[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] [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: diet aoc.png (146 KB, 707x707)
146 KB
146 KB PNG
>Everybody Codes is a free space for honing your coding skills, experimenting with ideas, and learning from others. At its heart lies the belief that programming is best when shared - whether through solving puzzles, streaming your progress, or discussing solutions.
https://everybody.codes

Similar to Advent of Code but in November. Puzzles drop at 4PM EST with weekends off

>oh no I started late
Can sort leaderboards by "local time" which doesn't start the clock until you open the puzzle. Not used for global ranking but still fun to be able to compare how you did

/g/derboard code
4151e976-7b9f-4fda-bb33-fa7c70fdceea

Last: >>107169473
>>
File: 9.png (1.85 MB, 1024x1024)
1.85 MB
1.85 MB PNG
Day 9 sucked. Maybe I'm too smoothed brained for good code, but cubed loops to check if any pair of dna can form another dna was all I could come up with. But it worked. #unfiltered
>>
>>107208479
What's wrong with nested loops?
>>
>>107208479
if O(n^3)GODs were meant to be filtered he would've increased the input set :^)
>>
File: 1750347499175627.png (527 KB, 1666x8516)
527 KB
527 KB PNG
>>107208479
Check my solution out it's the most readable one by far
>>
>>107208541
No, but really. What's wrong with nested loops? This is the kind of reasoning that the Ordo meme leads to, where people genuinely believe that an algorithm gets better or worse based on purely superficial attributes like where you set your function boundaries. Like:
>My algorithm is better because it is O(n) whilst yours is O(n^2)
>But your algorithm works on a value, and mine works on an array of values, so you need to call your algo n times but I only call mine once
>Yeah, but mine is O(n)
It's the same kind of thinking that gave us the Clean Code slop where functions were supposed to be shorter than short in order to be "readable", and the only thing that happened was that what could have been one long function was suddenly split up into 10 short functions that did nothing on their own, and required each other, so suddenly you have the same code but spread out over multiple functions (perhaps multiple files), and they all call each other.

Time complexity is a meme. The only thing that matters is if your code meets the real life requirements, not how it grows with hypothetical and unrealistic data.
>>
>>107208509
nothing its just tricky for me.
>>107208541
true story! we live to duck another day
>>107208629
oh cool thanks. ya this is pretty readable javascripts nice.
>>
File: d-9.png (236 KB, 902x1717)
236 KB
236 KB PNG
>>107208728
mine. unwashed python. gomen /g/
>>
>>107208746
i nod my head to a fellow // part1,2,3 commenter
>>
>>107208746
rewrite it in Rust. Memory safety is important yknow
>>
>>107208659
This might be correct in theory, but never happens in practice. Link me a single EC/AoC solution pair where Anon1's O^3 algorithm runs father than Anon2's O^2 algorithm?
>>
File: p33587_v_h10_aa.jpg (216 KB, 1280x720)
216 KB
216 KB JPG
>>107208777
1 file. 1 repl. do we need more?
>>107208788
Memory corruption has never stopped Berrymore!
>>
last problem before the weekend break, get ready for a huge filter
>>
>>107208822
That's not my point. My point is that something being Ordo whatever doesn't tell you anything if you don't include the actual context itself, i.e. the problem you are trying to solve. But the whole Ordo meme has caused people to view e.g. O(n^3) as inherently bad even if the necessary data transformation do take O(n^3) time. People see Ordo whatever and based on that stop their thinking and instead either sort it as good or bad without considering the actual real life requirements (which would require actual domain knowledge).
And it has lead to people fearing nested loops, so what do they do? They extract the nesting into different funcitons, so now instead of a nested loop you have one loop in which you call a function, and everytime you run the function you call another loop. So the nesting doesn't disappear, they've just hidden it, but believe themselves to be more efficient because "O(n)".
The same argument applies to the so called "never nesters" who instead extract everything into different functions so that the code is instead spread out more, and in worse case in different files.
>>
>>107208996
As an example of this. Either at the beginning of Everybody codes or just before it someone posted a leetcode easy problem where you were supposed to check if a single linked list was a palindrome, and it was supposed to be solved in space complexity O(1). All fine and well, only the problem was that the O(1) solution required modification of said list, and since the question was to determine if the list was a palindrome and not to modify it, you are therefore most likely going to do some work on said list depending on if it is a palindrome or not meaning you need it back in its original state. We can therefore guess that we are working with a copy of the list, not the original list itself. So the whole "space complexity O(1)" requirement is destroyed by the question itself, because when you are working with a copy you are already in O(n) space complexity when viewed from a program perspective and not a function perspective.
So the question makes absolutely zero sense. But you wouldn't get that if you're a believer in the Ordo meme.
>>
i'm scared
>>
second day in a row where i almost completely forgot about this shit until five minutes before puzzle drop. does not bode well for my chances of remembering on monday
>>
5 MINUTES
>>
ONE TWO SEVEN THREE
>>
File: wf.jpg (133 KB, 1291x965)
133 KB
133 KB JPG
LET ME SEE YOUR WAR FACE FA/g/GOTS
>>
>>107209282
>original nightcore anon died years ago
RIP
>>
>>107209079
Counter Example: n + 1 problem. It’s a simple problem with a simple solution. Essentially every time you do a database lookup depending on your database structure you might have to do an additional query depending on data required from the first. You can solve this with a hashtable or with caching or restructuring your data. But the point is it’s a real issue that real programmers take into account because of page speed. Doing things fast and efficiently isn’t a meme until we hit quantum computing and infinite data storage.
>>
File: 1737762186333475.png (291 KB, 512x512)
291 KB
291 KB PNG
>>107209284
>>
What’s your duck solving music?
>>
File: robert.png (161 KB, 305x278)
161 KB
161 KB PNG
>>107209284
i'm ready to be filtered
>>
>>107209301
Silence (+ the sounds of my fans whirring when I start to broot)
>>
File: PqgJC0F.jpg (105 KB, 600x800)
105 KB
105 KB JPG
>>107209284
>>
>chess board

fuck off, im tired
>>
>chess
welp
>>
i just dont know if i can be bothered to be honest
>>
>sheep is both singular and plural
how am I supposed to name my variables then
>>
>works on the test
>not on my input (yes I remembered to increase the turn limit)
JUST FUCK MY SHIT UP SENPAI
>>
>>107209473
i used "sheeps" for a variable, idgaf
>>
>>107209473
>sheeps
>>
you guys remember that AoC problem where you had to simulate an entire goblin RPG?
>>
>>107209486
ah fug i had a typo that somehow didn't matter for the test
>>
>>107209293
I've never said that things shouldn't be fast and efficient, in fact I agree that it should. I believe that software should consume as little power, memory, time and money for the customer as is possible (within reason) and that the whole "premature optimization is bad actually" meme is just as harmful or even more harmful because at least the Ordo meme at least gets people talking about efficiency. My argument is that you can't look at the time or space complexity of an algo and believe that it says anything. Everything depends on the context.
>>
>>107209506
Goblins vs elves, day 15 in 2018? Yeah, I remember.
>>
File: 1751446483243120.jpg (51 KB, 550x502)
51 KB
51 KB JPG
solved part1 in 30 minutes, why is part2 like 5x harder from the first sentence?
>>
Not opening until tomorrow. I'm too tired...
>>
>just write a chess engine bro
isnt this supposed to be fun?
>>
>The last example has as many as 13033988838 unique sequences when all the sheep are eaten.
oh joy
>>
>>107209506
yeah that's the day i quit that year lel
>>
>>107209506
One of the best days.
>>
man fuck this, not even a hard problem but tedious as hell to debug with counting squares to see if they match the example
>>
something about this is fucked. I don't understand the dragons are eating the sheep before and after they move? do the sheep continue to be alive after they're eating wtf
>>
ohhh the fucking sheep get 2 moves for every 1 dragon move?? wtf
>>
>the sheep walk into the dragon to get eaten
what is this retarded sheep
>>
>>107209709
Yeah, fuck, I don't know where to even begin solving part 3.
>>
File: tired.jpg (6 KB, 209x250)
6 KB
6 KB JPG
What the hell is part3 ?
>>
>>107209994
>>107210019
>>107210026
dragons and sheep alternate moves

so a living sheep moves, if it runs into the dragon it dies.

then it's the dragon's turn. if the dragon moved onto the sheep with its turn, the sheep dies
>>
>my part 2 has been running for 2 minutes now
goddam i bet part 3 is gonna be a bitch
>>
File: 1739289410300375.gif (1.73 MB, 200x293)
1.73 MB
1.73 MB GIF
>>
File: file.png (220 KB, 636x2487)
220 KB
220 KB PNG
Some kind of combinatorics? Fuck me idk
>>
wew
guess I'll do part 3 tomorrow
>>
>>107210206
lmao i'm still on part 2 and this has me fairly confident that i'm filtered
>>
you know it's bussin when people have to share screenshots of part 3
>>
>works on test but not input
>answer has correct length and first number
just kill me
>>
how long is part 2 supposed to take?
my code has been running for 2 minutes...
>>
>The last example has as many as 13033988838 unique sequences when all the sheep are eaten.
uh brute force bros???
>>
File: EC-10.png (253 KB, 1075x2117)
253 KB
253 KB PNG
Holy fuck that was a pain to debug. Now I can sleep.
>>
>2 hours in
>44 solves
Absolutely brutal.
>>
FINALLY SOLVED
>TIME IT TOOK TO UNDERSTAND THE INSTRUCTIONS
1 HOUR
>TIME IT TOOK TO REMOVE ALL THE EDGE CASES BECAUSE I DIDN'T READ THE INSTRUCTIONS PROPERLY
1 MORE HOUR
>TIME IT TOOK TO IMPLEMENT THE DP
5 MINUTES
>>
I HATE MEMOISATION
I HATE MEMOISATION
>>
huh
is this fun
are you lads having fun
should i be wasting my time trying to solve things as well in the pursuit of fun
>>
>>107210436
only 20 more solves since
where did all the activity go?
did you guys all give up?
>>
File: carbon.png (1.03 MB, 1956x4498)
1.03 MB
1.03 MB PNG
Man, at this rate I'll really get filtered
>>
>finished part 3
>3:46 am
>remember I don't have a life

Phew
>>
>>107210685
No I'm not fucking having fun! But I'm unemployed and I have to work on something or I'll go insane
>>
>>107210685
honestly i only enjoy these competitions when they're easy enough for me to finish in an hour. beyond that and i get burnt out quickly
>>
>>107210685
honestly i only enjoy these competitions when they're hard enough for me to finish in over an hour. less than that and i get bored quickly
>>
>If at least one sheep can make a move (including escaping when it is on the lowest row of the chessboard), then a move by the sheep must be made. Otherwise, the sheep's turn is completely skipped and the dragon takes the turn again.
this rule sucks. how are you supposed to dp when the sheep can stay in the same spot forever and the dragon can't get it.
>>
>>107212096
>when the sheep can stay in the same spot forever
I don't think that's true though. my understanding of the rule is that if there is only one sheep left and moving forward would make the sheep hit the dragon, then skip a turn. if there's more than one sheep alive, then one of them an always make a non-suicide move so you wouldn't skip
>>
>>107212096
Because the dragon will move and then the sheep move when it's out of the way.
>>
File: d10.png (2.93 MB, 902x2015)
2.93 MB
2.93 MB PNG
I'm clocked in! Have a good weekend boys! Thanks for the memes.
@cached (tuple(sorted(set(sheep))))
>>
>>107212211
>>107212202
Ohh thanks!
>>107210169
Also thanks for this! I didn't realize sheep could get eaten on both their own turn and on the dragons.
>>
>>107212225
>caves
sovl
>>
>getting confused by my list of tuples of tuples of tuples
something tells me i'm in too deep
>>
File: day10.png (2.07 MB, 1024x1024)
2.07 MB
2.07 MB PNG
>>107212270
:D
>>107212309
You can never be too dee
RecursionError: maximum recursion depth exceeded
>>
Was this the great filter? No one is gonna be left by next week.
>>
File: JUST.jpg (6 KB, 204x247)
6 KB
6 KB JPG
>>107212397
>maximum recursion depth exceeded
>>
>>107212469
surprised it took this long desu, 2024's got harder much faster
>>
File: 10.png (1.79 MB, 3016x8072)
1.79 MB
1.79 MB PNG
>>
File: carbon.png (521 KB, 1024x2673)
521 KB
521 KB PNG
After much turd polishing
Holy fuck that was a pain in the balls to debug
>>
>The last example has as many as 13033988838 unique sequences when all the sheep are eaten.

yeah i'm filtered, i know it's dynamic programming but i can't be bothered
>>
can sheep swap columns if it's unoccupied?
>>
>>107213920
No, they only move down.
>>
I haven't had time to look at the puzzle yet, but from the looks of it this seems to be a good day
>>
>>107214132
nobody tell him
>>
>>107213920
what kind of stupid question is that? of course not, do you think they're gonna start moving like a bishop? are you schizophrenic? the author celery states they only go down
>>
>>107214132
The hardest so far baa none.
>>
> cargo test --release -- --test-threads=1 --report-time -Z unstable-options events::_2025::_10::tests::inputs
Finished `release` profile [optimized] target(s) in 0.01s
Running unittests src\lib.rs (target\release\deps\everybody_codes-65659e1d34dccbdd.exe)

running 3 tests
test events::_2025::_10::tests::inputs::_1 ... ok <0.000s>
test events::_2025::_10::tests::inputs::_2 ... ok <0.000s>
test events::_2025::_10::tests::inputs::_3 ... ok <0.241s>

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 167 filtered out; finished in 0.24s
>>
>>107213920
If the dragon moved twice on the previous turn they can en passant
>>
>>107214582
holy hell
>>
>>107214582
hahahaha
>>
Someone, somewhere wrote a bruteforce BFS for part 3 and just decided to leave it running overnight
>>
>>107214849
I wonder if they will keep it running all weekend on the misguided hope they'll get the answer?
>>
File: ec2025-10.png (498 KB, 604x3660)
498 KB
498 KB PNG
I should clean this up more but I don't want to
>>
>>107208342
I HECKING LOVE DP ON BITS
jokes aside, it's not even that hard, but it's like the 3rd or 4rd time the intended solution was like that
>>
>>107214132
Won't lie, it wasn't trivial. But it wasn't that hard either. Just a little bit tricky because approach always had a problem with it until I solved it, but there was always a step forward to take. Was never stumped.

Also, lol at those who tried a recursive approach and got maximum recursion depth exceeded.
>>
>>107216146
Time so far is far too slow for my liking, but I won't bother washing my code unless someone creates a bigboy.
Part 1: 155

Part 2: 1770

Part 3: 159037034676109


real 0m6,520s
user 0m6,389s
sys 0m0,025s
>>
>>107216169
My local time got fucked as well because my wife wanted to go out with me in the nature so I wasted a few hours.
Bah, don't care about time anyway, just a bit miffed that I should have ranked much higher had I actually had the ability to sit down and consentrate.
>>
File: 6atk1gxsck311.png (1.01 MB, 957x879)
1.01 MB
1.01 MB PNG
>>107216188
My local time got fucked as well becaues the super model programming cheerleaders asked me back to their place and I was up all night. Really tired orgying all night. Bah, don't care about time anyway, just a bit miffed that I should have ranked much higher had I actually had the ability to sit down and consentrate.
>>
>>107216365
Success breeds jealousy. I'll make it better for you, she's also a programmer, but very feminine and is thinking of becoming a housewife instead.
>>
>>107216401
its hard to be jealous of someone who's program took 6520 seconds to run kek
>>
>>107216518
6.5 seconds, mate. not 6500 seconds.
>>
>>107216518
retard
>>
>>107216822
>>107216544
bonjouno euro peens. hows the dp today?
>>
>>107216518
g*rman detected
>>
File: ec_day10.rs.png (942 KB, 868x3817)
942 KB
942 KB PNG
Tapping out at 150ms. Biggest boost is switching to u8 and letting movzx convert each time.
>>
>Only 174 people so far have completed part 3
>12 of them are on the /g/ leaderboard
This thread alone makes up nearly 7% of the people still in the running.
>>
>>107218543
We're all going to get jobs at Jane Street, boys.
>>
>>107218543
Well, I have two accounts only one of them on /g/. So we are possibly more than 7% if others have done the same.
>>107218575
>boys
I've seen some javascript so there's at least one woman here.
>>
File: break.png (2.92 MB, 1024x1536)
2.92 MB
2.92 MB PNG
Weekend bump! Next week predictions? Maybe some heap stuff? Does this duck guy do math? I bet linked list anon is sweating hard right now.
>>
>>107218802
you joke but a qt canadian girl is the second best coder on the whole site right now.

https://everybody.codes/event/2025/leaderboards/points/ranking/everybody/total
>>
>>107208342
I keep forgetting this is a thing, kek. are they hard yet or nah?
>>
>>107218918
I think they're harder than the average non dsa dev can solve. They're about on par with like AOC week 3ish now maybe?
>>
>>107218959
kk, I'll try and catch up by tomorrow. thanks.
>>
>2024 day 15 part 3
>description implies you need to solve it using a quirk of the input or else you'll be waiting for decades
>really don't want to
>optimize code from part 2 and add pruning
>wait an hour
>get the correct answer
brooters never lose
>>
>>107218911
Sorry, trannies aren't women, and never will be.
>>
if you didn't solve day 10 by now you are filtered
>b-but the next puzzle isn't open yet, I get three days on fridays
nope. filtered
>b-but
FILTERED
>>
>wilt
filtered
>temp
filtered
>368053
filtered
>726995
filtered
>hunter2
filtered
>Commander Kotori
filtered
>TMF
definitively filtered
>tad
Didn't even reach the filter
>adventcoder
Should go back to /r/etardedFaggots on plebbit. Filtered!
>noManInDraculasCastle
Died from a stroke last week.
>nitsu
filtered
>z3sty
unemployable, and filtered
>H3mingway
filtered

All of you, get off the /g/derboard. You have no right to be here.
>>
>>107219438
You're doing the Lord's work anon. These fools thought they could escape the filter. I hope you're filter-anon from AoC too.
>>
>>107219438
if they are all filtered there's no one left
>>107219041
>Sorry, trannies aren't women, and never will be.
how can you tell? rust?
>>
I gave up
>>
>>107220139
Why?
>>
weekend breaks killed this thread
>>
>>107221753
yaaa aoc 20 days in a row is a much better design. breaks are for chumps
>>
so the 1-25 pure kino is dead and now we have two replacements:
1-12 (Dec)
and 3-7, 10-14, 17-21, 24-28 (Nov)
worst timeline
>>
>>107222454
>>107222431
oh damn I just checked. only 12 days now. that sucks.
>>
File: quest1.png (103 KB, 1168x1011)
103 KB
103 KB PNG
quest 1, late
>>
>>107222785
most readable rust code itt
>>
There's something about the feeling of spending hours on one of these problems, constantly debugging and not knowing why your output doesn't match up against the example's, rewriting giant chunks because maybe it'll just work this time, hard-coding test cases and print statements within every function...
...then finally getting the right answer with 500 unwashed lines of code, and going back to reduce it to only 20 or so.
All that trouble and all that typing and in the end 90% of it was removed for the important part which can fit on one screen.
>>
RecursionError: maximum recursion depth exceeded in comparison

Bros, go on without me
>>
File: filtered.png (438 KB, 3760x1880)
438 KB
438 KB PNG
>>
>>107223360
got it. i was using part 2's output on step 3.
Thank you, last hour wasted.
>>
File: carbon(8).png (1.05 MB, 1542x4718)
1.05 MB
1.05 MB PNG
>>
>>107214849
>>107214990
Mine is a BFS actually, and runs in 6.5 seconds. >>107216169
>>
File: file.png (15 KB, 939x125)
15 KB
15 KB PNG
>>107219299
>didn't read the problem description
You're wrong, it's actually in the problem description this time. For anyone not filtered, you've got just under 12 hours.
>>
File: day 2 part 2+3.png (191 KB, 901x2977)
191 KB
191 KB PNG
part 2 takes 10ms, part 3 takes 580ms
>>
File: day 2 part 2+3.png (352 KB, 2946x1544)
352 KB
352 KB PNG
>>107224046
part 2 takes 2ms, part3 takes 186ms
>>
>>107224100
>using the stack
bloat
>>
>>107224046
>>107224100
wtf why is your guys' literal assembly code solutions shorter than most of the regular code guys solutions. total regular code guy extinction :( i don't feel so well regular bros
>>
File: day 3.png (45 KB, 867x374)
45 KB
45 KB PNG
>>
>>107225868
it doesn't parse the input and only runs either part 2 or part 3 at a time, so...
the other anon's picture is the output of the compiler and it's not the entire program, it's originally a Rust program I think
>>
File: Untitled.png (2.25 MB, 926x10000)
2.25 MB
2.25 MB PNG
>>107225868
yeah, I lied
>>
Can your part 3 handle this?
SSSSSSS
.......
..#.#..
#..#.##
##.####
###D###

ans: 3176570856605295031
>>
>>107226876
takes 4 minutes to run, but yes
>>
>>107227033
Nice!
How about this one?
SSSSSSS
.......
..#.#..
#..#.##
##.####
###D###
..#.##.

ans: 899978633754937522790405263019948290
>>
>>107226876
2.635s
>>
>>107227378
That one definitely won't work without changing my code
>>
>>107227378
tremble, brooters, and despair! Doom as come to your CPU!
>>
>>107227497
Recursion? Or integer overflow?
>>
>>107227506
has*, not as or ass
>>
>>107227512
Need to change to bigint for that
Also at the moment having a board taller than 6 rows will mess up my memoization dictionary keys, so I need to change that too
>>
File: 10.png (527 KB, 1626x2920)
527 KB
527 KB PNG
>>107227378
36.4s
>>
How about the rest of you? As you can see it is just two more sheep and one more row. Should be easy, right?
>>
>>107227730
>u128
>>
File: file.png (21 KB, 874x333)
21 KB
21 KB PNG
>>107226876
My turd >>107213626 finishes in 40 seconds.
>>107227378
6 1/2 minutes (and about 15GB of RAM). Could be worse.
>>
How are tge puzzles now? I didnt have much time to solve post day 5
>>
>>107228842
Easy. If you can't do quest 10 within like 30 minutes you are filtered.
>>
>>107228725
Interesting. Your turd is faster than mine on >>107226876 but much slower on >>107227378
1m26,775s and 4m43,282s
>>
>>107228924
Probably the optimization on line 76-84 I wrote while procrastinating about having to actually write a recursive DFS. The second one significantly negates the benefit.
>>
>>107228972
TY for that. I thought of it earlier but never got around to implementing it. Pushed my time down to 1m9,113s
>>
>>107229186
And my little big boy time to around 8.2 sec.
>>
File: day 4.png (81 KB, 1315x646)
81 KB
81 KB PNG
>>
>>107208342
>input changes from part to part
Complete and utter SHIT. Still not over it after 10 days
>>
File: day 6.png (73 KB, 945x581)
73 KB
73 KB PNG
sweet regex powertool day
bruteforcing part 3 took 2m33s
>>
>>107230998
perlGODZ ww@?
>>
File: day 7.png (172 KB, 1391x1226)
172 KB
172 KB PNG
anyone else using the match and delete method for part 1 and 2?
>>
File: day103.png (1.85 MB, 1024x1024)
1.85 MB
1.85 MB PNG
Wow, the /g/ board actually shows people pretty much caught up over the weekend. Nice job. I was worried there wasn't gonna be anyone left to meme for the last couple weeks.
>>
Reminder that if you don't beat the bigboy >>107227378 you are filtered
>>
if you thought day 10 was a great filter just wait until 12 hours from now. it's going to be brutal.
>>
>>107233732
Probably not, Eric goes easy on us on Mondays. Likely the same story here.
>>
dead thread
>>
File: soon.png (55 KB, 1424x960)
55 KB
55 KB PNG
>>
Just so you know, I’m not getting the last duck until December 1st. I’ll post the answer in the thread, but I’m not giving a drop to niggers
>>
undead thread
>>
20 minutes until the puzzle drops, where is everybody?
>>
>>107240565
Working in my case
>>
>struggle with part 3 on friday
>oh well i got all weekend to work on it
>didn't think about this shit at all between friday and now
well shit, guess i'm filtered
>>
>>107240644
you still have 5 minutes anon!
>>
>>107240675
i'll attempt today's and if that goes ok i'll finish up friday's after. i think i was pretty close on friday so even if i'm done i'd like to at least cap that one off
>>
advent of reading comprehension
>>
i gave up on day 10 after part 1, hope you guys have fun
>>
is part 2 a brute force trap?
>>
File: botcity.png (499 KB, 388x520)
499 KB
499 KB PNG
>>107240813
cya for aoc bro
>>
>>107240966
oh nvm, part 3 is the brute force trap lel
>>
File: day 8 part 1+2.png (82 KB, 1223x666)
82 KB
82 KB PNG
I bruteforced part 3 in C.
>>
File: EC-11.png (83 KB, 759x979)
83 KB
83 KB PNG
>It's a "spot the quirk in your input that makes it trivial" day
>>
File: file.png (21 KB, 522x454)
21 KB
21 KB PNG
Ayy
The algorithm for part 3 is really simple, just a little addition/subtraction.

>>107241153
Yeah, I can't immediately figure out what the shortcut to get from phase 1 to 2 would be.
>>
>see part 3
>assume I can't brute it
>spend 5 minutes figuring out the secret math formula to solve the second phase
>spend an hour trying to figure out the secret math formula to solve the first phase
I solved it immediately after realizing what I was missing but I'm still mad.
>>
>>107241322
Did you ever figure the first phase out?
Something like...from left to right, the first time you see a number bigger than the number to its right, average it with all the contiguous numbers to its right that are smaller than the first number (making sure the remainder is evenly distributed starting from the right-most number). Restart the same algo at the number you previously ended at until you've done a full loop. Repeat until nothing changes. Then, apply the same diff algorithm used in part 2, between start state and end-of-phase1-state, to count how many rounds it took?
Hmm...
>>
>part 3 input is all ascending
oh fuck off this what a dumb gimmick
>>
File: tenor.gif (3.66 MB, 498x258)
3.66 MB
3.66 MB GIF
brute bros. I don't feel so well.
>>
File: 1740478711148975.png (3 KB, 584x52)
3 KB
3 KB PNG
>
>>
>solved part 3 half an hour ago
>didn't realize i solved it because i made my own test sequence but was testing my code against the wrong answer
fuck me
>>
>>107241454
Actually I found that finding the state after phase 1 is pretty easy. Just loop from left to right, averaging any descending ranges you find (still evenly distributing the remainder over the range, starting from the end), repeating until nothing changes.
def p2_fast():
data = [x[0] for x in parse_lines(4, get_ints)] # just the input parsed into a list

did_work = True
while did_work:
did_work = False
for i in range(len(data)-1):
j = 1
while (i+j) < len(data) and data[i + j - 1] > data[i + j]:
j += 1
if j == 1:
continue
did_work = True

sum_of_range = sum(data[i:i+j])

q, m = sum_of_range // j, sum_of_range % j

for k in range(i, i+j):
data[k] = q
for k in range(i+j-m, i+j):
data[k] += 1

print(data)

However I still haven't worked out how to get the number of rounds it took out of that. The formula for phase 2 doesn't work here, nor have any of the other things I've tried.
>>
I know this doesn't work, but shouldn't the amount of rounds be (avg - min) + (max - avg)? Aren't we just sorting 1 item at a time? Once you completed the min and the max number of balance transfers shouldn't the other columns be sorted correctly too?
>>
>>107241750
same but I used part 2 input instead
>>
>>107241479
I realized this after solving part 3 as well, I feel so duped.
>>
File: day 11 visual.png (144 KB, 1450x1500)
144 KB
144 KB PNG
permutations of how many rounds it takes the first phase to complete, for four duck columns ranging from 0 to 9
the two numbers (a, b) above each table are the first two duck columns, then the (x, y) coordinate in the table are the last two duck columns, in the order (a, b, x, y) with the value at that coordinate being how many rounds that input would take
an input of 4,3,2,1 requires 3 rounds for example, which is labelled in green in the picture

is there a formula for solving phase 1 in O(1)?
it looks like there's patterns
>>
File: 1660623236561110.jpg (41 KB, 681x383)
41 KB
41 KB JPG
went back and finally beat day 10 part 3. spent two hours debugging my memoization before realizing i was double counting in certain situations, fuck me. oh well, at least i'm still in this shit
>>
File: carbon.png (453 KB, 1634x2478)
453 KB
453 KB PNG
No idea why it works but it works, job's done. The trick is that the ducks can move in any order, just keep track of the necessary rounds per column.
>>
>>107243216
lol dude take an actually good look at your part 3 input and see how many phase 1 steps there are.
>>
>>107243216
the real trick for part 3 is that your input is already sorted so the answer is just:

>find the average
>for all of the numbers less than the mean, add up "mean - number" (could also flip it around and do only numbers greater than the mean)
>thats your number of rounds

your solution is pretty interesting though, good shit
>>
ummmmm... i don't get it
>>
File: 1755893172538142.png (249 KB, 1135x748)
249 KB
249 KB PNG
>>107243319
>both anon ( >>107243285 ) and claude are smarter than me
i have been rendered obsolete
>>
>>107243259
0 lol, just realized after reading the thread.
>>107243285
Thanks! I probably wouldn't have figured out the cheat though
>>
>>107243370
>>107243374
that algo only works because your real input pre-sorted though and would fail the test inputs, so idk if this was "intended"
>>
>>107243441
I think it's intended since AoC has pulled similar stunts in the past and this is inspired by it.
>>
File: file.png (146 KB, 561x560)
146 KB
146 KB PNG
>mogs you
>>
File: 11.png (1.56 MB, 5386x6702)
1.56 MB
1.56 MB PNG
>>
>>107243747
bros.. i don't want to participate in a furry adjacent event
>>
>>107243957
dumb retard
>>
>>107243957
Which is funny because ducks have feathers and dragons have scales
>>
>>107241593
Hahaha. Serves me right for not opening the notes for part 3. I only have a small window around the time the challenge starts, so figured I'd need to come up with something much better than the slow code I wrote for part 2.
>>
what. ThE. FUK
>spent a bunch of hours trying to figure out solution math
>diffing from avg only works on sorted data
>give up crawl back to thread for hints
>"input data is sorted"
FFFFff
>>
>>107244098
>diffing from avg only works on sorted data
just sort it
>>
Make an unsorted bigboy lol
>>
>>107244113
I don't think that actually works does it. For example the data they give you in P2 is this:

805
706
179
48
158
150
232
885
598
524
423


The given answer is 1579. If you sum diff from average you get 1378. That is the correct answer if the data if those nums are sorted and processed. But otherwise its incorrect.
>>
>>107244153
>I don't think that actually works does it
nope, doesn't work. my actual solution failed on part 3 tests lel
>>
File: d11.png (1.08 MB, 641x804)
1.08 MB
1.08 MB PNG
Where is this story even going?
>>
Fun puzzle. Thankfully I looked at the input data immediately.
At first I started combining moves into mega-moves that transfer between the level sections at the end, but that seemed annoying to implement. Then I took a shower and thought of the smart answer.
I assume this is taken from Codeforces or something?
>>
>>107244434
I don't know but it's pure kino. AoC's glorified fetch quests don't even compare
>>
>>107244444 (checked)
I went down a retarded rabbit hole thinking of flows. Whenever I made progress, it became difficult to translate it back to the rounds.
>>
File: ec2025-11.png (116 KB, 584x855)
116 KB
116 KB PNG
For some reason I immediately decided the average thing wouldn't work, so I spent 2 hours trying and failing to optimize my sorting.
>>
>>107244524
If this was AoC, today would have been about a Yeti rolling snow down a mountain, instead of some gay birds.
>>
>>107245232
>reading the story
cringe
>>
File: carbon(9).png (476 KB, 2048x2150)
476 KB
476 KB PNG
I hate math trick days.
>>
>>107245232
If this was aoc you'd be helping a dumb elf with her crossword puzzle instead of Voyaging Toward The Kingdom Of Algorithmia to uncover your legacy and discover the whereabouts of your kin
>>
File: img-2025-11-18-18-08-16.png (1.19 MB, 5440x3452)
1.19 MB
1.19 MB PNG
>>
I waited the whole day to do today’s puzzle after work. But then my wife saw an ad and now we are out shopping instead…
>>
File: xmas.png (2.16 MB, 1024x1024)
2.16 MB
2.16 MB PNG
>>107248374
>helping a dumb elf with her crossword puzzle
sovl
>>
>>107208342
democratizing "coding" and giving away knowledge for free is the jewish trick that ruined it for average developers and coomputer scientists
>>
File: uglyelf.jpg (195 KB, 768x768)
195 KB
195 KB JPG
>>107250954
I've always pictured the elves uglier than that.
>>
>>107250977
I think the entire field is a scam. I came out of university pretty much completely fucking unhirable. The teacher don’t know shit. I guarantee most “professors” couldn’t solve a leet code easy never mind doing some shitty full stack app. My company has indians with full comp sci degrees that can’t program. The entire QA team basically. The bootcamp people are even worse somehow.
>>
File: IMG_8617.jpg (298 KB, 811x965)
298 KB
298 KB JPG
>>107251732
>hires thousands of short, disheveled, sexy, gremlin girls for his warehouse
santa’s my kinda guy
>>
Thank god cloudflare is fixed. Now I can vibe code the next problem.
>>
Just did day 11, what the fuck was that bullshit part 3
>>
>>107244434
the duck better be fucking this girl on the last day
>>
>>107252323
ya I wish there was a hint. actually I wish brute force worked, but took like hours or something. some of my favorite aoc memories are waking up the next day and having an answer that works. its like a christmas miracle.
>>
>>107252874
Brute force does work, and it does take hours. Many, many, many hours.
>some of my favorite aoc memories are waking up the next day and having an answer that works.
filtered
>>
>>107245656
I wish it were a math trick, more like a "check your input day". With it all pre-sorted, the overshoots from the first phase aren't a consideration so it's "obvious".
>>
5 MINUTES
>>
SOLVED with a part 3 that took about 30 seconds
>>
File: EC-12.png (175 KB, 1149x1620)
175 KB
175 KB PNG
Fun.
>>
File: file.png (5 KB, 949x127)
5 KB
5 KB PNG
>>107254350
Yeah, that one was pretty trivial.
>>
>smallest barrels are marked 1
>find barrels marked 0 in input
Fantastic
>>
File: part 1 visual.png (454 B, 20x20)
454 B
454 B PNG
Part 1 input
>>
>>107254600
Do you have a picture that's more compressed? I can't load all 454 bytes at once.
>>
File: part 2 visual.png (9 KB, 176x72)
9 KB
9 KB PNG
>>107254600
Part 2 input
>>
File: part 3 visual.png (14 KB, 202x105)
14 KB
14 KB PNG
>>107254600
>>107254611
Part 3 input
>>
I wasted all those time thinking of how to optimize the solution when brute force just works
>>
File: ec2025-12.png (192 KB, 574x1508)
192 KB
192 KB PNG
Runs in 90-ish seconds
If I prevent it from re-searching lower-numbered barrels it'd probably speed things up.
But at least I finished a puzzle before bed this time
>>
File: carbon.png (217 KB, 1224x1230)
217 KB
217 KB PNG
Presorting so we actually hit the cache, does all parts in 5 seconds. Only part 3 code, I'll leave the first two parts to your imagination.
>>
File: 1719770772133124.jpg (73 KB, 956x956)
73 KB
73 KB JPG
missed puzzle drop today, what are we thinking? easy? filter?
>>
>>107255033
easy unless you're optimizing for a bigboy
>>
>>107255033
today's is like a day 3 tier problem
>>
>>107254946
The easiest speedup is to realize that when you're testing positions in part 3, each time you test a spot and get a set back, you can remove that set from the remaining points to check for that iteration, because any test of any point in the returned set will only return a subset of the set you just checked.
I also realize that because of that, runtime can probably be improved by randomizing the order you're testing points rather than doing a "scan", because you're more likely to hit a big flood fill and cull your search space earlier.
>>
RecursionError: maximum recursion depth exceeded


aw shit, should've seen that coming. time to rewrite into a while loop
>>
I dunno what to tell but my unwashed code runs all three parts in 500 ms and I haven't done shit to make it efficient.
WTF are you guys doing???
>>
>>107255788
what lang? unwashed rust is probably still gonna be faster than people running optimized python algos
>>
Is anyone else getting 133 for the part 3 example? I'm trying to debug that now.
>>107255687
lol yuup same.
>>
>>107255914
i got 134 but somehow fixed the issue after rewriting my function into a while loop. only thing i can think of is to make sure your starting barrel is getting added to your set of exploded barrels
>>
File: carbon.png (430 KB, 1532x1956)
430 KB
430 KB PNG
I have djisktra fatigue pepe.png
>>
>>107255788
GPTSama breaks it down for me:

>So for each cell you:
> - Copy the visited set
> - Run a full BFS from that cell
> - Measure how much bigger the visited set got
> On an N-cell grid, that’s basically:
> - O(N) BFS work
> - Done for O(N) start positions
> - Done 3 times
>So ~O(N2) BFS work and a ton of set copying. On a typical puzzle-size grid (tens of thousands of cells) that’s going to hurt.
>>
File: carbon(10).png (624 KB, 1330x3044)
624 KB
624 KB PNG
>>
File: carbon.png (223 KB, 1024x1406)
223 KB
223 KB PNG
>>107255788
It's like 8s for me in CPython. I also tried compiling it with Cython to see if it's any faster, and the answer is no.

Captcha: HHHHT
>>
File: quest12.png (188 KB, 1421x2396)
188 KB
188 KB PNG
>>107254611
>>107254623
Nice.

Fun day
>>
File: 12.png (2.6 MB, 5440x8392)
2.6 MB
2.6 MB PNG
>>
>>107255054
>bigboy
https://files.catbox.moe/2dveow.txt
11/96/272
>>
>>107255827
C++
>>
>>107258029
solution for part 2 is 12 though
>>
File: 12 p3.png (1.07 MB, 5440x3972)
1.07 MB
1.07 MB PNG
>>107258029
part 3: 24s
>>
>>107258104
>unwrap()
into the trash
>>
>>107258115
if it's good enough for cloudflare, it's good enough for me
>>
for the part 3 example
41951111131882511179
32112222211518122215
31223333322115122219
31234444432147511128
91223333322176121892
61112222211166431583
14661111166111111746
11111119142122222177
41222118881233333219
71222127839122222196
56111126279711111517


could anyone tell me the correst x,y positions? I think I got a bug. thanks guys!
>>
A true part 3 solution would be insanely slow. You can build pathological inputs where the largest explosion isn't part of the solution, so you have to try all triples.
>>
>>107258215
>where the largest explosion isn't part of the solution
wrong
>Find the barrel that allows you to destroy the most barrels with a single fireball.
>>
>>107258226
>fail for hours because you misread the question

Many such cases
>>
>>107258236
I didn't fail though, it took me less than 30min to solve all three parts
>>
>>107258215
Maybe it's doable if you do graph stuff.
>>
>>107258333
I'm a brainlet, but I've heard the word path compression and I sort of remember union find. Can you do union find path compression type junk on a 2d grid like this? I was also thinking that other day where the grids had all the zeros you could maybe path compress that? also sorry if I'm talking like a retard. I don't know enough to even know what to ask honestly.
>>
File: carbon (1).png (715 KB, 1420x3416)
715 KB
715 KB PNG
>>107255788
try again with openmp
took pic related down to 200ms from 700ms
>>
>>107258404
I was thinking of iterating through triplets of root nodes, path compression would help. Not sure about union find though.
>>
$ cargo run --release
Finished `release` profile [optimized] target(s) in 0.00s
Running `target/release/ec12`
238
5786
4012
9.951407ms


sub 10ms runtime for rustGODS
>>
>>107258447
>>107258548
try the bigboy though >>107258029
>>
>>107258552
I made the bigboy. 2m
>>
>>107258404
You can do "root find": plateaus of cells with the same value are considered the same element, return one element from each plateau that doesn't border a larger element, like how DSU chooses one element as root of a set.

Maybe there's a faster approach that involves precomputing the full basin around each root, but I found it quicker to recalculate each time.
>>
>>107258552
I get 272 in 2.8 seconds
>>
>>107208342
what element is that?
>>
>>107258647
where is the code though?
>>
>>107258675
https://pastecode.io/s/piey1bon
>>
>>107258753
is that site written rust too lmao
use pastebin or catbox
>>
>>107258647
>>107258753
can't reproduce, part 3 takes 41s for me
>>
>>107258830
>cargo new ec12
>cd ec12
>cargo add rayon
replace src/main.rs with >>107258753
>cargo run --release

Enjoy your 2s runtime
>>
>>107258855
I'm not retarded, I know how to compile and run rust code.
You multithreaded shit is slower than my singlethreaded solution.
>>
>>107258830
What's your algorithm? Root find like >>107258636 or checking every square every time? That's the biggest difference; unwashed python with root find will beat optimised parallel rust broot.
>>
>>107258876
see >>107258104
>>
>>107258881
>iterate 0..3
>iterate x 0..w
>iterate y 0..h

Looks like you're searching the whole grid every time. You only need to start from roots (see find_roots in https://pastecode.io/s/piey1bon).
>>
>>107258922
>Looks like you're searching the whole grid every time
wrong
>You only need to start from roots
it's slower though, see >>107258830
>>
>>107258935
Post your full code (not a screenshot), I'll benchmark them both on my machine.

I run the bigboy, I get 272 2.8 seconds later. My CPU is 13th gen intel i5, decent but nothing crazy.
>>
>>107258966
https://pastecode.io/s/9tp7oxir
>>
>>107255218
Yeah that's what I just did. Brought it down to 20 seconds. Not sure if F# is just not a very fast language, or if I'm using it wrong.
Random shuffling only made it worse for me, so instead I ordered by descending barrel size.
>>
>>107258935
>wrong

How exactly? Your screenshot doesn't show your full code, but:

>line 6, 0..3
>line 9, iterating x over the entire width for each 0..3
>line 10, iterating y over the entire height for each x

It sure looks like you do at least one check for every cell, and call 'fire' (whatever that function is) on every non-destroyed cell. There's no sign of any root finding.

My code only checks roots each loop, no whole-grid iteration:

    for _ in 0..3 {
let (size, region) = roots
.par_iter()
.map(|&(ry, rx)| {
let region = flood_region(&grid, &dead, ry, rx);
(region.len(), region)
})
.max_by_key(|p| p.0)
.unwrap();
for (y, x) in region {
dead[y][x] = true;
}
total += size;
>>
>>107258982
>no main function
>no read function

Jesus Christ this isn't code golf, just copy and paste the whole thing. Anyways yours runs in 16.8 seconds, mine in 2.8 seconds.
>>
u guys seriously program in rust? why?
>>
>>107259031
>It sure looks like you do at least one check for every cell, and call 'fire' (whatever that function is) on every non-destroyed cell.
fire shoots fire balls. I'm pretty much doing what >>107255218 describes.

>>107259082
I don't have a main function. Also reading the input is just std::fs::read_to_string. calm down, kiddo.
>Anyways yours runs in 16.8 seconds, mine in 2.8 seconds.
well, on my crappy laptop mine runs in 24s and yours in 41s (72s if I replace par_iter with iter)
>>
>>107259108
My runtime obliterates yours, obviously I know what read_to_string is you fucking retard. If you post code for benchmarking it should just werk. Sorry to hear you're a broke thirdie who can't afford modern technology.
>>
>>107259179
>My runtime obliterates yours
not on my hardware though
>I know what read_to_string is you fucking retard
than stop crying, dumb retard
>Sorry to hear you're a broke thirdie who can't afford modern technology.
damn, getting btfo by my single-threaded solution made you really mad, huh?
>>
File: carbon.png (761 KB, 847x4461)
761 KB
761 KB PNG
>>107258404
>Random shuffling only made it worse for me, so instead I ordered by descending barrel size.
Yeah, on further contemplation, I don't think it would make a very significant difference. Checking larger barrels first is definitely the play.

I fed my original code into ChatGPT, and tard wrangled it into optimizing my code into this fucking abomination. Somehow it works, and finishes in ~300ms in regular CPython. My original code was ~18000ms (and a quick partial rewrite where I turned the grid into a NetworkX graph and made it do all the complicated stuff was ~5300ms). Frightening.
>>
>>107259225
Oops, meant to reply to >>107259019
However the post I accidentally replied to is relevant too, because that's basically what my AIslop does, I think.
>>
>>107259198
Hop off my dick already. I write good code that runs fast on modern hardware that people with jobs use. You're clearly seething your shitty nograph solution got btfo. Next time include all your code in your screenshot upfront so you can be laughed at properly.
>>
>953ms bigboy
>17ms on actual input

Like >>107258636 but instead of re-flooding each root, you record the flood sizes on the first pass. This is an upper bound on how much each root can contribute. Use it as a key to sort the roots, then you can skip subsequent rounds as soon as you find a root with lower initial size. For the cost of one sort you essentially skip rounds 2 and 3.
>>
File: 12 p3.png (1.36 MB, 2932x5960)
1.36 MB
1.36 MB PNG
>>107258029
1.1s
>>
File: scawwy.png (59 KB, 490x490)
59 KB
59 KB PNG
>bump limit reached
>>
>>107260509
what motivates you to spend eight hours on a shitty puzzle? this is like the tenth troonslop screenshot you've posted since morning
>>
page 10 bonus challenge: solve day 12 with one (1) regex
>>
>>107261312
why are you so mad though?
>>
>>107261349
I'm mad and genuinely worried that someone's wasting so much time on something so vapid
>>
>>107261537
No need to worry, I only spent ~1.5 hours on this, and 1 hour was while I was at work.
I do it because it's fun, you should try doing this that are fun, maybe you'll be less mad.
>>
>>107261557
>doing this
doing things



[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.