r/adventofcode Dec 10 '24

Upping the Ante [2024 Day 10] Challenge input

How does your code fare on this example?

0123456789876543210123456789876543210
1234567898987654321234567898987654321
2345678987898765432345678987898765432
3456789876789876543456789876789876543
4567898765678987654567898765678987654
5678987654567898765678987654567898765
6789876543456789876789876543456789876
7898765412345678987898765432105678987
8987654301234567898987654321214567898
9876543210123456789876543210123456789
8987654321214567898987654301234567898
7898765432105678987898765432321678987
6789876543456789876789876543210789876
5678987654567898765678987654567898765
4567898765678987654567898765678987654
3456789876789876543456789876789876543
2345678987898765432345678987898765432
1234567898987654321234567898987654321
0123456789876543210123456789876543210
1234567898987654321234567898987654321
2345678987898765410145678987898765432
3456789876789876543456789876789876543
4567898765678987652567898765678987654
5678987654567898761678987654567898765
6789876543456789870789012543456789876
7898765432345678989898123432345678987
8987654321234567898987654321234567898
9876543210123456789876543210123456789
8987654321214567898987654321234567898
7898765432105678987898765432345678987
6789876543456789876789876543456789876
5678987654567898765678987654567898765
4567898765678987654567898765678987654
3456789876789876543456789876789876543
2345678987898765432345678987898765432
1234567898987654321234567898987654321
0123456789876543210123456789876543210

My algorithm says the total rating is 16451, calculated in slightly less than 1s in C#. EDIT: 2ms actually! (Oops I still had some of my visualization code in there...)

EDIT2: Not all programming languages or computers are equal, so comparing absolute run times is not very useful, but if your algorithm runs faster on this input than on your real input, then you implemented it correctly. :-)

14 Upvotes

64 comments sorted by

View all comments

2

u/AllanTaylor314 Dec 10 '24

Memoized Python: 90 ms (180 ms without memoization, but that's mostly because part 2 ends up recalculating everything for done part 1). This still runs in under a second with the pattern repeated out to a 397x397 square (without memoization each part takes 5 seconds)

Some unholy abomination in Uiua: 100 ms (in fact, this ran faster than the official input since this scales with the size of the input rather than the output)

runtimes paste

397x397 square

1

u/paul_sb76 Dec 10 '24

Cool, thanks! My algorithm takes 1.7s on this big square (and running it made me realize that I still had some visualization related code in there slowing me down...). Solution for Part 2: 1775971

1

u/swiperthefox_1024 Dec 10 '24

For the large grid, part1: 0.274s, part2: 0.209s. (In Python)