[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1734442950364826.png (2 KB, 416x283)
2 KB
2 KB PNG
bit by bit edition

>Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as a speed contest, interview prep, company training, university coursework, practice problems, or to challenge each other.
https://adventofcode.com/

/g/ leaderboard join code:
796940-44255af5
anonymous-only leaderboard:
383378-dd1e2041

previous thread: >>103548198
>>
bros these threads are getting a lil too cozy if you catch my drift
>>
File: slowpoke.png (123 KB, 475x475)
123 KB
123 KB PNG
Guys guys! I figured out the secret in this year's map! It's going to look like a giant "10" to celebrate the tenth year of AoC!
Not only that, but the stuff inside the ten is stuff from previous years maps! How cool is that?
>>
>>103554626
that's really cool man
>>
>>103554626
Wrong, the last line is actually I HATE WOMEN AND NIGGERS AND GAYS PS CODING IS FOR FAGS. By the time this is revealed Eric will be on a flight to El Salvador with the sponsor money stashed in a suitcase.
>>
File: 1704047221656758.png (1.51 MB, 1920x1080)
1.51 MB
1.51 MB PNG
You didn't get filtered by a simple puzzle like that, right anon?
>>
File: 1713335912051785.png (655 KB, 1600x5182)
655 KB
655 KB PNG
>>
>>103554667
well I managed to solve part 1 on my own..
>>
File: 1727301544156898.jpg (80 KB, 480x480)
80 KB
80 KB JPG
I dread the coming days
>>
>>103554752
I think it's exciting. In the hour before the puzzle drops, knowing there's a huge chance you could get filtered, but steeling yourself to do it anyway. This is exactly how the Romans must have felt before a big battle.
>>
>works on sample input
>your answer is too high
FUCK YOU ERIC YOU JEW

The last lines of my program output B and jump to 0. Register A is divided by 8 every loop, so A must be in the range [1, 7] on the last loop. Searching the program backwards, I find all A in [1, 7] which satisfy the output, then calculate new ranges [A*8, (A+1)*8-1] for each A, which will be used on the next check.

What's wrong with my logic?

// setup
let register = { a, b, c };
let out = [];

// opcode
let opcode = (ptr, op, literal) => {
let combo = literal;
if (combo == 4) combo = register.a;
if (combo == 5) combo = register.b;
if (combo == 6) combo = register.c;
switch (op) {
case 0: register.a = parseInt(register.a / Math.pow(2, combo)); break;
case 1: register.b = register.b ^ literal; break;
case 2: register.b = combo % 8; break;
case 3: ptr = register.a !== 0 ? literal - 2 : ptr; break;
case 4: register.b = register.b ^ register.c; break;
case 5: output.push(combo % 8); break;
case 6: register.b = parseInt(register.a / Math.pow(2, combo)); break;
case 7: register.c = parseInt(register.a / Math.pow(2, combo)); break;
default: break;
}
return ptr + 2;
};

// run program ignoring jump
let runSingle = (a, b, c) => {
register.a = a;
register.b = a;
register.c = a;
out = [];
let ptr = 0;
while (ptr < program.length) {
if (program[ptr] == 3)
ptr += 2;
else
ptr = opcode(ptr, program[ptr], program[ptr+1]);
}
return output;
};

let ranges = [[1, 7]];
let solutions = [];

[ ...program ].reverse().forEach((res, i) => {
// find accepted x in ranges, compute next ranges
let next = [];
ranges.forEach(range => {
for (let a=range[0]; a<=range[1]; a++) {
if (runSingle(a, 0, 0)[0] == res) {
if (i == program.length - 1)
solutions.push(a);
else
next.push([a*8, a*8+7]);
}
}
});
ranges = next;
});

console.log(Math.min(...solutions));
>>
>>103554889
>javascript
you need xor in better than 32 bits
>>
>Filtered by day 5 part 2
>doesn't matter, the silverGOD marches on
I kneel. I thought you would have given up by now
>>
File: aoc 2024 day 17 excel.png (307 KB, 2628x1162)
307 KB
307 KB PNG
Solved in Excel. No VBA.

Part 1 isn't too bad, each column executes a single instruction (with the exception of jump instructions, which do nothing in that column, but both the jump and the instruction after the jump are handled in the next column).
I included every relevant formula, color coded. Blue and green are simple input parsing; blue gets everything after the colon for the registers/program, and green finds the nth comma in the program, then returns the character directly before it.
The pointer (purple) checks if the previous instruction was a jump (and ensures A wasn't 0) and updates to the previous literal if so. Otherwise, it just increases by 2.
The opcode and the literal (yellow) are simple, just grab the C column's relevant instruction using the pointer.
Combo (dark blue) is the same as the literal if 3 or under, otherwise get the appropriate register from the previous column.
Registers A and C (pink) both have a single instruction that writes to them, they're easy.
Register B (orange) has a lot of instructions that write to it, but it's really just a few IFs.
Finally, the OUT (brown) carries over previous values, but updates itself if it's blank, the value above it isn't, and the opcode is 5.
To get part 1, I just concatenate all the OUTs after a bunch of steps.

Part 2 wasn't simple, and it requires a lot of manual work.
There's no way to compact part 1 into a single function that can be used in any cell (without VBA). So, to solve part 2, I did a manual recursive octal search.
>Run part1 with register A set to 8**15, (8**15)*2, ... (8**15)*7
>Check if the last digit of the output matches the last digit of the program
>This is true with (8**15)*6
>Put 6 in the "found" array, extend "running total" down a row
>Run part1 with (8**15)*6 + (8**14)*1, ... (8**15)*6 + (8**14)*7
>Check digits for each, extend found if two matching digits
>Repeat
>If dead end, step backwards and continue checking
First found value is part 2.
>>
File: file.gif (1.12 MB, 600x144)
1.12 MB
1.12 MB GIF
>>103554994
Process of solving part 2.
>>
>>103555005
Unspeakable based.
>>
>>103554994
i did this manually but there was too much backtracking
took me fucking FOREVER
>>
File: 1733887359530571.png (629 KB, 822x744)
629 KB
629 KB PNG
wowza yowza today was brutal
Eric is on a quest to either make me use Python or feel like an idiot, but I did manage to do it in awk today.

At least I didn't get caught up on 32-bit XOR ops, because awk HAS NO BINARY OPS at all, so I rolled my own. But wow, was part two awful. Solved most of it on pen and paper and just hardcoded everything into awk and then BROOT'ed on a limited pool of potential values for A.

Christ; how bad are the rest of the days gonna be?
>>
>reverse engineer my part 2
>reimplement with bigint so that XOR works
>run value against my program
>works and returns my program back
>enter value
>"That's not the right answer; your answer is too low."

bros, wtf am i doing wrong here? i realise TS/JS is shit but I seem to have the answer and it's just not accepting it.
>>
>>103554970
Imagine how happy he was getting that day 11 gold star
>>
>>103554970
based elf lore enjoyer
>>
>>103555264
Post your program/value so other anons can check
>>
>>103554593
What is it calculating?
>>
>>103554920
bro THANK YOU
>>
>>103555264
>>103555322
nice try Eric, i'm not getting banned. turns out I just forgot to copy a digit on paste, so all good.
>>
>>103555264
post your code dw I'll front you the $100k legal fees
>>
>>103555144
>keeps using a text-processing DSL as a full-fledged programming language
woman moment
>>
Best day so far, Christmas tree is #2
>>
calendar anon here
filter status = not
will update the image tomorrow
>>
>>103555264
try to use an other language
Perl is the closest scripting language to JS, integers are int64_t or uint64_t so bitwise operations will just work
>>
>>103555477
Did anyone do day 14 properly? It was late so I gave up on crt and brooted the final stretch

let mut ans2: usize = x_remainder;
while ans2 % uheight != y_remainder {
ans2 += uwidth;
}
>>
>>
>>103555477
Liked this a lot more than the tree, easily best so far
>>
File: aoc_2024_17.png (165 KB, 752x2391)
165 KB
165 KB PNG
Perl. I should try to rewrite it to do gold backwards probably, no need to carry around future checks that way. And maybe throw in vec instead of array of ints.
Maybe I'll try for generic solution in Summer. At least for one where we assume that B and C reset between the output steps.
>>
>>103555477
agreed, it was very satisfying to figure out
>>
>>103555477
>>103555596
u mean worst day so far
>>
>>103555515
bigints worked fine for this in JS without any actual code changes beyond changing definitions. i figurës out my problem anyway (I didn't copy correctly), not switching langs because of dumb shit like bitwise ops when im sharing my solutions with coworkers.
>>
>>103555667
better than another grid pathfinding
>>
>if A hits zero, the program must end (no jumps + no way to increase A)
>so for any non-halting program A must always be nonzero
>so there's no flow control, jumps always trigger
>therefore not Turing complete

Does this work? Feels like it'd be impossible to make an undecidable program.
>>
>>103555831
Wouldn't you be able to run at an indeterminate length if you just used B and C as your registers? The jump can be made to any arbitrary point and then you can just halt by setting A to zero.
>>
File: gfn.webm (1.93 MB, 960x540)
1.93 MB
1.93 MB WEBM
>>103555667
>>
>>103555638
you can do this anon
my ($a_reg) = <> =~ /(\d+)/;
my ($b_reg) = <> =~ /(\d+)/;
my ($c_reg) = <> =~ /(\d+)/;

I'm glad to see perl being still represented
>>
today I will be filtered
>>
Eric confirmed bdv is a red herring, so we have these opcodes constant for each input:

adv: decrement A to end program
jnz: flow control
bst: copy A's 3 bits into B
out: out

And these varying:

cdv: use C as a temp value allowing A to affect B with more than 3 bits - otherwise mapping 8 values would be too simple
bxl: add noise to B
bxc: add noise to B, works with cdv

Which only gives about 56 unique puzzles (8 xor values, ~7 C shifts)
>>
this happened to my buddy eric
>>
>>103556133
Assuming you only decrement A and output once per loop.

>>103555966
Yeah, that'd look better, thanks. Also get_combo could be rewritten as
return @{[0,1,2,3,$a_reg,$b_reg,$c_reg]}[$operand]

instead of this pseudo-switch, And I still have some dead/debug code here and there. Hopefully I'll have enough time on the weekends this year to get to the end of it.
>>
>>103556062
usually there are some really easy days mixed in. I think today will be an easy one.
>>
File: file.png (12 KB, 798x68)
12 KB
12 KB PNG
algorithmtards btfo'd the fuck out
>>
>>103555530
>mathlets
>>
How is there only 7 puzzles left already? Where has the month gone? Also J haven’t done any Christmas shopping at all. I’m fugged.
>>
>>103556293
>J
you are now obliged to learn the language and post some solutions in it. We've had no J posts this year.
>>
>>103556278
>eric wants me to multiply two numbers together? ah clearly this should be solved using the Karatsuba Algorithm, excuse me while i copypaste 200 lines of code
>>
time to import solution
>>
been fun lads but I have 13 hours of travel tomorrow so I'm filtering myself out now
>>
>>103554889
Imagine using Javascript and not taking advantage of eval to transpile the puzzle opcodes directly into Javascript.
>>
>>103556278
Eric acts coy about it but he knows a lot more than he lets on. Even if he doesn't know the name I'm sure he knows the algorithm and its time complexity.
>>
File: carbon(141).png (527 KB, 1932x3684)
527 KB
527 KB PNG
absolute python shitcode for the buzzer beater. couldn't fimd the right way to know when to stop the recursion. might rewrite in risc-v and wash if I have time between finals and tonights puzzle
>>
>>103556248
>return @{[0,1,2,3,$a_reg,$b_reg,$c_reg]}[$operand]
yes that's a nice idiom, but common on bro
>@{[]}[$operand]
>@
>>
>>103556405
>He cant do the solve while waiting for his flight
filtered.
>>
>>103549123
hey are you the polish tranny? if so fix the kcrypt2 code on your blog, it segfaults lmoa
>>
>>103556591
the who and the what
>>
I bet today we will use the program again.
>>
ded
>>
I kneel. For the first time in years, I am fucking filtered. I've been fucking around all day and can't make it work.
>>
>>103556819
For part 1, get all the examples to work. I had a bug where I was assigning something to the wrong register.

For part 2, write a small segment of code that measures how long the output is, and print out when the output gets longer. You should see a pattern. After that you should be able to draw the rest of the owl.
>>
>>103556819
how? print a after every step
>>
>>103549605
>he's still brooting
>>
>>103556856
>For part 1, get all the examples to work
Easy, took 10 minutes.

>For part 2, write a small segment of code that measures how long the output is, and print out when the output gets longer. You should see a pattern.

I've been trying this all day.

>>103556857
What is a step in this context?
>>
>>103556819
Run your program with A = 1. Observe output
Run your program with A = 2. Observe your output.

Repeat until you understand. Should take 64 or so repetitions.
>>
>>103549605
so he really was an LLMfag
>>
>>103557112
don't think so not everyone has a hour to spend on this everyday
if anything it just shows he doesn't take solutions from reddit
>>
>>103556897
Try checking what A gives you the last number in your sequence, then what A gives you last two numbers in your sequence.
>>
>2 minutes
LETS FUCKING GO
>>
>>103557150
Hi oofmatoes.
>>
>>103556856
>write a small segment of code that measures how long the output is, and print out when the output gets longer.
isnt this the bruteforce way?
i didnt think about the problem that long but i thought of that and realized its gonna take too long to get an answer...
>>
>>103556819
literally take out a piece of paper and pencil and think for five minutes and you will understand
>>
File: 1721308810974479.png (106 KB, 1460x605)
106 KB
106 KB PNG
>>103557185
ive been writing schizo notes for 12 hours
>>
File: carbon.png (343 KB, 1024x2810)
343 KB
343 KB PNG
The answer to part 2 is 15 digits, you can't just brute for-
>>
>babby's first problem for 17 days straight
>still everyone filtered somehow
>thread is dead
Is this the curse of not being completely retarded?
>>
>>103557198
>anon overthinks it
here's a hint.
you're not going to find a math solution where you can immediately derive all possible inputs from an output with just pen&paper.
your part 2 solution will require repeatedly checking an input against the program, and knowing what to do next based on the results.
>>
File: bruhcode1.png (17 KB, 855x87)
17 KB
17 KB PNG
REMINDER. SAVE YOUR CODE
>>
>>103557264
it won't be important
>>
>>103557209
damn nice
i thought using a GPU would be cool but i dont know how
>>
>>103557264
I would save my code anyway, but it is not that big to fear losing it anyway.
>>
>>103557198
2,4, 1,2, 7,5, 4,5, 0,3, 1,7, 5,5, 3,0


Your program ends with [code[5,5,3,0 (output B, jump 0). Your program is 16 outputs long. Therefore the loop should only run 16 times before A is zero. 0,3 is the only time A is modified. Therefore a must be 1-7 at the start of the final loop. Go from there.
>>
dijkstra today
>>
>>103557284
And yesterday, and tomorrow.
>>
>>103557284
already happened
>>
>>103557284
Dijkstra is eternal
>>
The thread being so dead so close to showtime is depressing me
>>
>>103557284
I got AoC# early access. It's DP
>>
F U C K
U C K F
C K F U
K F U C
>>
> no more krita anon drawings
why even come here every morning.
sigh
>>
>>103557283
yeah I figured all that
I'm literally just blocked at this point, too tired to think straight
maybe if I sleep it'll become obvious
either way, filtered...
>>
File: 1733294778241687.png (38 KB, 1090x498)
38 KB
38 KB PNG
>>103557316
>>
>>103557320
someone needs to compile what we got into a calendar. It will be the best one this year
>>
FUUUUCKKK I GOTTA TAKE A SHIIIIITTTTTTTT AAAAAAAAHHHHHHH
>>
any brootbros left
>>
File: showtime.jpg (46 KB, 640x480)
46 KB
46 KB JPG
https://www.youtube.com/watch?v=hjGZLnja1o8
>>
>>103557338
cancer music
>>
>>103557338
kino music
>>
>>103557331
if you can't even plan your shit for before AOC how do you even plan to solve day 18?
>>
File: 1733201676061642.png (453 KB, 1858x1829)
453 KB
453 KB PNG
>>
>>103557334
Standing back and standing by.
>>
>>103557334
they are still brooting yesterday's
>>
File: mokou-showtime.jpg (130 KB, 440x518)
130 KB
130 KB JPG
>>
>>103557338
SHOWTIME
>>
>>103557321
well you're on the right track at least. it'll come to you :3
>>
so, there's what, six people left in here?
>>
i suck at graphs
>>
it's an A* problem, I can sense it
>>
>>103557359
the #aoc channel at work is dying too :(
>>
just >>103557359 & me
>>
>>103557359
http://poal.me/hlcvv8
>>
>>103557359
all the people that matter are here except drawanon
>>
>>103557360
But do you suck at my penis?
>>
It's a grid problem again
>>
FUCK
>>
FUCK
>captcha: KKKKRM
>>
FUCK
>>
FUCK
>>
>Cnile moment
>>
it's dijkstra
>>
oh fuck it's time already
>>
GRID TRAVERSAL WOHOOO!!! THANK YOU ERIC!!!!!
>>
File: 1707506435949745.jpg (190 KB, 1280x720)
190 KB
190 KB JPG
Tonight's the night!
>>
>>103557359
i'm pretending to be 5 person at once to keep the thread alive
>>
File: corruption.png (41 KB, 603x1090)
41 KB
41 KB PNG
this is suspiciously easy to traverse
>>
>another easy day
>>
File: 1733948922993367.png (3.1 MB, 1000x3567)
3.1 MB
3.1 MB PNG
ok this one was ridiculously easy, I just copied most of my code from day 16
>>
really?
another easy day today
I thought part 2 was going to "1024 bytes have already dropped, and a new byte drops every step. what is the shortest amount of steps through the maze?" and had my dijkstra from day 16 ready to go
instead, it would've been easier to just use a flood fill
whatever

      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
18 00:11:57 1055 0 00:17:56 1008 0
>>
Holy shit, this is easy and I'm fucking it up. I am so retarded and I want to die.
>>
Easy day. Thank fuck.
>>
File: carbon.png (177 KB, 1382x1600)
177 KB
177 KB PNG
>>103557540
same
>you didn't solve it
I don't care
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
18 00:05:16 204 0 00:10:22 316 0
>>
broot started. Time to make a hot chocolate
>>
Wtf, I thought second would be optimizing the path with a new byte falling each step. This was way easy, I didn't even need to optimize it, just bfs each byte.
>>
>>103557570
wait i can change where my broot starts. binary search time
>>
Brutebros, we're so back. My brute only took a minute and I didn't even need to binary search.
>>
> fall
> falling

what the fuck eric?
>>
File: 78odc9-1037733792.jpg (40 KB, 640x604)
40 KB
40 KB JPG
today was easy? runtimes everyone? it takes me 7-8 seconds to do like 2800 bfses with no smart reuse
>>
>>103557576
How are you bruting? I bfs each step and it is only 3 seconds in node.
>>
>>103557573
>>103557556

easy day. disappointed. We already had a djikstra day and it was harder. for part 2 i just manually screwed around with the starting number to see where it was blocked and unblocked, and brooted less than 100 values
>>
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
18 00:20:54 2432 0 00:25:58 1922 0

I am retarded and first wrote a BFS and then Djikstra. Two Djikstra problems in the same year? WTF Eric?
>>
>>103557584
yeah, what was the point of that? took me a while just to understand what part 1 was asking
>>
>>103557572
yeah this seems like a real missed opportunity
shit puzzle
>>103557590
takes me less than that in clojure when I make a whole new data structure every step
>>
>>103557590
Benchmark 1: ../target/release/aoc-day18 input
Time (mean ± σ): 88.2 ms ± 2.5 ms [User: 82.7 ms, System: 4.6 ms]
Range (min … max): 84.7 ms … 91.3 ms 10 runs
>>
>>103557607
>/release/
don't tell me you're using a real language and not python?
>>
>it's brootable
Alright lads see you in a bit
>>
>>103557572
I was expecting this and it would have been way more fun than the nothing we got instead.
>>
File: UNWASHED ASS.png (261 KB, 824x2104)
261 KB
261 KB PNG
>>103557598
UNWASHED ASS POST ASS UNWASHED ASS UNWASHED POST
>>
Eric's trying to lower our guards. Tomorrow's gonna be a bloodbath. Don't get relaxed.
>>
Well, this was underwhelming.
>>
IM BROOTING
>>
>>103557625
he felt bad for the people filtered by part 2 yesterday
>>
WTF kind of day 17 was that? "Sorry for the whole intcode modulus thing BRO"??
>>
File: day18.png (118 KB, 871x1081)
118 KB
118 KB PNG
I am disappoint.
unwashed bruteforce.
>>
floodfill bros we are so back
>>
nice day 7 puzzle.
>>
File: xarbon.png (16 KB, 508x788)
16 KB
16 KB PNG
sigh. another horrible day.
misread and thought that the whole point of these shits falling per second is that you need to check the map at THAT timepoint these niggers took to get there. debugged for 20 minutes until I actually read the problem. fuck you eric.
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
18 00:26:49 3133 0 00:30:10 2379 0
>>
>>103557650
>he thought the puzzle would be interesting
well there's your problem
>>
Reading comprehension bros... I was waiting for the "bits" to shift downwards as you move through the puzzle or something. Needed clearer language, my Europoor brain can NOT parse that at 6AM.
>>
did anyone even bother to do it "properly" where you check if a thing fell on the path? Eric really needed to punish brooting more today.
>>
That's it?
>>
>>103557656
there was no brooters left alive after yesterday
>>
2ez
>>
>>103557663
I brooted today thoughbiet
>>
>>103557656
no, i just redo the bfs from scratch every time. i was prepared to run my program, see it takes too long and then think about this but nothing.
>>
>>103557656
always do brute first and estimate its time
in one second my brute had already found the shortest path for bits 1 to 1000 so I let it run
>>
this can be solved by counting down
>>
fucking off by ones
>>
wtf, why was today so easy? I thought it was going to ask me to calculate the path as they fall or be like that tornado puzzle from 2 years ago where you need to update the path as the environment changes
>>
>>103557672
Who cares, naive approach works fine.
>>
>>103557656
that's what I did, rerun Dijkstra only if something fell on the current path
>>
>>103557672
unironically would be faster than counting up
>>
>>103557672
This. I started by placing all of the walls and then removed them until I found a path. Countdown bros win again.
>>
File: file.png (535 KB, 1804x2762)
535 KB
535 KB PNG
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
18 00:12:18 1117 0 00:34:00 2735 0

i dont fucking get it, the puzzle was so easy yet i had a billion random issues on part 2
even the answer is a random off by 1 where i figured out i have to -1 the actual number i used
feels like the binary search should have just werked
>>
What the fuck was this puzzle. This was the worst one yet.
I was anticipating that part 2 would involve dynamically creating a path while the stones are falling down, and instead it was a huge disappointment.
Another fucking pointless grid search problem.
Better write a giant grid library at this point because you know the remaining problems will all be grids.
>>
>>103557672
hang yourself, but unironically
>>
>>103557684
>even the answer is a random off by 1 where i figured out i have to -1 the actual number i used
I had this, but the test case caught it easily. you ARE checking your code on the test case, right anon?
>>
>>103557692
debugging on the test one was how i figured out it was off by 1 and i just -1 instead of bothering to figure out why
>>
>>103557656
>did anyone even bother to do it "properly" where you check if a thing fell on the path?
doesn't take rerouting into account
O#...
O#...
OOOxO
#..#O
>>
>don't get random off by 1s because i'm good at coding
some people are just built different
>>
File: bqn.png (8 KB, 249x285)
8 KB
8 KB PNG
good news BQN has negative indexing
>>
>>103557692
it would've taken me longer than a minute to account for the test case and change the grid size instead of just waiting the minute to submit a second answer
>>
>>103557695
falling on the path means you have to recalculate the path, not that youve found an answer
>>
>>103557695
sure but what I mean is that if a rock doesn't fall onto your path you don't have to do any pathfinding at all. I was preparing to do this optimization, but my broot finished too quickly
>>
part 2 could be interesting if the input was about 1000000 times longer. SO a good day for a bigboi
>>
I don't even know why I bothered binary searching for part 2. I could have just brooted.

Oh well.
>>
>>103557572
>>103557677
requesting someone post their input and their answer for this part3 platinum star
(I would do it myself but I don't have a spare 150,000$ to fork over)
>>
>another grid
eric's not even trying any more. just raking in ad revenue
>>
>>103557718
yeah it would be cool to see the solutions people would have come up with. A cool way I thought of is instead of pathfinding, as you don't care how long the path is for part 2, all you have to do is try to draw a line between two sides using walls, if you can, there is no solution.
>>
idiomatic solution

import pq (Heap)

let bytes = [line.split(',').map(int) for line in slurp().lines()]

let lo = 1
let hi = #bytes

while lo <= hi {
let m = (lo + hi) / 2

let q = Heap()
q.push(1, [(0, 0)])

let seen = %{}
let blocked = %{(i, j) for [i, j] in bytes.take(m)}

let clear? = while #q != 0 {
let path, n = q.pop()
let (i, j) = path[-1]

continue if (i, j) in seen
seen << (i, j)

if (i, j) == (70, 70) {
break true
}

for (di, dj) in [(1, 0), (-1, 0), (0, 1), (0, -1)] {
let (si, sj) = (i + di, j + dj)
if si in ...70 && sj in ...70 && (si, sj) not in blocked {
q.push(n + 1, [*path, (si, sj)])
}
}
}

if clear? { lo = m + 1 }
else { hi = m - 1 }
}

print(bytes[hi])
>>
>>103557719
I did too because I'm retarded.
>>
Eric has given up. This is the last year. Start doomposting, its over.
>>
>>103557719
I binary searched by hand. probabl saved some time vs writing a for loop
>>
>llmnigger took leaderboard positions from people who actually care about AoC
seething rn.
>>
FUCK LLM USERS
>>
>>103557601
same here
>>
if part 2 wasn't trivially brootable, then the answer would just be to brooot it with a binary search instead
>>
>>103557684
guess ill fix this piece of shit later cant be bothered now
>>
>>103557663
Wherever I am, I must also broot
>>
>mathletsbtfo
>btfo by modulo math
Ironic
>>
>>103557763
>no post on socials
>skips ez llm leaderboard points days
>0 confirmed post here
if true what's his motive
>>
>here's a 2D grid
>it's completely empty by default but here are some coordinates where the walls are
>it doesn't cost anything extra to turn or for going too many spaces forward in a row or anything
>also the walls don't move or anything special just don't walk into them
>yeah just get from this static starting position to the static ending position

>part 2 is a real zinger
>this time there's a couple more walls
>how many can there be before there's no longer a path from start to end?
>but they're always added in the same order btw no need to worry about anything complicated

Day 18 tier difficulty everyone
>>
>>103557800
he's still brooting day 17
>>
One time I'm 30 minutes late and it's a completely straightforward problem that should be on days 5-10. Lmao @ my luck.
>>
>>103557808
I really thought part 2 was going to be finding the shortest path to the end if you can move 1 square before each one falls
>>
File: day18clojure.png (644 KB, 912x795)
644 KB
644 KB PNG
I love clojure
>>
>>103557808
this problem could be instantly redeemed if the walls moved, or were added as the character moves. but instead Eric just did nothing. WTF was he thinking?????
>>
alright im brooting p2, i think this is gonna take a while because my p1 was slow as fuck. I'm missing some pruning or something
>>
fuck. easy day but I psyched myself out because grid search is easy and I fucked around because I had this condition
                nscore := curr.score + 1
pscore, ok := hist[ndir]
if ok {
if pscore < nscore {
continue
}
}

the < should be <=
so I just looped around and ran out of memory.

      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
18 00:49:15 4761 0 00:53:07 4064 0
>>
Advent of Djikstra's
>>
>>103557815
>>103557820
>it's going to cause a byte to fall into your memory space once every nanosecond!
>Fortunately, you're faster
>you create a list of which bytes will fall in the order they'll land in your memory space.
why did eric specify this
>>
Maybe there was a harder version of this problem that he gave up on at the last moment?
>>
>>103557838
This feels like it was a fun problem, and playtesters whined about it so eric lobotomized it.
>>
>>103557838
kek this is what I thought as well
>>
>three (3) people got both (2) stars on today's problem in less than (<) a minute (60s (1m))
>>
>get answer to problem
>says it's wrong
???? my code looks correct and works on the smallboy, what is this edgecase that I'm not seeing
>>
File: 4582586_0.jpg (54 KB, 630x630)
54 KB
54 KB JPG
>NetworkX day 2
>try except
>>
File: 1706340663327963.png (3.18 MB, 1000x3657)
3.18 MB
3.18 MB PNG
>>103557540
>>103557607
now washed and optimized
Benchmark 1: ../target/release/aoc-day18 input
Time (mean ± σ): 8.2 ms ± 0.2 ms [User: 7.5 ms, System: 0.5 ms]
Range (min … max): 8.0 ms … 8.5 ms 10 runs
>>
>>103557838
The dynamic version has more or less the same solution, dijkstra can still be applied
think about it it's quite intuitive
>>
File: carbon.png (275 KB, 1232x1754)
275 KB
275 KB PNG
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
18 00:22:15 2615 0 00:38:08 3079 0

I didn't even need to use a grid of chars, a set would suffice, but I got kinda used to it.
>>103557815
Same, I actually wrote that for part 1 and had to redo it, hoping we'll at least have it in part 2.
>>103557853
Off by one if you're binary searching?
>>
File: img-2024-12-18-07-02-53.png (1.39 MB, 5492x5142)
1.39 MB
1.39 MB PNG
somewhat idiomatic Rust solution
>>
>>103557869
>somewhat
don't disappoint me, anon
>>
File: 24_D18_C#.png (517 KB, 2372x2270)
517 KB
517 KB PNG
Good morning sirs!

My BFS seems suspiciously slow today but I'm sure it'll give the solution sooner or-
>printed out the object ref

God Damnit!
>>
>>103557853
I'm actually going insane, someone please just give me a yes/no that the p2 answer to https://files.catbox.moe/ql8hhh.txt is 68,47 because it seems like it has to be
>>
>>103557879
no
>>
File: 1731818797945643.jpg (126 KB, 1024x683)
126 KB
126 KB JPG
>>103557884
man what the fuck did I do wrong
>>
>>103557879
no and you're not even close
>>
Ill try to take this opportunity to learn something.
I am using a python dict to do my djikstra, which is very slow. I want to switch to a heapq, but I don't know how to make a heapq with more complex data.

I have this problem frequently in AoC where I have a state of several variables, and want to sort the states by one of those variables. The most common solution is to sort by a key, can heapq be given a key in a similar way? and If not, would I just have to make my own heap structure that could do this??
>>
>>103557800
kek
>>
File: 202418.png (114 KB, 688x769)
114 KB
114 KB PNG
unwashed
bfs p1
disjoint set p2
>>
I'm copying my bfs from day 16 and it's taking forever to run.
>>
File: carbon (18).png (157 KB, 1013x1273)
157 KB
157 KB PNG
Washed python. Honestly, disappointed in today's puzzle.
>>
>>103557879
I'm getting (8, 12), line 2881 in the input.
>>
>>103557748
What is this chimera language?
>>
>>103557889
Tuples sort by the first element so just put the cost first
The heap ops don't take a key
>>
>>103557901
>spoiling the answer
>>
>>103557901
I am not inputting that until I get it myself
>>
>>103557889
the first value of a tuple in a heapq is the queue key.

so your queue might be like
q = [(0,'apple',(9,2)),(1,'banana',(6,9))]
[\code]
apple would queue before banana
you would insert by doing
heappush(q,(2,"carrot",(4,20)))
[\code]
>>
>>103557910
>>103557914
I'm sorry, I didn't read carefully enough. I regret my post. I would delete it but it's too late.
>>
>>103557909
>>103557920

>Tuples sort by the first element
ok that's good to know. does this apply to all comparisons?
>>
>>103557930
i believe if there is a tie it will compare the next elements in the tuple
>>
>>103557930
Yes, they sort lexicographically, it's just the standard comparison operator
>>
So the trick is actually not to keep checking the path from the start, but to find out when a new block makes a chain all the way from one end of the map to another?

That would have been a better challenge but the brute method does well enough here
>>
>>103557889
    class Agent:
def __init__(self, coord, dir, cost):
self.v = (coord, dir)
self.cost = cost
def __lt__(self, other):
return self.cost < other.cost

I use complex coords which do not implement comparisons so I use a wrapper like this for queues.
I don't know what you're doing today but it's not really a dijsktra day unless you're somehow getting weighted edges. Day 16 is good if you want dijkstra to actually be faster than bfs.
>>
>>103557763
It would be suspicious if he had top 100 silvers every single day but no gold on anti llm days, skipping days isn't really evidence desu
>>
>>103557884
>>103557888
>>103557901
okay I realized the error of my ways. my fucking coordinate hashmap is unsorted so it's going out of order. god damnit
>>
File: file.png (147 KB, 311x316)
147 KB
147 KB PNG
>mfw there are filtered anons in this thread RIGHT NOW
>>
File: carbon (9).png (430 KB, 2056x1918)
430 KB
430 KB PNG
So, did he switch the real day 18 with an earlier one in hope of filtering some ai fags or what is up with today's puzzle? I can't remember a day 18 being this easy or at least not tedious.
>>
>>103557947
I've been thinking , and I think the best way would be to place all walls, identify chains of walls, and remove the largest time index of the wall and see if the pathfinding works.
>>
>>103557953
Fucking finally. Christ, that should not have taken as long as it did. I don't know why I stored the second set of bytes in an unsorted data structure since the order matters.
>>
File: binary_search.png (320 KB, 625x1099)
320 KB
320 KB PNG
>>
>>103557962
I'll solve 17P2, someday
>>
File: 1719211834951325.png (467 KB, 1600x3314)
467 KB
467 KB PNG
I ended up doing a manual search of printing every 100 extra bytes because my solution was too slow. I was gonna do a binary search but I wasn't sure how to tell if it was done
>>
>>103557962
>There are filtered anons who cheated, on the leaderboard RIGHT NOW
>>
File: carbon.png (154 KB, 883x1069)
154 KB
154 KB PNG
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
18 00:18:24 2085 0 00:21:23 1412 0

Washed ass.

>>103557677
Same, I started writing code for that after badly skimming part 1. I copy/pasted my generic Dijkstra, always used neighbor weights of 1, and just slightly modified it so 'cost' was being used to keep track of step count instead of actual cost, and I could feed that into my neighbor function to determine whether walls should be considered yet etc.
Then I more carefully read part 1, realized I interpreted the problem wrong, but surely that would be part 2, right? So I set that code aside.
Then part 2 was like 3 line modifications to turn part 1 into a tiny bruteforce that finished after like 15 seconds, what the fuck.
>>
>>103557483
I think maybe the point of this was so that the djikstras took forever if you started with only a few bytes dropped down? idk
>>
I'm brooting
>>
>>103557951
I will kneel if he manages to get leaderboard position on a anti LLM question
>>
>>103558011
it does, good thing my solution was in the high quarter of bytes dropped
>>
mfw I had swapped x,y order because I always do and got gold wrong
Luckily I realized immediately.
>>
>>103558012
broot backwards
>>
>>103558031
that very quickly gives me a wrong answer
...
but I did notice that I was wasting a lot of time from only skipping the first 12 bytes before starting part2, thanks
>>103558011
I thought there might be large open spaces that could be easily removed from the input, but the final picture is a dense maze
>>
>>103558052
just manually search to get an idea of where, i.e., 1200 byte, 1300 bytes, 1400 bytes
>>
>literally just do Dijakstra again
Now that's just lazy
>>
File: 1721672393599116.jpg (263 KB, 1024x1024)
263 KB
263 KB JPG
>>
>>103557663
>>103557209
>>
>>103558029
Every single grid problem, I swap x and y and the +y and -y directions, to make parsing easier.
Every single grid problem, I fuck up a line somewhere and spend 10 minutes finding it.
I really need to just write my own AoC grid library already.
>>
>>103557209
I KNEEL
>>
>cuda
you cheated
>>
File: carbon(62).png (386 KB, 1404x1914)
386 KB
386 KB PNG
I spent a considerable amount of time with a bfs that wasn't short circuiting.
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
18 01:14:55 5815 0 01:30:11 5583 0
>>
>>103557209
do the multiplying stones using a dfs
>>
File: bqn.png (153 KB, 870x1205)
153 KB
153 KB PNG
>>103558057
this worked and I found the answer very quickly just by restarting any time it didn't almost immediately fail to find a path.
now if only I hadn't forgotten that my coordinates were reversed, for the answer

I'm very, very slowly getting less bad at this language.
>>
File: img-2024-12-18-07-43-20.png (1.1 MB, 5546x3452)
1.1 MB
1.1 MB PNG
idiomatic Rust solution
>>
>>103557209
ssh root@kubernetes.datacenter.jewgle.il
>>
>>103557838
I thought the harder problem was something like you have to path while blocks fall, new blocks will alter your path or something.
>>
>>103558154
this isn't even a big deal, its like one extra check in your djikstra. But yeah, I thought so too.
>>
>>103558031
did you count down while brooting?
>>
>>103557209
I KNEEL
>>
>>103557209
BASED
>>
anyone want to collect all of those drawfags drawings and make a calendar from them. They were really good and should be calendarized.
>>
>>103557962
do you have to solve both parts of each challenge by yourself without help or online resources to be unfiltered
>>
>>103558239
you opened the thread you are filtered
>>
calendar image: sisyphus rolling a rock up a mountain but the mountain is a maze grid. this is to represent the eternal struggle of this year's grid traversal problems, as well as topical due to the theme of today's puzzle.
>>
>So many grid problems this year
>not a single one was good (sokoban was ok)
What did Eric mean by this? Usually I am fine with the grid problems, but they are just so low effort this year.
>>
>>103558239
You need to derive the answer from first principles every single time.
>but I knew what to google to find the correct algorithm, so...
Doesn't matter. You didn't figure it out on your own, you were filtered.
>but I was taught this algorithm years ago when...
Doesn't matter. You didn't figure it out on your own, you were filtered.
>but I already knew this algorithm from last year's AoC when I...
Doesn't matter. You didn't figure it out on your own this year because you already knew it, you were filtered.
>b-but that's ridiculous
If you don't want to be filtered, don't participate. It's that simple.
>>
File: 1709557915301581.png (1.25 MB, 2054x1938)
1.25 MB
1.25 MB PNG
>another grid problem, except this time it's 3000 grid problems
Eric has given up.
>>
are all the bytes that fall 1 length or 0 length?
How do we know?
>>
>>103558277
I unironically think this is the most fun way to solve the problems.
I was burned really badly on the d16 maze when I intentionally didn't use djikstra, my solution failed, and I had to give up and use djikstra.
>>
So now that the dust has settled and we all agree that Eric is burned out, and this is likely the last AoC. What is the plan for next year? Is that anon still making puzzles or was he filtered already?
>>
File: day18.png (39 KB, 945x295)
39 KB
39 KB PNG
BQN day 18
>>
>>103558328
cute!
>>
>>103558250
Also that the maze poses no difficulty whatsoever.
>>
stupid question.
how do you find all the block related to the best path after finding the best path?
do you keep a path list on each item in your heap?
or is there a better way of reconstructing the path
>>
>Part 1 is now Part 2
>Part 2: The rocks fall once a second, in the order of the input. You can move 1 square a second. Sometimes the rocks will block your path. You can choose to either walk around the block, or destroy the rock for a time penalty. Every 10th rock is a stick of dynamite you can pick up to destroy 1 rock. Find the quickest path.
>>
File: 18.png (1.35 MB, 1704x3098)
1.35 MB
1.35 MB PNG
Probably could have gotten a pretty good time tonight had I not been asleep for the first 2 hours. Oh well. Kind of nice to have an easy day today.
>>
>>103558354
Could do something like union find starting with the left+down edges and up+right edges and then return when the sides merge
>>
>>103558363
This is the kind of problem eric would write in 2018. And then the input would have a handcrafted edge case where you have to spend 3 dynamite to gain 10 that are made to all drop in a corner.
>>
>>103557827
um akshually sweaty this was a bfs problem
>>
>>103558354
when I need to do this with djikstra, I save the "parent node" with the distance score. Then I can walk backwards from the goal to get the path.
>>
>>103558298
>a 0 length byte lands on 1,0
doesn't matter that it's not visible in the visualization, it's there. you cannot move right from the starting point, it's blocking you.
>>
File: 1715947646399573.webm (234 KB, 568x568)
234 KB
234 KB WEBM
>>
>>103558363
now THIS is a problem worth solving
>>
>>103558399
ah, so your 'history' map would be like
map[xy] = {score, parent}
then you can start at your end point and work back to start?
gona give this a go. ty
>>
>>103558412
that will be $150,000
>>
>>103558412
cute
>>
>>103558298
>zero length
>order MUST be maintained (order ended up not mattering)
Were these really the only funny edgecases this year? In previous years there was an edgecase every few days that we could meme about
>>
File: unwashed24.18.png (21 KB, 474x1276)
21 KB
21 KB PNG
Is Eric out of ideas?
>>
>>103558314
wonder if hannukka of code anons got filtered
i liked that idea
>>
File: calendarbee.png (911 KB, 1349x1024)
911 KB
911 KB PNG
>>103558344
>>
>>103558407
if the byte has no length? how does it block you?
>>
>>103558412
nice
>>
>>103558434
Holy kek this is amazing
>>
File: carbon(17).png (1.29 MB, 1818x2210)
1.29 MB
1.29 MB PNG
Haskell solution.
I did not want this to take time, so I ended up reusing my horrible dijkstra from day 16. Also not bothering to do a union-find for part 2, a bisection using part 1 does the job.
>>
>>103558428
sure saar,
pls give me bank info,
you will get redeemed 150,000
>>
LLMniggers.... we are so back
>>
>>103558447
>Also not bothering to do a union-find for part 2, a bisection using part 1 does the job.
I just brooted and am a brainlet that has no idea what you are talking about. How does a union find help in part 2? What two sets are even disjoint in this problem
>>
>>103558434
lmao
>>
>>103558471
You could start from the end state, then go back in time removing rocks one at a time and maybe connecting the chunks. Once start and end are in the same connected component you're done. I believe this is more efficient than bisecting, depending on the ratio bytes / grid size
>>
>>103558434
Literally me manually solving day 17 part 2
>>
import { readFileSync } from "fs";
import { createMatrix } from "../../utils.js";

const input = readFileSync("./input", "utf-8").trim();

/** @param {string} input */
function parseInput(input) {
return input.split("\n").map((line) => line.split(",").map(Number));
}

/** @param {number[][]} input */
function part1(input) {
const map = createMatrix(71, 71, 0);
for (let i = 0; i < 1024; i++) {
const [x, y] = input[i];
map[y][x] = -1;
}
let queue = [[0, 0, 0]];
while (queue.length) {
const newQueue = [];
for (const [x, y, steps] of queue) {
if (x < 0 || x > 70 || y < 0 || y > 70 || map[y][x]) {
continue;
}
if (x === 70 && y === 70) {
return steps;
}
map[y][x] = steps;
newQueue.push([x + 1, y, steps + 1]);
newQueue.push([x - 1, y, steps + 1]);
newQueue.push([x, y + 1, steps + 1]);
newQueue.push([x, y - 1, steps + 1]);
}
queue = newQueue;
}
return "No path found";
}

/** @param {number[][]} input */
function part2(input) {
const map = createMatrix(71, 71, 0);
outer: for (let i = 0; i < input.length; i++) {
const [x, y] = input[i];
map[y][x] = -1;
let queue = [[0, 0]];
while (queue.length) {
const newQueue = [];
for (const [x, y] of queue) {
if (
x < 0 ||
x > 70 ||
y < 0 ||
y > 70 ||
map[y][x] === -1 ||
map[y][x] === i + 1
) {
continue;
}
if (x === 70 && y === 70) {
continue outer;
}
map[y][x] = i + 1;
newQueue.push([x + 1, y]);
newQueue.push([x - 1, y]);
newQueue.push([x, y + 1]);
newQueue.push([x, y - 1]);
}
queue = newQueue;
}
return `${x},${y}`;
}
return "No block found";
}

console.log(part1(parseInput(input)));
console.log(part2(parseInput(input)));
>>
BFS is just too good. It's fast, simple, and clean. I would probably still use it on a big boy, It's not brooting, it is just the optimal algorithm. BFS can't be beat!
>>
>>103558363
I was expecting part 2 to be the bytes moving down the memory space with new bytes waterfalling in from the top and you have to plot a course that gets you to the end before the last byte enters, while avoiding the falling bytes.
>>
>>103558506
I should start writing a library with common algorithms like bfs or dijkstra.
>>
File: day18.png (352 KB, 1710x2736)
352 KB
352 KB PNG
$ mix run -e 'AOC.main()' -- 2024 18 b input/real
372
25,6

Ran in 353.304ms


Did binary search because brooting was taking a while and I didn't want to bother with union-find. Spent five minutes trying to figure out why part 2 was wrong and then realized I had tuple brackets around the coordinates.

>>103557815
That's exactly what I thought it'd be.
>>103558412
Neat!
>>
>>103558471
Initially
>set 1
the top and right edges
>set 2
the bottom and left edges
Points added based on Moore neighborhood.
Once the two initial sets merge, the path is cut off.
>>
>>103558496
Oh I get it now. That was basically my thoughts on the optimal solution, I just didn't know the graph theory terms.

bisecting is efficient enough that it is impossible to get people to do anything interesting with today's problem. The puzzle is flawed and Eric should feel bad.
>>
>>103558496
interesting idea
so you start after all rocks were added and maintain a set of points visitable from the start location, then each time you remove a rock, floodfill from there if it is connected to the your set of visitable points? and you can ignore anything thats already visitable
>>
File: day18_fast.png (212 KB, 871x1807)
212 KB
212 KB PNG
okay, I am ready for the bigboy.

takes 0.5 ms for the normal input.
>>
>>103558412
That's pretty cool, good job.
it's too bad today was so brootable it wasn't even remotely necessary to recalculate the path only when a wall landed on it (and even then a basic bitch binary search is more efficient).
Maybe if the walls were toggles and could be re-opened if the same coordinate came up? Throw some keys in there like that absolute nightmare of a puzzle from 2019/18 or something, hell I don't know.
>>
>>103558552
the bigboy anon got filtered already
>>
>>103558542
No need to flood fill - Union find structure takes care of the connected components stuff for you. But also as
>>103558516
said, an equivalent (and probably simpler) way to proceed is to do union-find on the blocking bytes, Its dual and easier since you don't have to do the initial setup of building the union find of free bytes.
>>
>>103558471
check my implementation in part 2
>>103557892
You don't need to floodfill to check if the start and the end are connected, checking connection is effectively an O(1) solution. this is one of the advantages of disjoint sets
>>
>>103558565
A lot of the recent problems aren't even worth bigboying. d17 can't really be bigboyed. I guess d15 could be, but the size of the grid is irrelevant, and the runtime will be linear with number of moves, so that is boring as well. d14 difficulty doesnt scale with input size. d13 is mathematically solved

So for the past 6 days, only d16 and today even matter for bigboys.
>>
>>103558564
>maze with keys from 2018/19
they just don't make grid puzzles like they used to
>>
File: carbon.png (730 KB, 1682x3280)
730 KB
730 KB PNG
>>103558552
I thought about using union-find but I didn't want to mess around with keeping track of connected sides. My bfs with binary search does my input in 300µs so I think I'll leave it at that. 100µs of that is string parsing, oof.
>>
>>103558672
>doing a manual binary search
>>
Based on how the story started I thought this was gonna be a redux of the drop 100000000000 tetris pieces puzzle, but no
>>
>>103558704
that one was difficult to keep all the numbers in check
where the cycle starts, where it ends, how tall a cycle is, how many pieces are left over after the last cycle before 1000...0000, how much that would increase the height by, how tall it was at the start, how tall all the cycles in the middle end up being
and putting it all together for the final math equation
>>
>>103558704
ha same. With the 'in this case we only drop 22' I thought we would need to build a height map
>>
The blizzard version of this problem from a few years ago was much more fun.
>>
>>103558601
>>103558565

if you want i have collected all the bigboys
https://github.com/Error916/Aoc2024
>>
> Only 6.62% of those who did d1p1 did d17p2
The filter is ... strong
>>
>>103558757
>filter
I can solve everything but I wont because the shit eric crap out is boring as fuck minus day 14
>>
>>103558771
You are ... filtered
>>
Do people just give up after not solving a day? I imagine today will have less gold stars than yesterday despite today being a trivial problem.
>>
>>103558757
how did you get 6%? or you talking about the /aocg/ boards?
8593/( 226257 + 16268) = 0.035
>>
>>103558778
day 13 gold stars > day 12 gold stars.
so I guess not.
>>
>>103558771
Filtrado
>>
>>103558780
I am talking about day 17, it is too early to talk about day 18.
>>
>>103558796
ah my bad. sorry.
>>
>>103558771
The filter was strong on this one.
>>
I've hit something of a wall.
After completing day 9 for GBA, I'm just not getting excited about day 10.
>>
>>103558802
>Not wanting to slurp up slop means you're filtered
Shut the fuck up I'm not the only one complaining about it
>>
5000 by 5000 bigboy
https://files.catbox.moe/u9xm63.7z
day18 result:(9998, 320431)
>>
>>103558776
>>103558793
>>103558802
Eric cock suckers
>>
>>103558885
>>103558892
Happens every year. Filtered and sour.
>>
File: 1715740893612525.png (426 KB, 1472x2500)
426 KB
426 KB PNG
Swift.
Wrote it again, instead of copying day 16 to practice pathfinding. Always have troubles with it for no reason.
>>
>>103558888
ahh, shit it's all wrong... i added the random dots before the maze...
>>
>>103558888
I guess you mean 5000x5000 grid, with end at 4999,4999. Don't know why your part 2 answer looks like that though.
Star one: 9998
Star two: 4054,101

Benchmark 1: ./target/release/_2024
Time (mean ± σ): 5.786 s ± 0.046 s [User: 5.637 s, System: 0.051 s]
Range (min … max): 5.733 s … 5.891 s 10 runs

With bfs >>103558672
>>
>>103558277
My most satisfying AOC moment was solving the bus timetable problem from 2020 on a piece of paper without knowing any of the maths, then seeing the immense seethe online - people claiming it was only solvable if you knew some niche Chinese algorithm.
>>
thank you Eric for free stars after rough last 2 days
>>
>>103558936
>people claiming it was only solvable if you knew some niche Chinese algorithm
eric doesn't even know the CRT, lol. what a cope
>>
>>103558906
I'm right you fucking nigger Eric is the one who got filtered for being unable to deliver quality questions
>>
>>103558972
>I willingly joined a competition that gets harder over time
>but I'm going to stop competing now, over two thirds of the way through, because uh I got bored
>yeah, it's just too easy, it's not interesting anymore, I'm not gonna bother doing the last quarter because of how easy it is
>make sure not to disqualify me, I clearly didn't fail after all
>I just chose not to solve the problem
>in the competition I willingly joined
>and that's why I'm still eligible to compete and not filtered
>>
>>103559001
Alright I'll fucking do day 18 fuck you
>>
>>103559019
too late you opened the thread hence you are now filtered
>>
>>103559019
based
>>
>>103558888
woops that p2 is supposed to be
(3163, 4131)

seems the bigboy input is correct, I was just confused.
>>103558931
are you sure about the 101 in star two? maybe your grid is limited? my first blockage occurs at index 12971005
>>
>>103558931
okay so it's off by one for one of us, since 4054,101 is at index 12971006
>>
>>103559101
I DID DFS ON A DIJKSTRA'S DAY AND TODAY I DID DIJKSTRA'S ON A FLOOD FILL DAY
I AM GOING TO FUCKING KILL MYSELF
>>
ignore the reply, i just clicked on the first post and forgot to delete it
>>
>>103559155
Why did you reply to me with a irrelevant message I don't understand
>>
this anonymous guy sure posts a lot
>>
File: day18.png (45 KB, 870x397)
45 KB
45 KB PNG
>>103558328
cleaned up a bit
>>
>>103559101
For me, the end is reachable at index 12971005.
[/code]
block 12971005 Coord(3163, 4131) length: Some(959050)
block 12971006 Coord(4054, 101) length: None
[/code]
>>
File: xarbon.png (24 KB, 604x996)
24 KB
24 KB PNG
washed code
utilizing dsu-chan for part 2
>>
File: Day18.png (119 KB, 941x1285)
119 KB
119 KB PNG
C#, simple binary search.
>>
>>103559189
you take i blocks for "best_path" and then the result is blocks[i] which is the i+1-th block, right?
>>
>>103559194
bigboy performance
$ ./main < bigboy.txt
+ ulimit -s unlimited
+ pypy main.py
+ tee /dev/fd/63
++ tail -n 1
++ xclip -sel clip
9998 3163,4131

real 2m2,653s
user 2m0,201s
sys 0m2,412s
>>
>>103559290
>2m
lol
>>
>>103559295
It's python (not rustshit) and my dsu implementation is logarithmic for the sake of simplicity
>>
only 1 week until Christmas
>>
File: 17_v2.png (337 KB, 736x548)
337 KB
337 KB PNG
>>103559388
alternative to day 17
or I can put the cat pic inside the demotivator
>>
>>103559238
Star one: 9998
Star two: 3163,4131

Took me a while to debug, but damn, you're right, I was taking all blocks below i. But I also messed up the binary search by returning i itself instead of the lower bound. Surprised it didn't matter for the regular input.
>>
File: aoc24_18.png (275 KB, 718x1987)
275 KB
275 KB PNG
Odin
Sure wish there was an int.max constant that doesn't require me importing C interop stuff
>>
>>103559460
>Sure wish there was an int.max constant that doesn't require me importing C interop stuff
-1 >> 1?
>>
Part 1
data = open("Day 18 input.txt", "r").read().strip().split("\n")

size = 70

grid = set()
for i in range(1024):
grid.add(tuple(map(int, data[i].split(","))))

dirs = [[1,0],[0,1],[-1,0],[0,-1]]

queue = [[(0,0), 0]]
visited = set()
while True:
pos, cost = queue.pop(0)
if pos in visited: continue
visited.add(pos)
if pos == (size, size): break
for d in dirs:
if 0 <= pos[0] <= size and 0 <= pos[1] <= size and (pos[0]+d[0],pos[1]+d[1]) not in grid:
queue.append([(pos[0]+d[0],pos[1]+d[1]), cost+1])

print cost

Part 2
data = open("Day 18 input.txt", "r").read().strip().split("\n")

size = 70

grid = set()
dirs = [[1,0],[0,1],[-1,0],[0,-1]]

for num, i in enumerate(data):
print num
grid.add(tuple(map(int, i.split(","))))
queue = [[(0,0), 0]]
visited = set()
while len(queue):
pos, cost = queue.pop(0)
if pos in visited: continue
visited.add(pos)
if pos == (size, size): break
for d in dirs:
if 0 <= pos[0] <= size and 0 <= pos[1] <= size and (pos[0]+d[0],pos[1]+d[1]) not in grid:
queue.append([(pos[0]+d[0],pos[1]+d[1]), cost+1])
else:
print i
break

Easy BFS, not even using a proper deque brute force was still fast enough.
Can't remember the last time I used an else statement on a while loop, if ever.
>>
File: aoc 2024 day 18 excel.png (351 KB, 2120x1748)
351 KB
351 KB PNG
Solved in Excel. No VBA.

It's mostly just a flood fill that tracks distances. Formulas color coded again.
Column A is my input directly copy+pasted. Blue is simple input parsing to separate by comma.
The first grid (red) initializes the maze by placing walls where specified, based on the requested amount in "qty. blocks". Checks if there exists a line in the input where both coordinates match, and returns a "#" if so, or a "." otherwise. Top left is hardcoded as 0, since the start is always in the top left with a distance of 0.
Every grid after that (green) updates the distances by 1. The formula shown in the pic is for coordinate 1,1 in the grid with distance 9 specifically. The two big grids underneath the formula are the full mazes for grids 1 and 2. These grids are the bulk of the spreadsheet, they calculate distances incrementally up to 3136 (accidentally did way overkill, since the highest distance to get to the end was 560). For each cell, if this cell isn't a wall and doesn't already have a distance, check the adjacent cells in the previous grid. If at least one of them is a number, get the minimum of the four adjacents, add 1, and make this cell equal to that distance.
Part 1 is just setting the qty to 1024 and getting the final distance.
Part 2 is a manual search, edit qty until you find the first value that returns a "." instead of a number, then get the associated coordinate (dark blue).
>>
File: code.png (475 KB, 1792x3188)
475 KB
475 KB PNG
Python

Feels like a rest day
>>
>>103559640
Excel strong this year.
>>
File: file.png (343 KB, 1556x1774)
343 KB
343 KB PNG
>>103557684
zzz i washed and redid part b and it works instantly with no trouble at all
why was it so painful earlier
>>
>>103559640
holy excelchad.
nice
>>
New thread:
>>103559822
>>103559822
>>103559822
>>
holy fuck. I just figured out how to do part2 with just 1 dfs. erics input is flawed.
# single dfs
def part2(coords: list[tuple[int, int]]):
maze_done = next(
i for i, (x, y) in enumerate(coords) if x % 2 == 0 and y % 2 == 0) - 1

blocked = {*coords[:maze_done]}

curr = deque([(0, 0)])
visited = {(0, 0)}
preds = {}
while curr:
(x, y) = curr.popleft()
for dx, dy in (-1, 0), (0, 1), (1, 0), (0, -1):
nx, ny = x + dx, y + dy
if 0 <= nx < 71 and 0 <= ny < 71:
if (nx, ny) not in visited and (nx, ny) not in blocked:
curr.append((nx, ny))
visited.add((nx, ny))
preds[(nx, ny)] = (x, y)

path = []
p = (70, 70)
while p in preds:
p = preds[p]
path.append(p)

return next((x, y) for (x, y) in coords if (x, y) in path)
>>
>>103559838
Is there only a single block that blocks a path to the end?
>>
>>103559838
explain!
>>
File: corruption.gif (316 KB, 710x710)
316 KB
316 KB GIF
C++, 50ms.
>>
just opened the problem
would be cool if we had to run at the same time when memory is falling from the sky
>>
>>103557902
https://based.lol/
>>
>>103559925
the trick is to count down
>>
>>103554667
I need her to tell me that with a smug, humiliating me for being filtered by such a silly riddle.
>>
>>103561018
based. solved it the same way.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.