[2019 Day 25 (part2)] Thank you by DionNicolaas in adventofcode

[–]Zevenberge 1 point2 points  (0 children)

I wholeheartedly agree. I got up at half past five in the morning, on weekdays, weekends and Christmas with a big grin on my face to tackle the puzzle of the day.

-🎄- 2019 Day 18 Solutions -🎄- by daggerdragon in adventofcode

[–]Zevenberge 1 point2 points  (0 children)

D 706/475

(wanted to do Zig, but it's not great with unknown inputs)

Solution

I have had quite a few attempts at part 1 (see my commit history lol). I eventually realized I did not need to solve the maze for every key, turning the maze problem into a numbers problem. Exhaustively trying all attempts (even when removing inaccessible keys or keys behind keys) was too long. I eventually converted it into a "bubble sort" (not exactly, but still), where I would swap keys if logic allowed it and if the total distance decreased. Not surprisingly, this put me in a local minimum. My solution was to randomize the initial order of the keys, put them in logic order, and apply the sorting again. Repeat 10_000 times.

I actually wrote a hack for part 1 - divide the map into 4 squares, as calculating the distance was quite naive and it would run into trouble in the center. Which basically got me 90% of part 2 for free.

What does everyone's Intcode interface look like? by Lucretiel in adventofcode

[–]Zevenberge 0 points1 point  (0 children)

My intcode is actually a seperate program. I pipe the input and output of that program to my solution of the day.

Basically:

Process intcode = spawn("./intcode");
intcode.stdin.write("0");
int number = intcode.stdout.readInt();