#advent code

1 messages ยท Page 1 of 1 (latest)

grave vortex
#

Is there any reasonable way to do day 2 without a look up table

winter gust
#

yes

#

maths

grave vortex
#

How do maths on string sir. I don't want to convert to char then get ascii offsets to subtract because that isn't clean

winter gust
#

its not that bad

#

could also do 'ABC'.indexOf(a)

grave vortex
#

advent day 2 part 2

document.body.innerText.split("\n").slice(0,-1)
  .map(a=>["ABC".indexOf(a[0]), "XYZ".indexOf(a[2])])
  .map(a=>a[1]*3+(((a[0]+a[1]-1)%3)+3)%3+1)
  .reduce((a,b)=>a+b)
winter gust
#

nice

wise gyro
#

@grave vortexwhere day 3

grave vortex
#

Lick my elf bag sack
||```js
// https://stackoverflow.com/a/55435856/8133370
function* chunks(arr, n) {
for (let i = 0; i < arr.length; i += n) {
yield arr.slice(i, i + n);
}
}

// https://stackoverflow.com/a/41708135/8133370
var strIntersect = (a,b) => a.match(new RegExp([${b}], "g")).join('')

var elfSacks = document.body.innerText.split("\n").slice(0,-1)
var elfSackTrios = [...chunks(elfSacks, 3)]
var elfSackBadges = elfSackTrios
.map(elfSackTrio=> strIntersect(strIntersect(elfSackTrio[0], elfSackTrio[1]), elfSackTrio[2])[0])

var priority = item => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(item)+1

elfSackBadges.map(priority).reduce((a,b)=>a+b)


I couldn't make this one into a cursed oneliner because I relied on a stackoverflow function I don't understand how it works
wise gyro
#

@grave vortexwhere day 4

grave vortex
#

I havent done it

grave vortex
#

Day 4 Part 1

||```js
var pairs = document.body.innerText.split("\n").slice(0,-1)
.map(pair => pair.split(",") // split into the two ranges
.map(range=>range.split("-").map(Number))) // split ranges into their two numbers while parsing them
.filter(pair => {
// check if either pair contains the other entirely, tossing ones that dont
var rangeA = pair[0]
var rangeB = pair[1]

if (rangeB[0]>=rangeA[0] && rangeB[1]<=rangeA[1]) return true
if (rangeA[0]>=rangeB[0] && rangeA[1]<=rangeB[1]) return true
return false

})

console.log(pairs.length)


My dayz position in queue is 8 so I may have time for part 2
#

Day 4 Part 2

||```js
var pairs = document.body.innerText.split("\n").slice(0,-1)
.map(pair => pair.split(",") // split into the two ranges
.map(range=>range.split("-").map(Number))) // split ranges into their two numbers while parsing them
.filter(pair => {
// check if either pair contains the other entirely, tossing ones that dont
var rangeA = pair[0]
var rangeB = pair[1]

if (rangeB[0]>=rangeA[0] && rangeB[0]<=rangeA[1]) return true
if (rangeA[0]>=rangeB[0] && rangeA[0]<=rangeB[1]) return true

if (rangeB[1]>=rangeA[0] && rangeB[1]<=rangeA[1]) return true
if (rangeA[1]>=rangeB[0] && rangeA[1]<=rangeB[1]) return true
return false

})

console.log(pairs.length)


That was a super easy part 2, I am only 6 in queue, now what do I do to wait
pliant pebble
#

@analog drum are you doing aoc daily at challenge start time

winter gust
#

i forgot this is real

analog drum
#

tonight I was a bit late though as I was at a family member's house

#

I'm not super going for speed but at the same time it's nice to see how fast I can do things xP

pliant pebble
#

okie

#

i wasted so much time on parsing today

#

it took me 8 minutes just to parse the stacks

#

i honestly didn't realise just hardcoding the input in source was an option, would've been off much better if i just did that

analog drum
#

It took me a minute to figure out how I should parse things but I think I figured out an okay way

#

of course once I finished I thought of a way that would be a lot more efficient though

#

haven't implemented it yet but will probably later tonight

grave vortex
#

what language are you writing in?

pliant pebble
#

i did it in ts

analog drum
#

so far I've done ts and nim, whichever I think would work better for the puzzle

#

the complicated parsing for today looks like it really killed off a lot of participants

#

it'll be interesting to see how many people come back

grave vortex
#

parsing today was 10x easier than yesterday's part two

#

yesterday I spent like 30 minutes working on parsing where today I spent like 3

analog drum
#

the parsing for the parts was the same for yesterday? do you mean the logic for yesterday?

grave vortex
#

by "today" I mean day 4

#

it's very very late for me, I wont be doing day 5 till I wake up

grave vortex
grave vortex
pliant pebble
#

you can group with a .map and a .filter pretty easily

grave vortex
#

how so?

pliant pebble
#

.map((_, i, t) => !(i % n) && t.slice(i, i + 3)).filter(Boolean)

grave vortex
#

I am aware of .map giving an index for the second arg, what is t?

pliant pebble
#

t is the array you're calling .map on

grave vortex
#

oh my god that is so useful

pliant pebble
#

yea for oneliners

#

if you're calling it on something that's already in a variable you can just a.map((_, i) => !(i % n) && a.slice(i, i + 3)).filter(Boolean)

grave vortex
#

god its almost 1 am and I am going to rewrite my day 3 now

#

Oh my god thank you so much
||```js
// https://stackoverflow.com/a/41708135/8133370
var strIntersect = (a,b) => a.match(new RegExp([${b}], "g")).join('')

var elfSacks = document.body.innerText.split("\n").slice(0,-1)
var elfSackTrios = elfSacks.map((_, i, t) => !(i % 3) && t.slice(i, i + 3)).filter(Boolean)
var elfSackBadges = elfSackTrios
.map(elfSackTrio=> strIntersect(strIntersect(elfSackTrio[0], elfSackTrio[1]), elfSackTrio[2])[0])

var priority = item => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(item)+1

elfSackBadges.map(priority).reduce((a,b)=>a+b)

#

no more accursed function* that I dont understand at all

analog drum
#

that feels like a super cursed regex still

grave vortex
#

yea

#

it makes sense, but its cursed

analog drum
#

why not just a.includes(b)

grave vortex
#

oh

#

yea that would make sense too

#

why didnt I think of that

analog drum
#

oh I see now, that wouldn't work for your immediate case but I think it'd make more sense if you had originally used includes instead of the regex

#

but it works

pliant pebble
#

this was my attempt at onelining part 2

part 2

input.split('\n')
  .map((_, i, t) => !(i % n) && t.slice(i, i + 3))
  .filter(Boolean)
  .map(g => [ ...g[0] ].find(c => g[1].includes(c) && g[2].includes(c)).charCodeAt())
  .reduce((a, b) => a + b - (b > 96 ? 96 : 38), 0)

but i did that after initially using lodash _.chunk and being challenged not to use it, you can make it a single map+reduce if you just check for falsy values in the reduce

#

i just didn't feel like bothering

analog drum
#

I just did manual chunking

#
let queue = input
while (queue.length > 0) {
  const [one, two, three] = queue
  queue = queue.slice(3)
  // whatever
}
#

though I was dumb and should have used splice instead of spread and slice

pliant pebble
#

aoc is the only thing i use lodash for

#

useful for shit like this

analog drum
#

that's true

grave vortex
#

if getting the input into ruby was as easy as document.body.innerText in my browser, I would be using ruby in a heartbeat over js

analog drum
#

is it not just File.read("filename")?

#

that splits on newlines I guess but just join the array back into a string if you need to

grave vortex
#

you underestimate my laziness if you think I can be bothered to save a file into a path accessable to my WSL

analog drum
#

any path is accessible to wsl though xP

#

/mnt/c/Users/you/whatever

pliant pebble
#

i just ctrl+a + copy paste it into a new file

#

you can nano that

analog drum
#

that too

grave vortex
#

true

#

I may try ruby for day 5

#

oh god

#

I will think about that later

analog drum
#

very fun parsing

#

i thought of a really slick way to do it that I'm a tiny bit proud of

grave vortex
#

I will probably too when my brain isnt rotting from a full day

#

good night!

analog drum
#

sleep good

pliant pebble
#

my initial approach was to ||take the last number of the last line, make a new array of that length, and then fill the array by iterating the stack lines in reverse and getting the (i * 4) + 1th char||

#

only afterwards realised that ||the stack indexes are on the same columns as their crates so if you instead iterate the last line you don't need to do the math||

#

said math also took me way too long, wasted most of my time on it

grave vortex
#

Couldn't you start by ||using regex to filter out non \w|\d, then just use map to turn rows into cols? ||

analog drum
#

My initial approach was ||allocate and generate a 2d char array with the length of the line / 4, then I chunked the line into groups of four and read the 1th char from - that ended up being silly, so now I just iterate with for (let i = 0; i < lines[0].length / 4; ++i) to get the letter of each box in a row - but your solution gives me an idea to combine the two but I'm not sure it'd be any more efficient than what I already have||

analog drum
#

Array.reduce would probably work better than map for that too

pliant pebble
#

what i had actually written
||```ts
const [ stacksRaw, movesRaw ] = inputRaw.split('\n\n');
const [ indexes, ...contents ] = stacksRaw.split('\n').reverse();
const stacks = Array.from({
length: +indexes.trim().split(/\s+/).at(-1),
}, (_, i) => {
const idx = (i * 4) + 1;
return contents.map(c => c[idx]).filter(c => c !== ' ');
});

analog drum
#

you love how codeblocks can't be spoilered

grave vortex
pliant pebble
#

huh, what platform

analog drum
#

desktop

pliant pebble
#

works for me on desktop

#

and android

grave vortex
#

Same

analog drum
#

wacky, it's never worked for me on any platform

grave vortex
#

I haven't had a client that it doesn't work on

#

Os?

analog drum
grave vortex
#

Maybe it's a Mac/ios thing that its broken on

analog drum
#

on linux

#

I've never had it work on any client for several years, I've even had to make workarounds for previous advent of codes because of it (other people had the same issue at the time as well)

grave vortex
#

Are you using discord-arch-electron? I think I remember code spoilers not working when I used manjaro

analog drum
#

just normal discord, no system electron

pliant pebble
#

do you have spoilers disabled in appearance settings

analog drum
#

no, you can see the other spoiler in the reply

pliant pebble
#

wtf lol

analog drum
#

and my theme is just changing discord's bg variables

grave vortex
analog drum
#

what the heck

#

I reloaded my client and it works????

grave vortex
#

Lmao

analog drum
#

discord what are you on

#

I had swapped channels a few times as well

grave vortex
analog drum
#

inb4 it's a patch I just hadn't reloaded and gotten in the last few days or something

glad rune
analog drum
#

It's not a very compact way to do it but sure (my variable names suck)
||```ts
import { readFileSync } from 'fs'

const [stackString, moveString] = readFileSync('./inputs/05.txt').toString().split('\n\n')

const stackStringArray = stackString.split('\n')
stackStringArray.pop() // Get rid of the column labels

// Initialze the stacks of crates, one for each star
const stacksOne: string[][] = []
const stacksTwo: string[][] = []
for (let i = 0; i < stackStringArray[0].length / 4; ++i) {
stacksOne.push([])
stacksTwo.push([])
}

// Populate the initial crate configuration
for (const line of stackStringArray) {
for (let i = 1; i < line.length; i += 4) {
const box = line[i]
if (box === ' ') continue
stacksOne[Math.floor(i / 4)].unshift(box)
stacksTwo[Math.floor(i / 4)].unshift(box)
}
}

#

oo I just thought of a way to do it without splitting the input into lines

#

I need to finish my homework then maybe I'll do that and benchmark it to see how much faster it is

#

if I was doing this in a language that wasn't TS/JS I'd use a string instead of a string array but eh

#

aeth's solution is pretty fancy and elegant on its own though, I didn't know ||the Array constructor could do that||

pliant pebble
#

||it's not the constructor, it's the static from method||

#

but yea

#

i've used that in like 3/5 days so far lol

pliant pebble
wise gyro
#

@grave vortex 5 & 6... NOW!

winter gust
#

6??

wise gyro
#

is 6 not out?

pliant pebble
#

no lol

grave vortex
#

I caught some kind of cold/virus and slept all day

#

Gonna go back to bed

#

I will do 5 and 6 together tomorrow

wise gyro
#

oh

#

get better soon <3

analog drum
#

aeth is catching up to me woag

pliant pebble
#

i was slow today

#

the lack of sleep is slowly getting to me, these are at 6am for me

#

at least part 2 was easy

analog drum
#

yeah, that makes sense

#

I didn't get to my PC until about 10 after the hour

#

once I go to visit my parents for the holidays I'll probably be a lot slower too, it'll be later at night

pliant pebble
#

ah fair

grave vortex
#

Day 5, part 1,
Still sick, some of the worst code I have ever written

||```js
var input = document.body.innerText.split("\n")

var erduish = input.splice(0,9).map(a=>a.split(""));

// row to col
var stacks = ([...new Array(34)]).map((_,i)=>erduish.map(a=>a[i])).filter(a=>Number(a.slice(-1))).map(a=>a.slice(0,-1).filter(b=>b!==" ").reverse())

// move [0] from [1] to [2]
var commands = input.map(str=>str.match(/\d*/g).filter(a=>a!=="").map(Number)).filter(a=>a.length===3)

commands.forEach(command=>{
// do [0] times
([...new Array(command[0])]).forEach(_=>{
// take last from [1] and push onto [2]
stacks[command[2]-1].push(stacks[command[1]-1].pop())
})
})

// get top element from each stack
stacks.map(stack=>stack.slice(-1)[0]).join("")

#

Day 5 part 2
||```js
var input = document.body.innerText.split("\n")
var erduish = input.splice(0,9).map(a=>a.split(""));

// row to col
var stacks = ([...new Array(34)]).map((_,i)=>erduish.map(a=>a[i])).filter(a=>Number(a.slice(-1))).map(a=>a.slice(0,-1).filter(b=>b!==" ").reverse())

// move [0] from [1] to [2]
var commands = input.map(str=>str.match(/\d*/g).filter(a=>a!=="").map(Number)).filter(a=>a.length===3)

commands.forEach(command=>{
// take last [0] from [1] and push onto [2]
stacks[command[2]-1].push(...stacks[command[1]-1].splice(-1*command[0]))
})

// get top element from each stack
stacks.map(stack=>stack.slice(-1)[0]).join("")

grave vortex
#

day 6 part 1 and 2

|| To change from 1 to 2 just make marker_len = 14

// https://stackoverflow.com/a/53526999/8133370
var unique = (a,t={}) => a.split("").filter(e=>!(t[e]=e in t));

var input = document.body.innerText

var marker_len = 4

for (let i = 0; i < input.length; i++) {
  if (unique(input.slice(i,i+marker_len)).length == marker_len) {
    console.log(i+marker_len)
    break;
  }
}
```||
brittle quarry
#

you will stop using var

#

idk why it does this, someone help?
||```julia
struct file
size::Int64
end

struct dir
subdirs::Dict{String, dir}
files::Dict{String, file}
parent::Union{dir, Nothing}
end

lines = split(read("input.txt", String), "\n")

baseDir = dir(Dict(), Dict(), nothing)
curDir = baseDir

for l in 2:length(lines)-1
line = lines[l]
if(startswith(line, "$"))
if(contains(line, "ls"))
continue
end

    _, cmd, args = split(line, " ")

    if(args == "..")
        global curDir = curDir.parent
        continue
    end

    @info curDir
    global curDir = curDir.subdirs[args]
    continue
end
if(startswith(line, "dir"))
    _, name = split(line, " ")
    curDir.subdirs[name] = dir(Dict(), Dict(), curDir)
    continue
end

size, name = split(line, " ")
curDir.files[name] = file(parse(Int64, size))

end

@info baseDir

||
analog drum
#

does it run correctly with the example input? I don't see anything immediately wrong it it but I'm not sure how far into your input you got before it missed something

brittle quarry
#

it runs correctly until it tries to change into that dir

analog drum
#

I mean, is that the first dir that it tries to change into

brittle quarry
#

no

#

line 130 or something

analog drum
#

does it fail on the example input?

brittle quarry
#

yes

#

oh

#

i havent tried the example, i was just working off of the normal input

analog drum
#

it's a lot easier to debug things when you're using the smaller example since the puzzle tells you what output to expect

brittle quarry
#

true

glad rune
#

the dir names aren't unique

#

idk julia and didn't read the error

#

but that's why the example worked for me and the actual input didn't

brittle quarry
#

...theyre not unique?

#

i mean they gotta be unique in at least the dir right?

glad rune
#

the names i mean

#

so like

#

there can be a/b and c/b

brittle quarry
#

also idk julia either

#

i cant run the example cuz theres some \r that i cant remove

glad rune
#

change end of line sequence from CRLF to LF

#

bottom right if ur in vscode

brittle quarry
#

bruh

#

yea the exmple works

brittle quarry
#

what. it never goes into vlwl

brittle quarry
#

OHHH

#

CONTAINS LS

grave vortex
brittle quarry
#

that is absolutely horrid.

grave vortex
#

lmao

brittle quarry
#

you cant afford to run vsc?

grave vortex
#

I cant be assed to download the input into a file then import it in a language

brittle quarry
#

its one line..

grave vortex
#

eh

glad rune
#

LMAO

grave vortex
#

firefox's editor has most of the vscode features I like, and I am too lazy to do anything otherwise

#

have you not noticed how my code takes its input from document.body.innerText?

brittle quarry
#

i didnt bother to read it before

grave vortex
#

lmao

#

I am aware of how cursed my development method is

#

its very easy to just open devtools and start writing

#

This advent day is making me want to kill myself

brittle quarry
#

yeah i hate tree like structures

#

haha yes i got it finally

#

day 7:
|| ```julia
struct dir
subdirs::Dict{String, dir}
files::Dict{String, Int64}
parent::Union{dir, Nothing}
end

lines = split(read("input.txt", String), "\n")

baseDir = dir(Dict(), Dict(), nothing)
curDir = baseDir

for l in 2:length(lines) - 1
line = lines[l]

if(startswith(line, "\$"))
    if(startswith(line, "\$ ls"))
        continue
    end

    _, cmd, args = split(line, " ")
    if(args == "..")
        global curDir = curDir.parent
        continue
    end
    global curDir = curDir.subdirs[args]
    continue
end
if(startswith(line, "dir"))
    _, name = split(line, " ")
    curDir.subdirs[name] = dir(Dict(), Dict(), curDir)
    continue
end

size, name = split(line, " ")
curDir.files[name] = parse(Int64, size)

end

cache = Dict{String, Int64}()
sumDirsBelow = 0;

function computeSize(path::String, directory::dir)
if(haskey(cache, path))
return cache[path]
end

sum = 0;
for (name, size) in directory.files
    sum += size
end
for (name, dir) in directory.subdirs
    sum += computeSize(path * "/" * name, dir)
end
cache[path] = sum

if(sum <= 100000)
    global sumDirsBelow += sum
end
return sum

end

totalUsed = computeSize("", baseDir)
@info "part one: " * string(totalUsed)

needToFree = totalUsed - 40000000
sorted = sort!(collect(values(cache)))

for i in eachindex(sorted)
if(sorted[i] > needToFree)
@info "part two: " * string(sorted[i])
break
end
end

grave vortex
#

I forgot that I should only be including directories with sizes over 100000, and just summed everything

||```js
var input = document.body.innerText

var folders = {}

input.split("cd ").slice(1).filter(dir=>dir.slice(0,2) !== "..").forEach(dir=>{
const split_folder = dir.split("\n")
const folder_name = split_folder[0]
const folder_contents = split_folder.slice(2, -1)

const sub_folders = folder_contents.filter(name=>name.slice(0,3) === "dir").map(name=>name.slice(4))
const files = folder_contents.filter(name=>name.slice(0,3) !== "dir").map(file=>Number(file.split(" ")[0]))

folders[folder_name] = {
sub_folders: sub_folders,
files: files
}
})

// gets the sum of all the numbers in an array
function sum(arr) { return arr.reduce((a,b)=>a+b, 0) }

// recursively sums the sizes of all the files in an array
function folder_size(name) {
const folder = folders[name]

return sum(folder.files) + sum(folder.sub_folders.map(folder_size))
}

// start recursive sum at root
folder_size("/")

winter gust
#

god i need to fix this shiki bug

grave vortex
analog drum
#

ugh, today is one that will be annoying

analog drum
#

my solution solves the star two example just fine and with the same exact results but then it doesn't get the right answer for my star two input

pliant pebble
#

today was hard actually

analog drum
#

I finally got it by rewriting my logic pawa_knock_head

#

tiny little printRope() function really pulling its weight for this one

#

this was pretty fun to do though

#

kinda want to animate it but also don't wan to put in too much more effort

pliant pebble
#

this one was really hard to visualise

#

i also think the explanation was hella confusing

#

right off the bat the planck thing confused me so much

analog drum
#

yeah, it was a bit confusing

#

it took me a bit to understand what the logic for moving diagonally should be but I did finally get it

#

I was over thinking it quite a bit

winter gust
#

the explanation was so confusing but reading the images made it make sense forme

pliant pebble
#

worked for the example, not for the real impl

#

my diagonal logic was already janky so i suspected it and just threw variations at it until it passed

#

aw cmon discord

analog drum
#

upload it as a file and spoiler the file

#

that should work better

winter gust
#

lol why do spoilers have more precedence

pliant pebble
#

zzz

#

it's in wsl

analog drum
#

remember how I said that spoilers and codeblocks are super broken trolley

pliant pebble
winter gust
#

i thought u meant the bug i fixed with shiki

analog drum
#

i mean I never enabled the vencord version of shiki until earlier today

#

codeblocks with other formatting is just super janky in general

#

welovebeing able to dothis

winter gust
#

i do actually

#

that one makes sens

analog drum
#

it does but it's still funny

winter gust
#

if only i could a

analog drum
#

but do you like hello there

#

it still makes sense but arguably less sense

analog drum
pliant pebble
#

how did you do it, i finished so much slower than everyone else i wonder if i grossly overcomplicated it

#

it did take me really long

#

just fixing stupid shit

analog drum
#

I'll share mine in just a sec, cleaning it up just a bit (console.logs everywhere moment)

#

I used the Array.from thing that I saw you use a few days ago, super useful xP

pliant pebble
#

ah shit mapping the direction to increments would've been a lot simpler

analog drum
#

I also didn't bother keeping track of the entire grid

pliant pebble
#

yeah lmao jeez that's exactly what i was afraid of, i did grossly overcomplicate it

analog drum
#

I feel like your solution would be slower just because it has to allocate so much more memory (comparatively)

pliant pebble
#

yeah it would be

#

you don't need to allocate a grid

#

the logic to grow it as well took me so long

#

oh well

analog drum
#

a few years ago there was a puzzle that was 3d conway's game of life

#

I didn't want to deal with resizing a 3d grid in space so I just had a const world = Map<string, bool>() and to set tiles I'd world.set(${x},${y},${z}) xP

#

it wasn't very fast but it was faster than me trying to implement the growing algorithms xP

pliant pebble
#

smart

#

my solution looks like this if i don't implement the unnecessary grid (and optimized the step logic based on yours too, but that didn't take me much time)

#

the core of it is completely unchanged lmao

#

aaaaaaaaaaaaaaaaaaaaaaaaaaa

#

i never actually used the grid

#

i only used it to track visits but that could've been done in any other ways

analog drum
#

oh using an object for directions instead of a switch case is smart

#

I've done that in the past but completely forgot about it today

pliant pebble
#
DIRECTIONS = {'U': -1J, 'D': 1J, 'L': -1, 'R': 1}

def sign(num: complex):
    return complex((num.real > 0) - (num.real < 0), (num.imag > 0) - (num.imag < 0))

def get_new_tail_pos(head: complex, tail: complex):
    diff = head - tail
    if abs(diff) >= 2:
        tail += complex(sign(diff.real), sign(diff.imag))
    return tail

def move_snake(data, tail_size):
    snake = [0] * (1 + tail_size)
    tail_seen = set()
    for line in data:
        cmd, size = line.split()
        for _ in range(int(size)):
            snake[0] += DIRECTIONS[cmd]
            for i, tail in enumerate(snake[1:], 1):
                snake[i] = get_new_tail_pos(snake[i-1], tail)
            tail_seen.add(snake[-1])
    return len(tail_seen)

if __name__ == '__main__':
    print(move_snake(input_str.split('\n'), 1))

what the hell

analog drum
pliant pebble
#

one of my professors wrote that

#

using imaginary numbers or something

#

๐Ÿ˜ตโ€๐Ÿ’ซ

analog drum
#

goodness sake

#

yeah

#

that's

#

storing x in the real part and y in the imaginary part

#

definitely bigbrain time

winter gust
# pliant pebble ```py DIRECTIONS = {'U': -1J, 'D': 1J, 'L': -1, 'R': 1} def sign(num: complex):...

my part 1 solution looks similars to this lol

import sys

Direction = {
  "R": 1 + 0j,
  "U": 1j,
  "D": -1j,
  "L": -1 + 0j,
}
visited = set()

head = 0j
tail = 0j
for line in sys.stdin:
  if line == "\n":
    break
  dir = Direction[line[0]]
  for _ in range(int(line[2:])):
    head += dir
    if abs(head - tail) >= 2:
      if (head.real != tail.real and head.imag != tail.imag):
        if (abs(head.real - tail.real) == 1):
          tail = head.real + tail.imag * 1j
        else:
          tail = tail.real + head.imag * 1j
      tail += dir
    visited.add(tail)

print(len(visited))
pliant pebble
#

imagine yourself some bitches

winter gust
#

cope

analog drum
#

is it normal to abuse complete numbers like that in python or are you just equally insane as aeth's professor

winter gust
#

im just a math person and im used to complex numbers representing coords in 2d space

#

feels more like a usage than an abuse

analog drum
#

i suppose so

winter gust
#

as soon as i had the thought "how do i condense a coordinate into one value" i was like yo complex

brittle quarry
glass zenith
#

fucj

#

how delete

brittle quarry
#

my crt fragmenting :((

#

so close

#

yet so far

brittle quarry
#

the fuck

#

i checked the logic like 3 times now but nothing seems wrong

brittle quarry
#

spoiler for 10:2 || start with cycle = 0, not 1 ||

#

this graphic is misleading

analog drum
#

it's not really misleading?

#

it depends how you laid out your data structures and logic

#

today's was fun though, wish I could have been able to start on it earlier

analog drum
# analog drum it's not really misleading?

||if you had a language like lua that indexes arrays starting at 1 this that layout wouldn't have even looked strange, and in others you should be used to the fact that 0th = first||

brittle quarry
#

||julia uses 1 as array start
though i do think that the cycle thing leads you to believe to start with 1, cycle 1 is clearly the first requested pixel||

#

somehow it worked for task one

#

i dont even want to know how

analog drum
#

like I said, it entirely depends on how you implemented or logic and/or data structures

#

for example, ||if you were off by one, just write the pixel before incrementing the cycle counter||

brittle quarry
pliant pebble
#

today was fun

#

i slept in and these are so much more enjoyable if you don't go for speed

#

it was so hard to understand though (part 2), i didn't understand what the problem description was asking at all

#

the example got me there but i didn't immediately understand what it was doing either

#

also the text output itself was so hard to read lol

shell roost
#

wtf why did noone tell me this existed

winter gust
#

xd

#

i love how hidden it is

shell roost
#

yesterday's puzzle was really easy for some reason

#

didn't make it any less fun

shell roost
#

so confusing

lost sun
#

you love my solution

finite juniperBOT
# lost sun https://github.com/wingio/advent-of-code-2022/blob/main/src/main/kotlin/days/Day...

**DayTen.kt: **

package days

import inputs.dayTenInput

object DayTen: Day {

    private val program = dayTenInput.lines()
    private var x = 1
    private val cycles = mutableListOf<Int>()
    private val display = ".".repeat(240).toMutableList()
    private var sprite = x-1..x+1

    override fun solve() {
        program.forEach {
            val command = it.split(" ")
            when(command[0]) {
                "noop" -> cycle()
                "addx" -> {
                    cycle()
                    cycle()
                    x += command[1].toInt()
                }
            }
        }

        val answer = cycles.sumOfIndexed { i, reg ->
            if(((i + 1) - 20) % 40 == 0) reg * (i + 1)
            else 0
        }

        println("Part 1: $answer")
        println("Part 2:")
        display.chunked(40).map {
            it.joinToString("")
        }.forEach(::println)
    }

    private fun cycle() {
        val pos = cycles.lastIndex
        if(sprite.contains(pos % 40)) {
            display[pos] = '#'
        }
        cycles.add(x)
        sprite = x-1..x+1
    }

    private fun <T> Iterable<T>.sumOfIndexed(selector: (Int, T) -> Int): Int {
        var sum = 0
        iterator().withIndex().forEach { (index, value) ->
            sum += selector(index, value)
        }
        return sum
    }

}
lost sun
#

guh bad bot

shell roost
#

i actually made my display a 2d array

lost sun
#

i didn't make it any more complicated than it needed to be

shell roost
finite juniperBOT
shell roost
#

they should have made it 420

lost sun
#

i originally did 2d array but realized it was not necessary

shell roost
#

easier imo

#

making 1d array fries my brain

lost sun
#

display[pos] = '#'

shell roost
#

it's not hard to draw to 2d array

#

just math which u need to do anyway

lost sun
#

bad bot

shell roost
#

how

#

I <>

lost sun
#

oh

#

its not day 10 anymore so no need to prevent spoilers

shell roost
#

I'm upset I didn't see the +20 %40

#

but that's honestly not much cleaner than just hardcoding the numbers

#

so eh its fine

lost sun
#

either way

#

i didn't know how many cycles there were when i first wrote it

#

didn't bother to check tonguecat

shell roost
#

huh

lost sun
#

i didn't originally check how many cycles had passed before totaling the power

#

i just assumed i got at least that part right

#

i actually didn't get it right at first

pliant pebble
#

i love part 2, finally getting to scalability problems

shell roost
#

damn

lost sun
shell roost
#

of today?

shell roost
#

this reminds me of the someone else already uses this password meme

lost sun
#

weird coincidence

shell roost
#

my main struggle was reading the task incorrectly

#

aka incrementing number before incrementing cycle

lost sun
#

i just added to x register after the first cycle of addx

#

instead of after the second

#

oh we both had the same issue

shell roost
#

yes lmao

#

I did that too

#

u love how C++ has three billion ways to parse an int

lost sun
#

im guessing bc theres different kinds of ints and strings?

noble halo
#

me when rust .parse::<u64>()

shell roost
#
std::stoi
std::stol
atoi
stol
stoi
std::stoll
stream >> i
sscanf(str, "%d", &i)
#

they're all different ๐Ÿ™‚

noble halo
lost sun
#

.toInt more readable imo

noble halo
#

so unreadable

lost sun
#

just more direct in what it does

shell roost
noble halo
winter gust
#

i thought it was ajoke

lost sun
#

ah

noble halo
shell roost
#

the ones without namespaces are C and will return junk if it's invalid input and you need to use errno, the name space ones will throw exception, sscanf is a terrible idea because yes, stream one is probably okay

lost sun
#

kotlin has int and long, both signed and unsigned

#

maybe bigint too?

#

idk

#

yeah it does

noble halo
#

I like the type parameter style

lost sun
#

although bigint is part of java stdlib

shell roost
#

I dislike long and similar names

#

I prefer size names

lost sun
shell roost
#

int32, int64

noble halo
#

yop

#

long long makes no sense

grave vortex
#

day 7 made me quit

#

too lazy for that shit

analog drum
#

day 7 was still one of my favorites

lost sun
#

was day 7 the crane?

grave vortex
#

day 7 was the command line

glass zenith
#

day 7 was filesystem

#

cli

grave vortex
#
$ cd /
$ ls
dir a
14848514 b.txt
8504156 c.dat
dir d
$ cd a
$ ls
dir e
29116 f
2557 g
62596 h.lst
$ cd e
$ ls
584 i
$ cd ..
$ cd ..
$ cd d
$ ls
4060174 j
8033020 d.log
5626152 d.ext
7214296 k
#

i had a solution but it didnt work for real input because duplicate folder names

glass zenith
#

that's why u're supposed to build a tree

grave vortex
#

I dont like data structures in JS and I refuse to switch to python/java/ruby because I am too lazy to import one file

lost sun
#

that one wasn't too difficult

glass zenith
#

well u can always skip days!

#

and come back to them later, or not

grave vortex
shell roost
#

day 7 was nice

brittle quarry
#

yeppers

#

kinda missed building structures like that

analog drum
#

monkeys cozykaffee

pliant pebble
#

mokeys

grave vortex
pliant pebble
#

by the way, in case you didn't know, you can use parentheses around an object in an arrow function to save yourself from needing the body + return statement

#
var chain = Array.from({length:9}, _ => { return { x: 0, y: 0 }});

->

var chain = Array.from({length:9}, _ => ({ x: 0, y: 0 }));
grave vortex
#

thanks

brittle quarry
#

i dont know why but my brain so stupid i thought no () would just work but ofc it doesnt

glass zenith
#

this code reminds me how the length attribute is not read-only

#
> arr = [0, 1, 2]
[ 0, 1, 2 ]
> arr.length--
3
> arr
[ 0, 1 ]
> arr.length += 2
4
> arr
[ 0, 1, <2 empty items> ]
> 
grave vortex
#
###..###..###...##..###...##...##..#####
#..#.#..#.#..#.#..#.#..#.#..#.#..#.#...#
#..#.###..#..#.#..#.#..#.#..#.#....###.#
###..#..#.###..####.###..####.#.##.#....
#.#..#..#.#....#..#.#.#..#..#.#..#.#...#
#..#.###..#....#..#.#..#.#..#..###.#.... 

How on earth does this say RBPARAGF

#

that is most certainly not an F at the end there

#

Day 10
||```js
var input = document.body.innerText.split("\n").slice(0,-1);
var cycle = 0;
var X = 1;

var screen = ""

function crtDraw(){
const pixel = cycle%40;
if (pixel>=X && pixel<=X+2) {
screen+="#"
} else {screen+="."}
}

input.forEach(instruction=>{
cycle += 1;
crtDraw()

if (instruction !== "noop") {
cycle += 1;
crtDraw()
X += Number(instruction.split(" ")[1]);
}
})

// Resize console until each line displays 40 characters
console.log(screen)

pliant pebble
#

what the hell is up with RBPARAGF, i've seen three people with that specific answer

#

i thought the answers were unique per person

glass zenith
#

huh

winter gust
#

roblox for girlfriend

glass zenith
#

holy shit real

grave vortex
#

how the fuck do you do day 11 part 2
the numbers get FAR too large

winter gust
#

that sounds so cool i cant wait to do day 11

pliant pebble
#

it's very very mathy

#

ur gonna love it

winter gust
#

or is that day 10

pliant pebble
#

that's 11

winter gust
#

oh ok

#

im so excited i might do it rn

#

this might be the one i do in mathematica let me read it

#

oh day 11 was day 10 in my head

pliant pebble
#

fyi it's more thinking than actually writing mathy logic

winter gust
#

i read this last night

pliant pebble
#

oho

winter gust
#

this one im gonna do in dz's lispy

lost sun
#

i gave up on part 2

shell roost
#

part 2 is just knowing math and coming up with the solution then adding like 2 lines of code to make it work

#

small tip: || you need to find a way to reduce the number while not affecting the result of the "dividable by x" for each monkey ||

shell roost
#

oh god is today Dijkstra problem

#

I might skip today cause I hate path finding algorithms

#

yeah

lost sun
#

i will too

shell roost
#

@pliant pebble did u do Dijkstra

pliant pebble
#

yeh

shell roost
#

I hope they don't do more tasks like that

pliant pebble
shell roost
#

no fun to just use an algorithm without having to use brain

pliant pebble
#

i hope so too. i learned from it but it was not fun lol

#

i also didn't bother with a real pq impl which means my part 2 took 2 mins to run :^)

shell roost
#

lmao

#

what's part 2

pliant pebble
#

part 2 makes you find the shortest distance to the end node from any height-0 (a) node

shell roost
#

pq?

pliant pebble
#

priority queue

shell roost
#

oh

pliant pebble
#

i just iterate the entire list on each node

#
const lowestCostNode = () => {
  let lowest: Position;
  for (const [ position, cost ] of costs) {
    if (!seen.has(position) && (!lowest || cost < costs.get(lowest))) {
      lowest = position;
    }
  }

  return lowest;
};
#

instead of using a pq like you typically do with dijkstras

bold willow
#

guh idk whats wrong with mine

#

first is right but second is wrong

#

gives me wrong answer for sample

#

ugh ive spent literally all day on this

bold willow
#

whh now the sample is right but my input is the same

bold willow
#

can someone just look at my code and figure out what god awful mistake im doing because im tired of wasting my time on this

pliant pebble
distant wing
#

I fucking hate day 12

#

yuck

winter gust
winter gust
#

soon

brittle quarry
#

code of advent

frail dew
#

coded

brittle quarry
#

@winter gust VAP

#

hear me out.

winter gust
#

..

#

yes

#

no

#

no]

#

nop

#

no

#

no

#

n

#

on

#

on

#

o

#

no

#

no

#

no

#

no

#

no

brittle quarry
#

you know whats coming

winter gust
#

i will not

#

i will use a REAL LANGUAGE

#

running on REAL ARCHITECTURE

brittle quarry
winter gust
#

ok maybe like

#

day 1 or 2

#

or 3

brittle quarry
#

fucking love how you IMMEDIATELY knew

#

what

#

no

#

small grammatical error (it was very grave)

winter gust
grave vortex
#

I will do it in typescript this year

brittle quarry
#

might use again blobcatcozy

winter gust
#

vap asm
golfscript
APL
Uiua
Typescript
Rust

brittle quarry
#

vap asm blobcatcozy

grave vortex
#

No

winter gust
#

yes

winter gust
#

oh yea swift

grave vortex
brittle quarry
#

julia
zig
rust?
typescript whenever
elixir?
purescript?
go surely
haskell?
anything else worth trying?

winter gust
#

i dont understand

#

where is uiua

#

also @lyric saddle get in this c hannelk

lyric saddle
#

rael

winter gust
#

that was quick

lyric saddle
#

beam will not be real because rust sucks

brittle quarry
brittle quarry
#

meh

#

tried it years ago, didnt really like it i think

#

oopsie almost sent a slur

grave vortex
#

I generally just like it's niceities and macros

#

it has the best map syntax there is imo

#

['a','b','c'].map(&:upcase)
vs
['a','b','c'].map(a=>a.toUpperCase())

It lets you directly access object functions/values through &: instead of having to define a function that takes an entry

#

and for advent of code, where you are so very often mapping arrays, its amazing

brittle quarry
#

did you know

#

i wrote multiple days of aoc in js with just arrow functions and no variables

brittle quarry
#

no

#

thats me

grave vortex
#

look at the first message of this thread

#

I don't know how to do that quickly

#

/firstmessage is not a vencord thing

brittle quarry
#

does that mean i didnt

grave vortex
#

its a dumb thing where I just insist I'm the only person who did the thing jokingly.
I have no idea why im like this

brittle quarry
#

idk where i put them :(

grave vortex
#

I ate

brittle quarry
#

think they were on thr laptop arch install i wiped

lyric saddle
#

i thought aoc was a bit later and i actually could get my beam thing to work

#

oob

brittle quarry
#

Oofie!

lyric saddle
#

i think i will start with sane languages

#

then suffer doing the insane ones as it gets harder

#

from a scale of ruby to erlang to golfscript to uiua

analog drum
winter gust
#

start with insane ones

lyric saddle
#

laame

winter gust
#

then when it starts getting impossible

#

do sane ones

#

cus it will still be hard

#

i just dont wanna do what i did last year and

#

have too hard a time

#

and then get backlogged and give up

brittle quarry
#

25 pt2 in vap asm

winter gust
#

NO

brittle quarry
#

ill pay you

lyric saddle
#

lina fix my beam encoder

winter gust
#

maybe i will try it

#

but idk if the program would fit

brittle quarry
winter gust
#

there is a file

#

but i'd have to make my cpu more than 8 bit

#

blehhh

lyric saddle
#

vap speedrun beam

#

okay im gonna

winter gust
#

too busy doing cursed matrix stuff

lyric saddle
#

watch me

frail dew
#

@lyric saddle write it in graph Al

#

Graphologie

#

GRAPHql

lyric saddle
#

HOW

frail dew
#

Do

brittle quarry
#

Graph Al

lyric saddle
#

something catastrophic about rust using result types: no backtraces

#

yeah bitch WHERE

#

@winter gust trace my calls pls

winter gust
#

arent there result types that like

#

have info

#

u can make smth or smth idfhkk

lyric saddle
#

yea there are

#

anyhow can

frail dew
#

invite 1776680-321d3007

winter gust
#

yea anyhow

lyric saddle
#

oh you can already make lbs

#

i mean yeah

winter gust
lyric saddle
#

but i didnt think of that lol

winter gust
lyric saddle
#

oo

winter gust
#

but only show the data for the year ur lookin at

lyric saddle
#

real

#

cooking

winter gust
#

what does that do

lyric saddle
#

assembling beam file

#

that i can run (i cannot it just crashes the vm)

winter gust
#

are function exports just labels

lyric saddle
#

yes

winter gust
#

how do arguments work

lyric saddle
#

registers

winter gust
#

rrrftyuiop[']

lyric saddle
#

thats why the arity is there

winter gust
#

transpose

lyric saddle
#

NO transp eople allowed

frail dew
#

what lang are u guys doing first

lyric saddle
#

uiua is cis lang

frail dew
#

im prolly gonna just stick with swift all the way thru

winter gust
#

i realized the "no" sign is

#

actually a diagonal line

#

cus transposing a matrix mirrors across the diagonal

lyric saddle
#

๐Ÿšซ

#

i think im gonna start with ruby

winter gust
lyric saddle
#

i mean first day and second is like whatever

winter gust
#

my assembly thing

lyric saddle
#

nop

winter gust
#

and then uiua as well

lyric saddle
#

day 3 at least

winter gust
#

i wanna get that one out of the way

lyric saddle
#

day 1 and 2 not real

winter gust
#

i dont think imma actually do the assembly cus

#

it would require a lot of set up

#

for the input

frail dew
#

i wonder if i can do it in swift playgrounds on a ipad

#

would be funny

winter gust
#

oh yea how am i gonnna

#

run swift

frail dew
#

get the toolchain

#

they have win/linux builds

winter gust
finite juniperBOT
# grave vortex https://github.com/CodeF53/AdventOfCode/blob/main/src/globals.ts#L1-L9

**globals.ts: **Lines 1-9

import type { LoDashStatic } from 'lodash'
import lodash from 'lodash'

// make lodash global while covering TypeScript's loud sobs of "YOU CAN'T DO THAT"
// eslint-disable-next-line ts/no-unsafe-member-access
(globalThis as any)._ = lodash

// convince TypeScript not to scream when it sees lodash used in other files
declare global { const _: LoDashStatic }
lyric saddle
#

super husk react this man

winter gust
#

ambient types file

lyric saddle
#

be sane and autoimport from lodash

frail dew
#

f35 do you really need lodash

winter gust
#

or import lodash functions as needed

#

like a REAL developer

lyric saddle
#

yes

#

autoimport

winter gust
#

oh true that yes

grave vortex
frail dew
grave vortex
winter gust
#

it can declare the type

#

and then u can set it like normal and use it

grave vortex
#

set it like normal as in?

winter gust
#

as in globalThis._ = lodash rather than (globalThis as any)._ = lodash

grave vortex
#

it gets mad about that

winter gust
#

yea because you dont have it declared as a member on your global interface

#

is this a webapp

grave vortex
#

is this how you would declare it as a member on the global interface
global.d.ts

import type { LoDashStatic } from 'lodash'

// convince typescript that having lodash be global isn't a sin
declare global {
  const _: LoDashStatic
}
grave vortex
winter gust
#

what is globalThis

lyric saddle
#

why am i getting eof parsing the atu8

winter gust
#

in this context

lyric saddle
#

oh.

#

[?] AtU8 => \x00\x00\x00\x02\x03nya\x03runCode\x00\x00\x00\x1f

grave vortex
winter gust
#

no like

#

hover over it

#

and see what it is

#

it's type

grave vortex
#

globalThis is globalThis

lyric saddle
#

my chunk lengths are wrong help

winter gust
#

ohh

#

ok then what u did should work

#

but just use var instead of const

#

so u can actually assign it

grave vortex
#

var is evil and also doesn't fix the issue

#

I think I am happy with the cursed solution I had

winter gust
#

typescript SUCKS

lyric saddle
#

oh god this is actually starting to

#

look like it works

#

thats progress i think

grave vortex
#

is rini doing old advent or do they somehow already have 2023 day 1

winter gust
lyric saddle
#

yapping about my beam compiler

winter gust
#

no shes trying to write a compiler for something

#

before day1

#

so that she can use it

grave vortex
#

i'll compile your beans

winter gust
#

thanks for remindsing me

#

i need to heat up my coffe

lyric saddle
#

erl's beam_disasm has better errors than erlang itself

grave vortex
winter gust
#

yes u do

#

u use strict settings

#

and then write bad code

#

FIX ONE

grave vortex
#

I would fix the global lodash thing, but I don't want to fuck with esbuild or something

#

I want global lodash

#

and I don't want to stop using the really stupid easy typescript runtime thing I use

lyric saddle
grave vortex
#

Adding my strict typescript and eslint config to my job's codebase to ensure no one can replace me due to how horrid it is to write in

winter gust
#

you will go to jail for sabotage /j

lyric saddle
#

apparently beam is mad im not adding function info sections

#

oh

#

i set max labels to 0 thinking it wouldnt care

winter gust
#

i showed an advent of code problem to my little cousin

#

and explained its like christmas code puzzles

#

and she insisted on doing one by hand

grave vortex
#

oh god

grave vortex
#

@winter gust have they given up yet?

winter gust
#

yes

#

ololo

lyric saddle
#

new aoc challenge: modify your own dna to solve the puzzle

winter gust
#

sorry i need ai to do that

#

and thats forbidden

lyric saddle
#

true

winter gust
#

bitcoin in my bloodstream

#

soon

lyric saddle
#

it also modifies ur dna to make u wifi compatible

winter gust
#

terrifyinhg

#

keep my biology away from terrible computer standards

lyric saddle
#

bioluminescence except its at wifi wavelength

winter gust
#

thats kinda firee

lyric saddle
#

called Result::unwrap() on an Err value: DecompressError { status: Failed, output: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }

#

of course ishouldve used miniz_oxide::inflate::decompress_to_vec_with_limit instead of miniz_oxide::inflate::decompress_to_vec_zlib_with_limit

grave vortex
#

<t:1701406800:R>

winter gust
#

@lyric saddle what should i do day 1 in first

lyric saddle
#

im doing ruby first

grave vortex
#

do we have a private leaderboard set up

lyric saddle
#

thats the one we used last year

analog drum
#

the venboard

grave vortex
#

I blame not getting first on new Date() having no easy way to specify a timezone for everything to be based off off

winter gust
#

why are u using new date

#

fear

frail dew
#

i spent 30 minutes putting together the cli

lyric saddle
#

@winter gust did u complete

frail dew
#

and then another 30 doing part 1

#

part 2 seems like hell

winter gust
#

no

lyric saddle
#

wait i can check

winter gust
#

uiua is funny

frail dew
#

how are yall approaching part 2

winter gust
#

i was gonna write it in js terms but

#

||going thru each index of the string, if it starts with a number replace the number, then add the char at that index to a result||

lyric saddle
#

||im surprised everyone is doing that im just matching both numbers and strings, indexing the value and then % 10||

winter gust
#

||tbf i might be able to do that cus i think uiua has regex but||

#

||thats cheating (in uiua)||

lyric saddle
#

rate part 1 ||```rb
p$<.map{(f,*,l)=_1.scan(/[0-9]/);(f+(l|โ€Œโ€Œ|f)).to_i}.sum

#

banger

#

zero width char to the rescue

grave vortex
winter gust
#

FUCK

frail dew
#

im going to kill aoc devs for this edge case

#

wait

#

no its fine

grave vortex
frail dew
#

YEAH

#

does it actually matter?

#

i cant tell if it does

grave vortex
#

yes

#

it does

frail dew
#

FUCK

#

that's so shit

winter gust
grave vortex
winter gust
#

?!@$>R#E$F#WTGE

#

?@$R#F%TWG#YFEHBDRF

frail dew
#

do i need to match ||eight|| or not

#

im confused

grave vortex
#

here is my really simple fix for part 2
||```ts
const stringNums = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
export function partTwo(input: string): number {
// turn string nums into their numerical equivalents, surrounding numerical equivalent with self, as to not fuck up combos like "fiveightwo"
stringNums.forEach((num, i) => input = input.replaceAll(num, ${num.at(0)}${(i + 1)}${num.at(-1)}))

return partOne(input)
}

frail dew
#

yeah FUCK thats so dumb

winter gust
#

man idk what im doing wrong

grave vortex
#

have you checked your code against the example?

winter gust
#

yea it works on the example

#

but not on my input

grave vortex
#

part one or two

winter gust
#

two

grave vortex
#

can I see spoiler code and try and give a hint

winter gust
#

yea one sec tho cus i'll have to rewrite it in js

grave vortex
#

fair, I can't read much else

winter gust
#

jk

#

read this NOW

grave vortex
#

that is vomit inducing

#

thanks

#

is that some kinda golf language?

winter gust
#

somewhat . ?

#

its more like a data analysis language

#

linear algebra language

#

||```ts
function fix(str: string) {
let res = ""
for (let i = 0; i < str.length; i++) {
const match = nums.find(n => str.startsWith(n))
if (match) str = str.replace(match, nums.indexOf(match))
res[i] += str[0]
str = str.slice(1)
}
return res
}

#

i believe this is equivalent

frail dew
#

my attempt works on the example but not the actual data
nice

#

@violet crow in here

violet crow
#

i know what the edge case is and how to fix it but simultaneously i'm lying down and cuddling my plushies and that's more important to me than funny points on the internet game

grave vortex
violet crow
#

solving the problem is piss easy

frail dew
#

does it need to be 5,8,2

grave vortex
#

I need to come up with a better example one sec

frail dew
#

it worked on eightwothree Sad

winter gust
#

wait do you mean like

frail dew
#

AH wait..

#

i know what it is

#

wait do i

winter gust
#

||fiveight should be 58?||

frail dew
#

idk if it should

grave vortex
winter gust
#

oh fuck

frail dew
#

my code should've done that from the start wtf

grave vortex
winter gust
#

yeaaa......

#

ok

#

this one was evil

grave vortex
frail dew
#

this is so shit

winter gust
#

yea but ||it doesnt say it should be 8 2 3||

frail dew
#

exactly

grave vortex
#

the example definitely should've had at least one instance where not accounting for it would fuck you up

winter gust
#

yea basically imo

violet crow
#

||

numbers = {
  "zero" => "0",
  "one" => "1",
  "two" => "2",
  "three" => "3",
  "four" => "4",
  "five" => "5",
  "six" => "6",
  "seven" => "7",
  "eight" => "8",
  "nine" => "9"
}

puts File.read("input.txt").then{|s| numbers.each{|k, v| s.gsub!(k, "#{k}#{v}#{k}") }; s}.lines.map{|x|x.scan(/\d/).then{|y|y.first+y.last}.to_i}.sum```||
frail dew
#

this one is fucking me the fuck up mannn

violet crow
#

haven't tested this but i'm pretty sure it works

grave vortex
frail dew
#

yes

violet crow
frail dew
#

hm

#

i think i might have something..

grave vortex
violet crow
#

i put it in there just in case

grave vortex
#

good idea

winter gust
#

yea i put zero too

#

it also makes indexof math easier

frail dew
#

i lied FUCKING HELL

#

wait

#

maybe i lied again ๐Ÿ™‚

violet crow
#

i could make this smaller by using actual variables but i don't like doing variable assignment because semicolons are the plague when it comes to one liners

#

feels like i'm cheating if i do that...

#

tbf .then is a variable equivalent anyways lmao

frail dew
#

no ugh fuck

#

indexes in swift fucking suck

violet crow
#

every single time i rush to beat someone i end up taking like 3 hours lol

violet crow
grave vortex
violet crow
#

used to using older versions of ruby so just muscle memory

grave vortex
#

or better yet just do ['zero', 'one', 'two'] and then do each_with_index

violet crow
#

that's actually a really fun way of doing it yeah

grave vortex
#

thats effectively how I did it, but I didn't include 0, so I added 1 to every index

frail dew
#

IT WONT WORK RAHHH

#

and now my shit is a mess

grave vortex
#

have you managed to get 5,8,2?

frail dew
#

nope wt

#

f

grave vortex
#

when you are scanning for string numbers, how do you do that

frail dew
#

im coming for you swift

#

im going to get you swift

#

im going to explode you

violet crow
#

just to make this as unreadable as possible for non-ruby devs:
||rb ["zero","one","two","three","four","five","six","seven","eight","nine"].each_with_index.then{|numbers|puts File.read("input.txt").then{|s|numbers.each{|k, v|s.gsub!(k,"#{k}#{v}#{k}") };s}.lines.map{|x|x.scan(/\d/).then{_1.first+_1.last}.to_i}.sum}||

frail dew
#

string interpolation.

#

excuse you?

violet crow
frail dew
#

oh i know why the fuck its fucking fuck

grave vortex
violet crow
#

truly the most performant solution by far

winter gust
#

OMG I HAVE A GREAT IDEA

frail dew
#

i know why my shit is still fucked

violet crow
#

oh i already looked at it

#

i was trying to avoid variable declaration as much as possible

lyric saddle
#

$< so good

analog drum
grave vortex
#

please stop making ruby unreadable.
I write ruby daily at work and yet I can' barily understand whats going on

frail dew
violet crow
lyric saddle
#

the inputs are personal

violet crow
lyric saddle
#

everyones answer is different

frail dew
#

I DID IT

#

โค๏ธ

violet crow
grave vortex
violet crow
#

skill tissue

#

going to see how well graal and crystal fare now

analog drum
#

can someone send me their full input and their answer I feel like my code doesn't cover some edge case that wasn't in my full input

violet crow
analog drum
#

danke

winter gust
#

@lyric saddle holy shit

#

so basically

#

the correct way to think about every problem

#

is with matrixes

frail dew
winter gust
#

everything is a matrix

#

EVERYHTING IS A MTRIX

#

THE MATRIX

frail dew
#

this is shit 1s

lyric saddle
#

vap is a scalar

violet crow
#

swift makes these things unfun

winter gust
#

u wish u were this data structure

frail dew
grave vortex
violet crow
#

i am bad at pasting

#

lol

violet crow
#

i recommend using hyperfine for this

frail dew
#

how do i time

#

a

#

ok

analog drum
#

yeah okay apparently my part two didn't have any of the edge cases that people were having issues with

#

welp derpabelle

grave vortex
shell roost
#

IT'S DECEMBER

winter gust
#

HIII

frail dew
grave vortex
shell roost
#

SHOULD I BRING LEADERBOARD BACK

frail dew
#

yes

grave vortex
#

YES

winter gust
#

YES

frail dew
#

oh we're yelling

#

oops

winter gust
#

itsok

shell roost
#

ill bring them back in a bit

#

just woke up gonna eat first

winter gust
#

i hope u have fun with day 1

#

im having so much fuin

grave vortex
#

is vee at a disadvantage due to waking up after the problem releases?

violet crow
winter gust
#

leaderboardwise yea

shell roost
#

what time do they release them

#

00:00?

winter gust
#

midnight EST

shell roost
#

that's 6am for me

#

i think Americans with a normal sleep schedule are more at disadvantage

winter gust
#

yea defe

grave vortex
#

thats 10pm for me, so I am way past bed time

winter gust
#

this is cutting into my sleep

#

2am

analog drum
#

comes out at 20:00 for this american cozy

winter gust
#

how are u

#

4 hours behind me

grave vortex
shell roost
#

it's 8am for me rn

#

i normally sleep longer tho

frail dew
#

how do i get hyperfine to not fuck up args

winter gust
#

are u in li ke Alaske

grave vortex
shell roost
#

10h behind

#

blud living like a day in the past it's so over for u

analog drum
#

it would be 19:00/7PM but alaska merged timezones a while ago (for some reason) and chose the timezone further in the future

grave vortex
#
function ppAndTime(func: (input: string) => unknown) {
  const start = performance.now()
  const answer = func(input)
  const end = performance.now()
  const time = `${(end - start).toFixed(3)}ms`

  console.log(`Day ${day} ${func.name}: ${answer as any}\t${time}`)
}

ppAndTime(partOne)
ppAndTime(partTwo)

beautiful timer

frail dew
#

cba to figure that in swift

winter gust
#

oh fire

frail dew
#

my swift shit takes.. time

grave vortex
#

javascript is far faster than it has any right to be

frail dew
#

fr

#

im seeing like 10s for part 2 wtf

grave vortex
#

with big input or normal

frail dew
#

bigboy

grave vortex
#

did you just write it in a really inefficient way?

frail dew
#

i kinda did what u did in swift

#

i think its the number replacement shit

grave vortex
#

because there is no way my lazy ass solution is more than 5x faster

frail dew
#

part 2 then part 1

frail dew
grave vortex
frail dew
#

i couldnt spoil them

grave vortex
#

./s

grave vortex
frail dew
#

unless u can spoil those

violet crow
#

you can!

frail dew
#

oh ok 1s

#

um..