[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: pathfinding.png (7 KB, 502x503)
7 KB
7 KB PNG
pathfinding 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: >>103471260
>>
>>103478070
nigger
>>
https://www.youtube.com/shorts/mkr3ytZdmBw
brootchads...
>>
tomorrow is proper pathfinding
>>
Fuck it. Tomorrow is MSTs
>>
>>103478109
>brootchad
nice oxymoron
>>
It's a memoization do this 15 trillion times problem.
>>
>/shorts/
no
>>
>>103478145
I have no fear
t. Bruteforced 2022 day 17 part 2
>>
>too retarded to keep track of visited spaces when doing DFS
>part 1 fails
>panic and just track visited "9" spaces to get part one
>solve part 1 and part 2 at once
Thank you Eric for coming through for the ditz contingent today! Still not filtered
>>
>>103478336
elf sex
>>
What are yall eating before the new puzzle drops?

For me, its Domino's™ Pan Pizza with bacon and feta.
>>
File: visfast.mp4 (2.42 MB, 500x500)
2.42 MB
2.42 MB MP4
>>103478336
I finished so fast that I also made a cute visualization! How fun!
>>
>>103478390
>amerifat
>can only think of eating even in /aocg/
like clockwork
>>
>>103478396
vid doesn't play for me
>>
>>103478372
very true, anon; seconded
>>
>>103478401
nta but that's because you're a dumb phoneposter
>>
>>103478401
Interesting; maybe it's your browser. If you download it then vlc/mpv should work?
>>
>>103478390
Empty stomach with the exception of coffee and home made eggnog
>>
>>103478390
hot chocolate. comfy times ahead
>>
>>103478407
no, desktop

>>103478413
worked in vlc, looks like it's because it's avc1
>>
>>103478401
probably the pixel format, happens when people shove a bunch of PNMs in ffmpeg without specifying the pixel format. changing it to yuv420p should make it play everywhere
>>
>>103478458
I've done visualizations in ffmpeg for years now and I've always used yuv420p; must be something else wrong.
>>
>>103478473
you haven't been posting mp4s for years
>>
>>103478458
>shove a bunch of PNMs in ffmpeg without specifying the pixel format
Wait what? ffmpeg is so based, is there anything it cant do?
>>
>>103478480
>is there anything it cant do?
Probably not. Might do next year in just ffmpeg
>>
>>103466932
In and out, 20 minute coding session
>>
File: eric wtf.mp4 (1.07 MB, 720x720)
1.07 MB
1.07 MB MP4
More AI slop, but it was too weird not to share.
>>
>>103478479
Yep! I usually give 'em a .webm file extension; you think that has anything to do with it?

>>103478499
Nope. It's load bearing civilizational tech at this point, at least until AI takes over maintaining it.

>>103478499
Actually this would be really fun. One of the things I've loved about doing it in coreutils is that you can actually see the data get transformed; I imagine ffmpeg could give you great views of the intermediate stages.
>>
>>103478508
what a tease
>>
>>103478508
RAPE
>>
haven't eaten yet, do I have time?
>>
>>103478537
As you digest your food, blood will leave your brain and travel to your stomach, causing your performance to plummet.
>>
>>103478508
>>103478529
>>103478536
hang yourselves
>>
>>103478508
idk about the puzzle but i'm as hard as it gets
>>
>>103478514
I didn't realize Eric was fat but I kinda see it now
>>
1 HOUR
>>
status: gooning
>>
dp problem please eric
I need to PRUUUUNE
>>
>>103478555
There is no reason to behave or act like you did there anon. Suicide is no joke.
>>
File: eric.jpg (94 KB, 1500x500)
94 KB
94 KB JPG
>>103478575
>>
>>103478508
>works on test input, not on real input
anthropomorphize this situation with elf girls somehow
>>
>>103478594
They're pedophile scum, should be treated/should treat themselves accordingly.
Also I'm pretty sure those posts have nothing to do with AoC or technology.
>>
>>103478612
input-chan has big booba and example-chan is jealous because she doesn't
>>
File: 1721619888926241.jpg (147 KB, 887x955)
147 KB
147 KB JPG
Please be a problem where I can use quad trees
>>
>>103478621
pedophile scum website
>>
>>103478633
cunny chad checking in
>>
>>103478621
>>103478633
I only come here because I hate reddit and I can say nigger. Even if I barely use the term at all.
>>
>>103478621
It's not my thing, on that I can agree. But acting aggressive online and staging moral outrage due to drawings of any kind is just virtue signalling.
>>
File: 1733776541663385.jpg (130 KB, 1280x720)
130 KB
130 KB JPG
>>103478612
he already did

>>103478555
we are doing a Christmas themed programming contest on 4chan, anon; we're all horny and lonely
>>
File: aoc_2024_10.png (98 KB, 777x1386)
98 KB
98 KB PNG
Perl. Too lazy to figure out global memorisation for silver when it works for gold, so arguably the end result is working even slower.
>>
>>103478657
>lonely
Speak for yourself.
>>
>>103478529
>>103478536
>>103478571
No sexo the little ones.
Here, take one of these instead
https://files.catbox.moe/gv7jz5.jpg
https://files.catbox.moe/powy9f.jpg
>>
>>103478657
If you don't enjoy being alone then find people to be around you. Fucking whining retard. Instead he posts these disgusting pictures.
>>
>>103478657
>we're all horny and lonely
Nah, a lot of us are married in our 30s at this point. I'm waiting for my wife to fall asleep so I can go wait for day 11 to drop at my desk
>>
>>103478682
put on a name so i don't have to see your ai slop
>>
File: 1733838723918563.jpg (274 KB, 1280x1500)
274 KB
274 KB JPG
I respect the example-chan and input-chan enjoyers.
But for me, it's broot-chan. I want to cuddle with her, and I don't want to finish at all.
>>
File: SkSvxvRZC.png (58 KB, 200x200)
58 KB
58 KB PNG
>>103478555
>>
File: aocHarderPuzzles.png (853 KB, 1241x866)
853 KB
853 KB PNG
If today isn't a filter i am storming AoC HQ
>>
File: male-loneliness.jpg (162 KB, 1080x1349)
162 KB
162 KB JPG
>>103478691
True. But to remain fair, you can still be very lonely while in a marriage.
It's just a kind of loneliness that gets overlooked and actively ignored by society.
>>
>>103478732
go back
>>
oh I didn't even notice but the picture is a giant "10" with a mini-map of all the previous years inside of it
>>
>>103478732
Stop shitting up the thread and acting like such a faggot. You can't farm any goodboy points here
>>
File: newfagaward.jpg (56 KB, 600x600)
56 KB
56 KB JPG
>>103478732
That's not what it means dumbass
>>
Are there any other places we can discuss these puzzles that aren't called reddit and not full of pedos?
>>
>>103478762
You first to groomsky
>>103478780
Less than how many years count as newfag?
>>103478777
I'm not the one shitting up these threads, scroll a bit up.
>>
>>103478793
You feel like a newfag election tourist to me
>UMMMM 2016 WAS NEARLY A DECADE AGO
I don't care.
>>
File: IMG_6538.png (658 KB, 2532x1170)
658 KB
658 KB PNG
Does anyone know what happened on D11 2016? Any war stories?

>>103478785
Hackernews but it's full of self-serious faggots. Don't even think about meming in any way, you'll have your post deleted
>>
>>103478704
SEXOO
>>
>>103478793
>I'm not the one shitting up these threads
zero self awareness
>>
>>103478732
pixels on your screen aren't real people
>>
Is tonight THE ONE?
>>
>>103478828
Yes. I already rented out a server farm in preparation.
>>
File: carbon.png (475 KB, 1534x4176)
475 KB
475 KB PNG
>>103476912
Pretty shit code but I got this working and didn't see anyone else do it like this with no BFS/DFS, just just addition and bitwise operations on neighboring cells
600ms as written though
>>
>>103478732
Calm down son, it’s just a drawing.
>>
>>103478804
>day 11 2016
>go to look at problem

yep, I remember her. a real firecracker, that one
>>
File: 74a0b7gvfg5a1.png (905 KB, 1000x2100)
905 KB
905 KB PNG
Somebody needs to create a /g/ and updated version of pic related.
>>
>>103478857
All are true except the last one, remove that.
>>
>>103478732
fuck off
>>
>>103478857
All are false except the last one, keep that.
>>
>>103478857
>YOU:
>Anonymous
>YOUR COMPETITION:
>Anonymous
>>
>>103478878
good morning saar keep shitting on the streets
>>
>>103478390
cock :3
>>
>>103478857
What a great image
Very funny and interesting
I definitely met wjhbr and Samir.
>>
>>103478857
>the llm pajeet
>the llm tranny
>the llm pajeet
>the llm pajeet
>the llm eastern euro
>the llm tranny
>>
File: Untitled.png (680 KB, 1000x2100)
680 KB
680 KB PNG
>>103478857
>>
>>103478905
>Everyone below me on the leaderboard is a drooling retard
>Everyone above me on the leaderboard is a LLM
It's very simple actually
>>
>>103478903
sir very good image sir can confirm sir
i kindly have to say the last one is most intelligent
me too always try to do the needful fast
>>
File: necrodancer-melody.png (60 KB, 528x720)
60 KB
60 KB PNG
>>103478857
> You
Anon
> Your competition
- mhfwalters
- wjhbr
- Another russian (tries to DDoS the leaderboard with his botnet)
- Tharg
- Woman (male) of some high paying remote only job. After 2 evening shakes of adderal and hormones.
- LLM cheater
- Chinese moonrunes (LLM cheater)
- Pajeet (also LLM cheater)
- Samir Nagheenanajar
>>
>>103478923
I was thinking of making a meme great filter image where I filter anyone that has gotten a time worse than me on each day
>>
>>103478960
kek
>>
>>103478857
This image contains all the major archetypes except the latest addition to the gang: tranny game engine dev.
>>
>>103478927
Namaste
>>
>>103478967
Those are filtered on the first "difficult" day.
>>
I want Timeenjoyed on the image.
>Harness the power of simp multitudes who will walk her through any mental obstacle.
>Consults tarot to ensure vibes are correct before submitting
>Utilizes expensive peripherals with cutting edge LED technology.
>>
>>103478857
>The rust troon
>The python brooter
>The runic language wizard
>The thread peeker (in denial)
>The llm cheater
>The anime background poster
>>
>>103478976
Trannies are high IQ, autistic, and good at coding puzzles though
>>
10 MINUTES
>>
>>103478983
tfw I didn't even get a mention.
>>
>>103478996
and who might you be?
>>
>>103478989
>high IQ
more like midwits
>autistic
yes
>good at coding puzzles though
there are literally zero trannies on the codeforces or atcoder leaderboard
>>
AoC++ chads, what are we looking at today. Tarot guys, what do the vibes say?
>>
>>103479006
string parsing
>>
less than 8 minutes and a dead thread
>>
>>103478703
Ditto. BigBoy-chan is def amazing in the sack and probably makes amazing Christmas cookies on top of that.

>>103478857
I feel like this whole era has now passes us by. Remember when coding was THE skill you could use to assess intelligence and everyone was super excited to do/talk about it?

Feels like so long ago.
>>
File: loli-sunglasses.png (813 KB, 899x899)
813 KB
813 KB PNG
>>103479006
game simulation today
>>
File: file.png (157 KB, 600x513)
157 KB
157 KB PNG
>>103479015
>>
>>103478976
Game engine, graphics, compiler development are all hard. Say what you want about her (him), the tranny is good at programming.
>>
>>103479006
first 3d puzzle
>>
>>103479022
Hmm. You were right last time
>>
>>103479026
>shhh
>now you may speak
>>
haaahhh, can you feel it /acog/? it's coming. the memoization problem
>>
File: aoc.jpg (33 KB, 460x460)
33 KB
33 KB JPG
>>103479016
>outcodes you
>>
inb4 another easy day
>>
>>103479036
I have functools.cache impoorted already.
>>
>>103479006
Insider here. Chinese reminder theorem day today.
>>
1 2 7 3
>>
File: showtime.jpg (46 KB, 640x480)
46 KB
46 KB JPG
https://www.youtube.com/watch?v=hjGZLnja1o8
>>
>>103479048
cancer music
>>
I am going with DP problem.
Something like x combination of y items you must solve per line.

First would be like N combinations where N is bruteforceable,
second would be N combinations where N is not bruteforceable.
>>
>>103479046
cancer music
>>
Solve this problem......
....
NOW DO IT 303948092832093128123 times tee-hee, nothing personal brooters.
>>
>>103479048
Blessed music
>>
>>103479048
kino music
>>
File: showtime-frog.png (468 KB, 1858x1829)
468 KB
468 KB PNG
>>103479048
we rollin
>>
>>103479048
SHOWTIME
>>
>>103479056
Kys
>>
File: mokou-showtime.jpg (130 KB, 440x518)
130 KB
130 KB JPG
>>
>>103479056
>>103479065
kys
>>
>>103479053
>Only 303948092832093128123 times? Sounds brutable to me.
>>
File: 1733654980642328.jpg (102 KB, 580x500)
102 KB
102 KB JPG
LETS GO BROOTBROS
>>
>>103479066
u first
>>
>>103479062
>>103479066
kys
>>
>>103479069
Always leave the brute force going in the background while working on a better solution.
Sometimes it pays off.
>>
>someone at the door
AGENTS OF CHAOS SENT TO SABOTAGE ME
>>
keep yourself safe guys :)
>>
BROOTBROS IT'S ALMOST TIME, SEE YOU AFTER 1 HOUR OF RUNTIME
>>
I NEED TO SHIT
>>
>hands: washed

I am ready
>>
File: booldha.jpg (15 KB, 400x400)
15 KB
15 KB JPG
>>103479079
let him wait
>>
>>103479079
>I got the right address
another one down...
>>
FUCK
>>
>>103479038
alright guys, now that the dust has settled.
is he black or not cheating?
>>
FUCK
>>
FUCK
>>
FUCK
>>
FUCK
>>
FUCK
>>
FUCK
>>
advent of parsing
>>
not one of these again
>>
Could've inlined that input text.
>>
>Memoization
FUCK THAT. BROOTERS. WE RISE
>>
IT'S BROOOOTING TIME
>>
Brootards BTFO in part 2
>>
Oh yeah part 2 is gonna be DP for sure
>>
oh yeah
FUCK
>>
I can't figure out the pattern...
>>
brutebros..?
>>
>>103479155
its over
>>
WHY IS @cache NOT WORKING AHHHHHH
>>
Just started my part 2 broot. Time to take a shit
>>
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
11 00:11:18 2756 0 00:11:42 470 0

kek
>>
IM BROOOOOOOOOOOTING
>>
File: ALL THE RAM.png (21 KB, 689x565)
21 KB
21 KB PNG
Guys I don't think brute force will work this time
>>
File: 1725465903011959.png (150 KB, 1438x993)
150 KB
150 KB PNG
>You got rank 108 on this star's leaderboard.
Motherfucker.
I thought I'd use Python today because I randomly woke up early and thought I might be able to place well.
And I would've, if I remembered that "pypy" defaults to the Python 2 interpreter and thus does not understand what functools.cache is lmao.
>>
>>103479184
>not renting a server
>>
>>103479187
>"pypy" defaults to the Python 2 interpreter
for what purpose
>>
>>103479173
its the same as the lanternfish one
annoyed part1 took me so long, i was faffing around trying to figure out how to do the rules nicely and got them wrong a couple times
>>
>all knowledge of memoization has left my body
Time to figure it out from first principles. Pen check, paper check. See you in 5 hours
>>
from collections import defaultdict

stones = list(map(int, open("input.txt").read().strip().split()))
sd = defaultdict(int)
for s in stones:
sd[s] += 1
for _ in range(75):
news = defaultdict(int)
for s, v in sd.items():
if s == 0:
news[1] += v
elif len(str(s)) % 2 == 0:
news[int(str(s)[: len(str(s)) // 2])] += v
news[int(str(s)[len(str(s)) // 2 :])] += v
else:
news[s * 2024] += v
sd = news


print(sum(sd.values()))

      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
11 00:04:31 475 0 00:17:50 1128 0
>>
File: image.png (539 KB, 967x766)
539 KB
539 KB PNG
UNWASHED BQN solution

      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
11 00:11:28 2817 0 00:11:43 471 0


>>103479173
hello there
>>
>>103479187
>@functools.cache
wow, I didn't even think of that. Python is so good. How can other languages even compare?
>>
my dp isn't finishing instantly god oh fuck
>>
LANTERNFISH QUESTION
PREPARE FOR THE GREAT FILTERING
>>
File: file.jpg (93 KB, 1280x720)
93 KB
93 KB JPG
>>103479212
>>
File: carbon.png (170 KB, 1580x814)
170 KB
170 KB PNG
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
11 00:08:39 1790 0 00:19:23 1295 0

I'm absolutely retarded. I did the naive thing on a list for part 1 and saw it's not gonna work for part 2. So I wrote a recursive solution for part 2 and forgot to decorate with @cache... Got pretty suspicious that I still had ram after 4 minutes and finally noticed that blunder.
>>
Part 1:
data = map(int, open("Day 11 input.txt", "r").read().strip().split())

for i in range(25):
new = []
for stone in data:
if stone == 0:
new.append(1)
elif len(str(stone))%2 == 0:
text = str(stone)
new.append(int(text[:len(text)/2]))
new.append(int(text[len(text)/2:]))
else:
new.append(stone * 2024)
data = new
#print data

print len(data)

Part 2
data = map(int, open("Day 11 input.txt", "r").read().strip().split())

cache = {}
def solve(stone, depth):
if (stone, depth) in cache: return cache[(stone, depth)]
if depth == 75:
return 1
if stone == 0:
result = solve(1, depth+1)
elif len(str(stone))%2 == 0:
text = str(stone)
result = solve(int(text[:len(text)/2]), depth+1)
result += solve(int(text[len(text)/2:]), depth+1)
else:
result = solve(stone*2024, depth+1)
cache[(stone, depth)] = result
return result

total = 0
for i in data:
total += solve(i, 0)

print total

Bruteforce part 1, DP part 2. Easy day.
>>
File: xarbon.png (9 KB, 452x468)
9 KB
9 KB PNG
terrible day :(
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
11 00:13:23 3522 0 00:23:38 1726 0
>>
i'm so sorry, brootbros... in a moment of panic i showed weakness
while brooting i bluescreened on the 40th iteration
i... used memoisation
please forgive me, i tried to be one of you, i really did
>>
>>103479217
you dont need to cache anyway, the other lanternfish trick is you just store the amount of stones rather than individually storing each stone
e.g. {0: 1, 1: 3, 5: 10, 2024: 8}
>>
>It's another see if you can program the right solution while your bruteforce runs in the background day
>>
>>103479184
Just download more RAM
>>
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
11 00:03:57 364 0 00:27:09 2073 0

AAAAAHHHHHH I AM SO FUCKING STUPID!!! THE ANSWER WAS STARING AT ME THE ENTIRE TIME REEEEEEEEEEEE
>>
>>103479236
maybe if your code wasnt so ugly you'd have done better
>>
File: file.png (72 KB, 709x311)
72 KB
72 KB PNG
>AI can do memoization now
it’s so over bros
>>
>>103479251
trained on lantern fish thank you sarr
>>
File: D11.png (440 KB, 2048x1534)
440 KB
440 KB PNG
>>103479157
Washed Kotlin.
>>
>>103479250
Ok anon-sama, still first on both leaderboards.
Tomorrow will be better. Don't know what you have against me.
>>
ezpz
>>
~230 trillion
Assuming 32 bit numbers, you could brute force this on a server with a petabyte of swap. Don't give up!
>>
>>103479251
>bikatrnigger
>2:25
how many times did he generate and run code, only for it to fail the sample?
AI would be hopeless in real world software engineering lol
>>
>>103479260
I just tried and chatgpt gets it right on first try once you tell it the naive solution is too slow
>>
> No matter how the stones change, their order is preserved, and they stay on their perfectly straight line.
> It doesn't actually matter
Thank god I remember the lantern fish puzzle

Wish I could have made my delta between silver and gold faster, it took me 23 seconds to change a value from 25 to 75, then re-run and paste my output
>>
>>103479250
>>103479257
Spaces are bloat
>>
>>103479263
I just tried your mom and went for round 2 once she told me i finished too fast
(my vril permits me to stay hard during refractory)
>>
BROOTBROS, IT'S STILL RUNNING
>>
>import functools day
I'm going back to bed
the fact that this is my best placement yet on both parts and I spent 10 minutes banging my head against a type error makes me die inside a little more than usual
>>
>>103479251
what happened to the so called "ai filter"
>>
File: fishy-solution.jpg (790 KB, 1440x2223)
790 KB
790 KB JPG
broot bros... just do some memory optimizations. it'll work out!
>>
>>103479268
FInally this anon gets it. Only use spaces when must and avoid reddit spacing especially in code.
>>
>>103479272
what iteration are you at?
45? that's like half way there

>>103479277
still working on it, will drop a puzzle on day 26
>>
>>103479253
>>103479266
Wait a second, you are not actually memorizing PUZZLES, right?
Surely you're memorizing the concepts (memoization, Dynamic Programming) like normal 100+ IQ people.
>>
The brootkiller.
idk if this will finish in 24 hours...
Sorry bros, we had a good run
>>
>>103479286
I FORGOT TO ADD A PRINT AND I'M NOT GOING TO RESTART IT, FUCK IT. I ALSO LOST 20 MINUTES DEBUGGING WHAT ENDED UP BEING A DUMB PARSING ERROR.
>>
>>103479257
>hmm someone calls my code ugly every day, i wonder what it could mean
>>
>>103479297
ANON EDIT YOUR CODE AND RUN ANOTHER INSTANCE
YOU HAVE MORE THAN 1 CORE, YES?
>>
>>103479292
>midwit thinks 100+ iq is worth noting
>midwit doesn't realize that memorization is free when you have a picture perfect 140+ IQ gigachad memory
>>
>>103479217
functools.cache can be done by hand in like 5 lines it doesn't matter

>>103479242
I let it rip while writing the memoized version and it crashed my vscode lmao
>>
>>103479292
i copypasted my lantern fish code and updated it
>>
>>103479307
IF I DO THAT THE CORE THAT'S DOING ALL THE WORK WILL DROP TO LOWER FREQUENCY
>>
I though for sure that the order of the stones would be important for part 2 so today was slow for me.
>>
okay I figured out how to solve it in my notepad, I'll code it up tomorrow or whatever
>>
File: 1724841943142909.png (110 KB, 1047x425)
110 KB
110 KB PNG
brootbros...
>>
>>103479292
You think too highly of me saar
But yes, I solved Lantern fish using memorization, recognised this was similar, then solved this using memorization

That's the idea, right?
>>
>>103479309
i never truly realised how retarded 90 <= IQ <= 120 people are until i tried arguing with one of them
they get confused by their own rhetoric and apply their own logic to call me a hypocrite
i shan't associate with them any longer
at least IQ < 90 accept they're retarded and that i'm probably right by default
>>
>>103479318
PUT A WATERPROOF PLASTIC BAG WITH ICE CUBES ON YOUR CPU
IT WILL PREVENT THROTTLING
>>
>>103479331
I mean memoization, whatever its 6am here in bonglang
>>
File: shoot_2024-12-11_00:40:24.png (157 KB, 1065x1101)
157 KB
157 KB PNG
>its a collect like terms problem
I spent about 10 minutes trying to draw out a loop of numbers and seeing if i could find cycles for the numbers 0-9. But I am too much of a brainlet
>>
File: 1731884595073739.webm (2.06 MB, 308x482)
2.06 MB
2.06 MB WEBM
>>103479258
>sum(list(positions.values()))
>>
>literal 5 second part 2
nice
>>
I'm running out of ram even when I do memoization
>>
big nigger: "1488", iterate 1488 times
>>
--------Part 1---------   --------Part 2--------
Day Time Rank Score Time Rank Score
11 00:22:42 6078 0 00:23:03 1661 0


I didn't broot today and my time confirms this
Feeling cute about this code ngl
>>
>Advent Of Number Theory
Well fuck. No idea how to approach this one.
>>
>>103479371
broot it; see you next year
>>
>>103479364
1130708099365958212847920062208177375754509799280386033131426870041260261310405132183086364338433960941900120695082716443200778425129506458267775291930748777257319728081141510098969231290238544509775526138355694978742618610830284620119054706181324294228801420840657460286
>>
>>103479234
oh yeah, each stone is independant so you can consider each one as its own problem
i was simulating the whole array, i knew i was fucked as inserting is worst case O(n)
well done
>>
>>103479364
>1488
0.07s
NOT SPAM
first few chars 176452840613
>>
>>103479371
>Number Theory
Hardly.
Keyword for today is "memoize" if you want to do research.
>>
>>103479258
>
rockpositions = defaultdict(int)
for d in data:
rockpositions[d] += 1

For me it's
rockpositions = Counter(data)
>>
>>103479234
you could have done both with your part1 code if you just switched from a list to a defaultdict where the key is the stone number and the value is the amount
>>
File: img-2024-12-11-06-50-09.png (106 KB, 1626x552)
106 KB
106 KB PNG
>>
>>103479382
Can confirm, the first digits are
>1764528406138
>>
Could a brootGOD dfs broot to ensure memory doesnt explode? how long would it take to compute? I kind of want to do it for the meme if it takes hours and not years
>>
File: mokou-vomit.jpg (122 KB, 415x497)
122 KB
122 KB JPG
>>103479367
what THE HELL is that UGLY THING in the background?
>>
>>103479384
fuck sake i always forget this thing exists
>>
>>103479051
Nice, I was correct
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
11 00:30:50 7410 0 00:49:30 4050 0

    stones1 := make(map[int]int)
for _, vs := range strings.Split(string(dat), "\n") {
vs = strings.TrimSpace(vs)
if len(vs) == 0 {
continue
}

for _, v := range strings.Fields(vs) {
n1, _ := strconv.Atoi(string(v))
stones1[n1] += 1
}
}

fmt.Println(stones1)

n := 1
n = 75
for i := 0; i < n; i++ {
// fmt.Println("stones", stones1)
fmt.Println("i", i)
stones2 := make(map[int]int)

for sn := range stones1 {
sv := stones1[sn]
if sn == 0 {
stones2[1] += sv
continue
}

digits := int(math.Log10(float64(sn))) + 1
if digits%2 == 0 {
// fmt.Println("digits", digits, sn)
ss := fmt.Sprintf("%d", sn)

left, _ := strconv.Atoi(string(ss[0 : digits/2]))
right, _ := strconv.Atoi(string(ss[digits/2:]))
stones2[left] += sv
stones2[right] += sv
continue
}

stones2[sn*2024] += sv
}

stones1 = stones2
}
fmt.Println("stones", stones1)
sum := 0
for _, v := range stones1 {
sum += v
}
fmt.Println("sum", sum)


Yes I am dumb dumb. I thought It had something to do with modulo 2024. then I realized the order does not matter and I swapped my slice to a map.
>>
>>103479391
There would be ~200 quadrillion array items in total, your computer cannot handle it.
>>
>>103479364 (Me)
my answer starts with 7561273255692629690

>>103479378
>>103479382
>>103479390
ruh roh
>>
>>103479393
Ah shit anon doesn't like nerdy Tewi?
>>
Graphchads. Would counting cycles be better than counting occurrences? For example. 0 -> [2,0,2,4] in 4 timesteps. And just saving a bunch of those as memoization.
>>
>>103479407
oh fuck me it's 176... i used my puzzle input 1488 times after checking my solution still got the right answer
>>
>>103479383
I tried this and it didn't work. Not sure what I'm doing wrong.

@lru_cache
def quick_blink(stone, num_blinks):
if num_blinks == 0:
return 1
if stone == 0:
return quick_blink(stone + 1, num_blinks - 1)
elif len(str(stone)) % 2 == 0:
return (
quick_blink(int(str(stone)[:len(str(stone)) // 2]), num_blinks - 1) +
quick_blink(int(str(stone)[len(str(stone)) // 2:]), num_blinks - 1)
)
else:
return quick_blink(stone * 2024, num_blinks - 1)


On the other hand, my dictionary-based approach works great, just tracking the count of stones of each number.
>>
>>103479330
at least you are using your CPU for something good.
>>
Brootbros, we got too cocky...
>>
>>103479409
Looks like westoid furfag art, ngl.
>>
>>103479016
>Remember when coding was THE skill you could use to assess intelligence and everyone
Nope.
>>
>>103479424
broot 2015 day 10 while you wait
>>
>>103479424
lol poorfag
>>
>>103479409
looks cute
>>
>>103479411
if you're not also caching the intermediate steps there is going to be a lot of repeated calculation.
>>
>>103479402
not if you depth first search it and pop things off the end one at a time though right? like if you keep count of how many times a stone has been iterated and do the same one over and over to get rid of it.

it would still be 200 quadrillion operations, but it wouldnt take up any ram.
>>
>>103479419
don't use lru_cache but explicit memo
never trust that shit
>>
File: day11.png (83 KB, 579x539)
83 KB
83 KB PNG
>>103479419
My solution. Same as lanternfish.
>>
>>103479444
well I was thinking you find good cycles for all single digit numbers, and numbers break down into single digits fairly quickly.
>>
File: carbon(9).png (230 KB, 1564x1414)
230 KB
230 KB PNG
Pretty happy with this
Started trying to analyze for cycles but gave up and just memoized
~100ms runtime with normal python
>>
i just want everyone who wrote a proper memoized solution for part 1, and therefore spent 5 seconds on part two - fuck you. fucking retarded autistic savants
>>
>>103479446
nigger you just ask the question "given stone `n`, how many stones will you have after `k` steps?", then cache your answer by the state `(n, k)`
>>
>mfw we have to move rocks all day
>>
>>103479456
Based memooer. I have a pretty similar solution.
>>
>>103479459
yes I know, but if you want to broot it for the meme, would it finish before the heat death of the universe?
>>
File: day11.png (235 KB, 1772x1520)
235 KB
235 KB PNG
$ mix run -e "AOC.main()" -- 2024 11 b input/real
183435
218279375708592

Ran in 392.716ms


defmemo my beloved.
>>
File: file.png (10 KB, 598x80)
10 KB
10 KB PNG
If you're not as good as this guy, just quit your job now. You're not a real engineer.
>Verifcation not required.
>>
>>103479452
What the fuck, this worked. Why is LRU Cache so shit!?

Thanks for the tip!
>>
>>103479467
if every time 1 stone splits into 2 you parallelise it, yes i think
>>
File: 1715171698839212.png (265 KB, 1528x1282)
265 KB
265 KB PNG
Unwashed Swift.
Never can remember how to do these problems properly and fuck up my memoization every single time.
The more I use this memelang the more I get annoyed by it. Time to learn something new.
>>
>>103479452
>>103479473
lru cache worked for me, just make sure to set maxsize=None
>>
>>103479473
>Why is LRU Cache so shit!?
LRU removes data from the cache. You never want to do that in the leetcode scenarios that finish in several minutes and can leak oceans of memory without any issue.
>>
>>103479467
considering the answer seems to be around 1e15 it should be doable to do one iteration in a few weeks towards the end
>>
File: sddefault.jpg (53 KB, 640x480)
53 KB
53 KB JPG
broot bros don't give up. the computer part store is just around the corner
>>
File: Capture.png (532 KB, 674x405)
532 KB
532 KB PNG
Guys. I am leaving my sorted rocks here for a while, just going to take a shit. Please look after them.
>>
>>103479473
look up what LRU means, it's shocking
>>
File: carbon.png (234 KB, 680x1795)
234 KB
234 KB PNG
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
11 00:38:27 8309 0 00:48:46 3978 0

Oh my god I'm retarded it was just lanternfish but easier
>>
that took me way too long

// setup
let nums = text.match(/(\d+)/g).map(x => parseInt(x));
let map = {};
let silver = 0;
let gold = 0;

// get next generation
let getNext = x => {
if (x == 0) return [1];
let sx = x.toString();
if (sx.length % 2 == 0) {
return [
parseInt(sx.substr(0, sx.length/2)),
parseInt(sx.substr(sx.length/2))
];
}
return [x * 2024];
};

// count numbers from x at generation
let count = (x, gen) => {
if (!map[x]) map[x] = {0: 1};
if (map[x][gen]) return map[x][gen];
let n = 0;
let next = getNext(x);
next.forEach(x1 => n += count(x1, gen-1));
map[x][gen] = n;
return n;
};

// get parts
nums.forEach(x => {
silver += count(x, 25);
gold += count(x, 75);
});

console.log(silver, gold);
>>
>>103479364
1764528406...3915461808
>>
>>103479476
Ah, this worked.

>>103479477
Good to know. Thanks bros.
>>
File: carbon.png (90 KB, 529x771)
90 KB
90 KB PNG
>>103479485
after 5 minutes of cleaning
>>
>>103479364
7.134017253309601e+270
>>
>finished day 1-11
>only 8 gold stars on my ascii calendar
ERIC!
>>
>>103479411
Yeah I think that would be possible
So the real bigboy should be doing 10^20 iterations or something
>>
>>103478396
based
>>
>>103479475
I am still mad that Swift won't let me hash a tuple and I have to define a hashable struct instead.
>>
>>103479498
>that one mini star
the fuck?
>>
File: 1704912890124130.png (501 KB, 1822x1950)
501 KB
501 KB PNG
>>103479187
And for completeness, here's the SML solution.
Threading the memorization data structure through all calls is such a chore, do I really have to become a Haskell monad autist to do this in a pure functional way without all this bullshit?
>>
>>103479505
literally ruined
this is scandalous
>>
>>103479506
>memorization data structure
GOOD MORNING SIR
>>
File: file.png (93 KB, 504x598)
93 KB
93 KB PNG
>>103479505
>>103479512
>they don't have aoc++
>>
File: file.png (1.21 MB, 679x1131)
1.21 MB
1.21 MB PNG
Calendar image should really be some variation of this

Ill try and think of something funny to edit onto it
>>
>>103478671
checked boomer
>>
>>103479515
>you made a typo so you are Indian
???
>>
so was that the memoisation problem for the year?
>>
File: day11_recursive.png (101 KB, 829x539)
101 KB
101 KB PNG
>>103479453
Here's the recursive version which now works, but I gave up on earlier due to issues with lru_cache. Even though this is still lightning fast, it's 50% slower than the dict approach. Sad!
>>
File: uhh.png (107 KB, 633x436)
107 KB
107 KB PNG
>>103479517
uhh, guys?
>>
>>103479504
>Can't hash a tuple
>Can only implicit return if the statement is just one line, so no bindings allowed
>So slow, it feels like I'm running this program on my 2007 Sony Vaio. The only way to make it somewhat faster is to use LibC and pointers.
>Stdlib is somehow bloated and absolutely worthless at the same time
>Have to plug unsafe everywhere since Swift 6 came out and safetytroons ruined everything
>And many more
It's just not fun
>>
Brootbros. I coded up a dfs that wont crash, but according to my calculations it will finish in about 13.2995 years. What should I do while I wait?
>>
>>103479525
does keeping a map of counts vs building the whole array counts as memoisation?
This does not feel like a DP problem. We will still get one.
>>
>>103479538
kek
>>
File: carbon (2).png (486 KB, 1814x2086)
486 KB
486 KB PNG
>HashMap throws concurrent modification
>ConcurrentHashMap throws recursive modification
>only working map impl required comparable keys
Okay, Java, whatever you say
>>
File: pp.jpg (24 KB, 475x478)
24 KB
24 KB JPG
reminder that this:

>20 82084 1650 3 346355 363 7975858 0

is eric's intellectual property. DO NOT STEAL IT.
>>
>>103479547
Just make a new hashmap every step
>>
File: file.png (142 KB, 665x514)
142 KB
142 KB PNG
>>103479538
not what I got
>>
>>103479539
>Can't hash a tuple
that seems lame.

noob question. Is there a difference between a struct/tuple in swift?
Can you hash a struct?
eg:
struct {
x int
y int
}
>>
>>103479552
what did eric mean by this?
>>
File: 1724431905585665.png (60 KB, 726x681)
60 KB
60 KB PNG
>tfw just realized this
>>
>>103479562
>2
what's the significance?
>>
>>103479547
writing and testing multithreaded java is awful, i don't even bother nowadays

>>103479539
rust doesn't have these problems
>>
File: day11.png (86 KB, 749x802)
86 KB
86 KB PNG
day11
194557 231532558973909
took 31455 μs (aoc_2024::day11::solve)

feels like this day would allow for some nice bigboys. log(2024)/log(10)=3.306.. is close enough to 3 so the numbers should not blow up too much.
>>
>>103479538
based
>>
File: zig.png (791 KB, 1502x3072)
791 KB
791 KB PNG
zig. Easiest DP problem ever, and part2 simplified my code, because it revealed that the stones-have-to-stay-in-order requirement was meaningless.
>>
my god I'm retarded. I spent 20 minutes debugging the memoisation solution since it was returning a wrong value for the example but I was sending the actual input and it was doing it right all along.
That plus not understanding a compiler error were the biggest problems today
>>
File: day11.png (42 KB, 696x431)
42 KB
42 KB PNG
BQN day 11
>>
>>103479556
AFAIK in memory they are the same, but
Struct can conform to protocols (interfaces), including Hashable. If every member of the structure is Hashable, then it's as simple as slapping : Hashable on the declaration, like
struct PooInLoo: Hashable {
var x: Int // Already Hashable by default
var y: Int // Already Hashable by default
}

With tuples you can even do something like this, and it's literally the same as a struct
typealias PooInLoo = (x: Int, y: Int)

But they can't conform to shit, because reasons, gay niggers and "think different"
>>103479569
Maybe it's the time to learn Rust, unironically
>>
>>103479590
What was the compiler error?
>>
>>103479540
what is the MINIMUM required amount of memoization for this problem? I am trying to come up with a brootchad solution that will actually give an answer in a few hours, but all the solutions I come up with solve the problem too easily and make it no longer a broot.
>>
>>103479601
just boot up your galaxy sized computer
>>
>>103479601
You don't need memoization at all.

See:
>>103479453
>>
>>103479596
I see. That is definitely a choice regarding not hashable tuples (stupid) even if each member is hashable. ty
>>
File: carbon.png (242 KB, 1042x1436)
242 KB
242 KB PNG
First day I had to take some time to wrap my head around, turns out it wasn't that tricky!
>>
>>103479607
I know, thats how I solved it. I am trying to come up with a funny broot solution that is good enough to return an answer by tomorrow, but bad enough to spend a few hours number crunching. Then I can post the 5h execution time and say BROOTCHADS WE WON. It will be very funny.
>>
>>103479547
>Java
Found your problem
>>
>>103479597
something about hashmap mutable reference not satisfying the trait bound to be used inside a function. Turns out, I was specifying the hashmap wrong (HashMap<(i64, i64), i64> vs HashMap<(i64, i64), i64, i64>).
The Rust compiler has been quite annoying in a couple of parts here, but I guess it's no worse than any C++ error involving templates. Still, nothing beats the simple errors of C (or maybe I'm too used to them, idk)
>>
>>103479630
I only specify types if I absolutely have to and when it requires annotation then I'll just copy paste what it's the error if I can. If you're the anon that's always naming types they don't have to, then that's probably why you're running into more annoying errors

I programmed in C for a long time and C errors weren't great until more recent clang compilers but by then I'd already switched to Rust
>>
>>103479306
It's unwashed, I find that ugly too. Will wash it later. Post yours.
>>
File: day11-mathematica.png (55 KB, 1032x913)
55 KB
55 KB PNG
Easy once you see what's going on, but it was fun to solve. Short input, so thought I'd include that in my screenshot, just for you Eric.
>>
File: 2024.11.gif (29 KB, 945x602)
29 KB
29 KB GIF
C++ 23
>>
>>103479667
lol. One map and just compound key the rock number with the iter count?
smort
>>
ok bigboy test of today: 500k blinks on example input. Prove your language isn't worthless trash
>>
so since i had to memoize the second part, should i just replace my pt1 solution with the memoized version too? or keep the broot to pay tribute to my fallen comrades?
>>
>>103479453
Nice, that's some actual dynamic programming.
>>
>>103479681
which example input? there is 2.
>>
>>103479684
? thats just a map.
>>
>>103479687
the only one where he gives you the solution in it's own little box you stupid fucking retard
>>
File: 24_D11_C#.png (606 KB, 2312x2792)
606 KB
606 KB PNG
c#
>>
JUST NOW FINISHED
ugh, that was EASY
but I spent so long because I didn't realize that what the bottom-most layer turns into doesn't matter, only its length. and then only the length has to be sent up the recursive chain.
I thought for sure it was some sort of, cellular automata "find the cycles/patterns" sort of problem. I had gotten out MS Paint and started drawing the trees that 8 turns into, what 2 turns into, trying to figure out how I would calculate all the cycles at the end...
>>
>>103479695
>more than one example in the text
>picks one that conforms to my world view
>retard
well. I liked the first one because there is no little box.
>>
>>103479681
md5sum with on number + new line:
5760fbb34272fe1de13c497cb561b91f  -
>>
I remembered my fish buckets.
I was expecting "their order is preserved" to be important but it wasn't.
>>
File: spam.png (24 KB, 1750x137)
24 KB
24 KB PNG
>>103479364
>Error: Our system thinks your post is spam. Please reformat and try again.
>>
>>103479707
WHEN YOU'RE NOT PERFORMING YOUR DUTIES DO THEY KEEP YOU IN A LITTLE BOX? CELLS.
>>
>>103479692
Dp is when you fill a table using already filled values from the table. This does just that bht since only the previous row and the row that we are filling matters it doesn't store the others. Also it's better to store it like a map in this case rather than a vector as it's difficult/inconvenient/unnecessary to compute some upper bound before just to do it with vectors.
>>
Ok I know I'm supposed to do memoization but what am I memoing? if I see a rock that i've seen before, how does knowing what it turns into next round help when I need to know what it turns into 75 blinks later? I can't just store its number of rocks value, because then I cant use that next round
>>
>>103479732
Don't store rock values. Turn the number of rocks it turns into.
>>
>>103479692
retards think everything that uses a map is dynamic programming
>>
>>103479737
>Turn the number
*Store the number
>>
>>103479742
>everything that reuses previously calculated values is dynamic programming
FTFY.
>>
>>103479364
0ms
RecursionError: maximum recursion depth exceeded
>>
>>103479732
Every time you encounter a rock of size n, memoize that it turns into zero rocks after zero blinks, one or two rocks after one blink, etc.

So apply_blinks(n=55, blinks=2) turns into 2 rocks. Memorize that. In the process you'll get to memorize that apply_blinks(n=5, blinks=1) turns into one rock.
>>
>>103479742
My illiterate friend, I just explained here
>>103479728
Think before you type
>>
>>103479758
I see.
everyday has been some DP problem. We have been summing values for results quite a lot.
I feel like a DP-pro now.
>>
File: memoiso.png (17 KB, 490x428)
17 KB
17 KB PNG
>>103479576
>stones-have-to-stay-in-order requirement was meaningless.
That's not the kind of game I signed up for either.
>>
>>103479774
you're exactly the kind of retard i'm talking about
>>
>>103479783
>DP-pro
Like mother like son.
>>
>>103479783
It's the same thing as OOP retards who say everything is OOP but when it's a bad characteristic then "it's not real OOP!"

DP is a completely nonsense term that applies to anything you want it to apply to. It's meaningless but most midwit CS idiots take pride in it
https://en.wikipedia.org/wiki/Dynamic_programming#History_of_the_name

>The 1950s were not good years for mathematical research. We had a very interesting gentleman in Washington named Wilson. He was Secretary of Defense, and he actually had a pathological fear and hatred of the word "research". I'm not using the term lightly; I'm using it precisely. His face would suffuse, he would turn red, and he would get violent if people used the term research in his presence. You can imagine how he felt, then, about the term mathematical. The RAND Corporation was employed by the Air Force, and the Air Force had Wilson as its boss, essentially. Hence, I felt I had to do something to shield Wilson and the Air Force from the fact that I was really doing mathematics inside the RAND Corporation. What title, what name, could I choose? In the first place I was interested in planning, in decision making, in thinking. But planning, is not a good word for various reasons. I decided therefore to use the word "programming". I wanted to get across the idea that this was dynamic, this was multistage, this was time-varying. I thought, let's kill two birds with one stone. Let's take a word that has an absolutely precise meaning, namely dynamic, in the classical physical sense. It also has a very interesting property as an adjective, and that is it's impossible to use the word dynamic in a pejorative sense. Try thinking of some combination that will possibly give it a pejorative meaning. It's impossible. Thus, I thought dynamic programming was a good name. It was something not even a Congressman could object to. So I used it as an umbrella for my activities.
>>
>>103479788
So define DP then oh knows-it-all. Bet you didn't even read Competitive Programming 3
>>
>>103479788
Do you know the difference between a bottom-up and top-down approach to dynamic programming?
>>
>>103479576
>>103479787
I wonder if that was a red herring he put in for LLMs
>>
>>103479799
Ah interesting.
>>
>>103479805
> has no argument so I appeal to some random text
>>
>>103479732
The non-memoization answer is actually easier. Just note that all 2-rock will turn into same amount of rocks after 75 iterations. Why store multiple 2-rocks in your array?
>>
>>103479732
For each stone number store how many stones it will be after 1-75 blinks.
>>
>>103479829
You are a drooling retard. I gave you a clear explanation and you refused to provide a counter argument. Your last post is literal projection.
>>
>>103479814
He's trying to get his birds to fledge.
>>
Anybody else going further?
(Stolen from plebbit)

Input: 125 17
Modulus: 10^9

Blinks | Stones
-------|----------
0 | 2
1 | 3
25 | 55312
75 | 38650482
10^2 | 486382721
10^16 | 519885608
10^100 | 180213553
>>
>>103479799
Pretty sure I learned in college that dynamic programming is when you break a big problem into smaller problems.

Not sure how people are getting memoization or hash maps out of this
>>
>>103479647
the error in particular was me specifying it in the function declaration, which is required iirc. Otherwise I just let the compiler infer whatever
>>
>>103479844
Isn't that just common sense?
>>
>>103479838
YOU are avoiding my arguments by just mentioning unrelated points.
Not sure if you cant read.
>>
>>103479852
Ah, that makes sense. It's easy to mess that up, or in the return part
>>
>>103479844
>Not sure how people are getting memoization or hash maps out of this
because those smaller problems you broke it down into are things that get repeated many times across the bigger problem
you break it into smaller problems that get memoized to prevent needing to calculate the same thing repeatedly
>>
>>103479844
Also one must not solve the same smaller problem more than once, so results must be stored somewhere. A grid cell, a hash map, etc.
>>
>>103479843
This seems like a problem that you can boil down to a math equation and get very close to O(1)
>>
>>103479869
i doubt you can because of the rule where you split the number in the middle
>>
>>103478401
>his stenchbox can't into AV1
>>
>>103479805
I re-evaluated the problem and determined I was wrong. The solution using a map is a form of dynamic programming.
>>
>>103479869
I have it down to O(log(n)) time, albeit with a big enough constant that it doesn't save any time on the actual part 1 and part 2. Not sure how to take it down any further.
>>
>>103479873
>>103479892

pre-calculate all of that to a set of known transformations. for example single digit numbers.

so for example f(0) maps to [2,0,4,8] in 4 cycles. do that for each number. Something something sum from 0 to infinity mumble mumble f(x)^n
>>
>>103479895
>just solve the problem
>>
>>103479272
brootbros... we lost
>>
>>103479888
checked

>>103479869
>>103479873
Mathchads is this true? Does your whole discipline fall apart as soon as you have to manipulate numbers as strings of digits?
>>
>>103479902
there are people smarter than me itt they will figure it out. Where are all the graph cycle autists from day 5?
>>
>>103479831
and how will you find how many rocks 2 rocks becomes after 75 blinks?
>>
>>103479909
anyone crying about the cycle for day 5 is actually dumb, topological sort worked fine but you needed to do it by query not universally
nothing about the problem even suggested no cycles across all pages
>>
>>103479909
>>103479907
Mathchads solve the problem and bounce. They're on to the next problem (counting their money), they're not hanging around debating the definition of DP.
>>
>>103479895
Yep, I'm taking a transition matrix and raising it to a power mod N, but exponentiation by squaring is still logarithmic in N. I don't think there's a way around that - maybe you could get O(log(log(n)) with mumble mumble multiplicative order mumble, but probably not O(1).
>>
>>103479912
You run all the iterations for one of the 2 rocks
>>
>>103479907
I think it's the "length divisible by 2" part that can't be converted into pure math
if you had a stone like
12345678
you could do something like take the log10, divide it by 2 to get n, then divide the stone by 10^n to get just 1234.5678, then grab the int and fractional parts separately
>>
>>103479927
ok but regardless. The numbers form cycles today. Find the cycles, solve the problem in O(1). Am I wrong?
>>
>>103479949
so precalculate the answer and then only time your solution after you did all the work?
>>
File: cga_2_pepe.gif (2 KB, 320x200)
2 KB
2 KB GIF
>>103479272
Anon, you will need 1040TB of memory, if you don't have that much just give up.
>>
>>103479956
also known as memoization :^)

You would just have to do the work to get your input to your precalced magic cycle numbers, which wouldn't take too long, maybe a few hundred broot iterations or whatever.
>>
>>103479895
Previous years have had a problem that needed something like that where the period is too long to get directly, but the pieces have shorter cycles and the overall period is the LCM of the pieces.
>>
>>103479895
You traverse the graph and calculate all stone sizes you'll see and transitions. Than make a matrix of the state transition. Then you can use matrix exponentiation to advance any number of steps in logarithmic time.
>>
File: carbon(55).png (229 KB, 1168x1132)
229 KB
229 KB PNG
I wrote this three different ways today trying to get the memorization to work, and finally converted it back to functools
>>
>>103479949
even if we do call your precalculation o("1"), it only works for trivial cases where you have a low number input
if I give you 5555555555, you're saying you'll have a lookup table for whatever cycle it is a part of?
>>
File: comfyyoshi3.png (720 KB, 768x768)
720 KB
720 KB PNG
>>103479912
Been comparing different approaches in Python.

Recursive is the classic top-down dynamic programming a la fibonacci (f(x) = f(x-1) + f(x-2)): >>103479533

Dict is using a counter to bulk-update stones with the same number, seen here >>103479453

Bottom-up builds a lookup table for the stones, starting from one blink, using earlier entries in the table to quickly build later entries.

Hybrid combines bottom-up with the dict approach.

Run 1: blinks = 75
Recursive took 0.1547 seconds
Dict approach took 0.0959 seconds
Bottom-up DP took 0.1269 seconds
Hybrid approach took 0.0498 seconds

Run 2: blinks = 250
Recursive took 1.7706 seconds
Dict approach took 0.5660 seconds
Bottom-up DP took 0.3513 seconds
Hybrid approach took 0.3217 seconds

Run 3: blinks = 500
Recursive took 3.6984 seconds
Dict approach took 1.2229 seconds
Bottom-up DP took 0.6933 seconds
Hybrid approach took 0.7098 seconds

Run 4: blinks = 1000
Recursive took 8.7698 seconds
Dict approach took 2.5459 seconds
Bottom-up DP took 1.5315 seconds
Hybrid approach took 1.5209 seconds
>>
There's a similar problem from 2015 where you can calculate the sizes by a transition table.
https://en.wikipedia.org/wiki/Look-and-say_sequence. I'll play around later to see if this can be done that way.
>>
>>103479965
that is literally the memoization answer
>>
>>103479989
uhh sweaty stop recycling my banger posts mmkay? >>103479433
>>
File: 1703313215735226.png (55 KB, 1745x988)
55 KB
55 KB PNG
somewhere my dictionary has gone astray....
>>
>>103479292
nigger, sub 40s on the leaderboard is extremely doable for someone that does programming puzzles all day and that is exactly how they do it, everything is muscle memory, this is a classic day 8-12 dp problem and they're all pretty similar in execution
>>
File: GeZXy94WYAAsxC8.jpg (74 KB, 720x919)
74 KB
74 KB JPG
bigboy #11
url: http://0x0.st/Xh3u.txt
stones: 100K
silver: 5399449821
gold: 6446795110566618681
>>
>>103479930
>Mathchads solve the problem and bounce
You're confusing them with engineers.
There was a joke about this:
>An engineer is working at his desk in his office. His cigarette falls off the desk into the wastebasket, causing the papers within to burst into flames. The engineer looks around, sees a fire extinguisher, grabs it, puts out the flames, and goes back to work.

>A physicist is working at his desk in another office and the same thing happens. He looks at the fire, looks at the fire extinguisher, and thinks "Fire requires fuel plus oxygen plus heat. The fire extinguisher will remove both the oxygen and the heat in the wastebasket. Ergo, no fire." He grabs the extinguisher, puts out the flames, and goes back to work.

>A mathematician is working at his desk in another office and the same thing happens. He looks at the fire, looks at the fire extinguisher, and thinks for a minute, says "Ah! A solution exists!" and goes back to work.

>>103479949
There are O(1) solutions, but they all boil down to reading the answer precalculated by Eric.
Everything else is at least O(logN) to read the input.
>>
File: 2024_11_zig.png (7 KB, 525x266)
7 KB
7 KB PNG
Zig solution using integers only and log10
>>
>>103479813
nta but i know all about bottom-up approaches
>>
Desperately don't feel like doing this tonight. Is it going to end up being math bullshit that you either know or don't, or is the gimmick that you cache a stone's multiplying rate and then look ahead?
>>
>>103479949
>Am I wrong?
Yes
>>
File: file.png (54 KB, 671x622)
54 KB
54 KB PNG
>>103480033
~600ms in python

I think if you really want to strain the algorithms you gotta increase depth as well
>>
File: 1733903245884.jpg (467 KB, 1080x1057)
467 KB
467 KB JPG
>>103479932
Yeah anon i think you are right because
>mfw i realize I've basically been trying to solve the collatz conjecture for an hour and I'm a fucking RETARD
>>
>>103480033
my solution
>>103480037
takes 72ms on my x230
>>
File: dayeleven.png (366 KB, 1292x1678)
366 KB
366 KB PNG
>>103480033
200ms ez
>>
>>103480057
can't change problem description
plus it overflows
>>
>>103479966
that tetris block falling one was fun. drop 100 blocks. now drop 2022 blocks something like that
>>
>>103480033
30ms on>>103479576, though hardcoding the input
>>103479595's bqn does it in 164ms
your gold answer needs 63 bits of precision, too much for 64-bit floats
>>
File: Screenshot.png (269 KB, 1727x1253)
269 KB
269 KB PNG
>>103480033
~80ms in C
>>
>>103479576
Dp brainlet here. How would you solve the problem if the stones actually did need to stay in order?
>>
>>103480114
you don't
>>
>>103480114
>How would you solve the problem if the stones actually did need to stay in order?
You would need to factor in the function that calculates the end result.
>>
>>103480122
Order doesn't matter.
>>
>>103480114
my DP solution does that by iterating through the stones in order

you start by expanding the first stone, depth-first all the way down until you have the first stone in the final list
then you go back up a layer and move over one, repeat ad infinitum and the end result will be in the correct order
>>
>>103480131
learn to read retard
>>
>>103480131
>But I had breakfast this morning.
>>
>>103480131
>but i did eat breakfast
Shut up nigger I am trying to learn
>>
>>103480134
it'd still complicate caching if a stone's position figured into the result
>>
>>103480134
do you not run out of memory?
How do you keep the stone number and the position in memory for so many stones?
unless you just 'stream' it
>>
File: split.png (129 KB, 902x632)
129 KB
129 KB PNG
>>103479907
Still working on my solution, but integer length can be calculated with floor(log10(number)) + 1, so you just check if that %2 == 0.


On another note, here is a sample in Squirrel of how to take a number and split it in half using only math and no string manipulation. In my solution, to prevent numbers from getting too big I store them as base * (2024^x), but that's just because my numbers keep overflowing to inf after a while, and you can check how many digits it WILL have after multiplying two numbers with floor(log10(x) + log10(y)) + 1.

Still need to add some memoization, going to be moderately annoying but I'll figure it out.
>>
>>103480134
I must be missing something here, because I tried coding a broot solution like this and it would take 100 years to finish.
>>
>>103480150
cont.
or you just keep the count and move on. but then the order does not matter again.
>>
>>103480139
>>103480138
>>103480136
You're all niggers. Order just has no relevance. Keep it or don't keep it, the problem is the same.
>>
>>103480156
(that comment should say run only on even-digit numbers, oops!)
>>
>>103480134
you're gonna be storing massive amounts of lists in your memo table, no chance this would work
>>
>>103480164
>>103480114
>>
>>103480156
>>103479907
see my solution
>>103480037
>>
on another note. How the fuck did we go from hiking with reindeer to a story of fucking pluto?
I am missing something here in the story.
>>
>>103480190
there's a story?
>>
>>103480190
did you miss when we traveled back in time 500 years too?
>>
>>103480197
yes I missed that.
>>
File: d11.png (428 KB, 1492x2774)
428 KB
428 KB PNG
It's clear Eric is taking it easy this year.
>>
>>103480164
>Order just has no relevance. Keep it or don't keep it, the problem is the same.
The original function was just counting
return stones.length


The new function is a hash function
result = 0
for stone in stones:
result = (result * 11 + stone) % 13
return result

You claim that the problem is the same even if the order needs to be keeped.
Provide your solution.
>>
>>103480033
82ms average using C++
>>
>correct answer on test data
>incorrect answer on input data
bros...
>>
File: xarbon.png (8 KB, 356x484)
8 KB
8 KB PNG
washed ass
>>
>>103480270
What integer type are you using?
>>
File: file.png (28 KB, 599x391)
28 KB
28 KB PNG
>>103479973
>>
>>103480274
Evidently my language allows somewhere around 128 bit integers, so it shouldn't be a problem. I don't get it, really
>>
My inefficient DP solution for 2015 day 19 part 2 just finished running and it gave me the correct answer.
$ time pypy main.py < inp.txt
200

real 407m12,541s
user 309m50,296s
sys 0m12,087s
>>
>>103480304
based 7 hour broot
>>
>>103480314
It's not broot, that would have never finished lol. The universe would cease to exist sooner.
>>
File: avatar_M17_C1_A5_P7.png (640 KB, 1080x1080)
640 KB
640 KB PNG
>>103480110
would you explain the cache function please?
>>
i got the first tier of day 11 in js
>ez
at a depth of 25 it took maybe 10 seconds to run
i then took the next step and increased the limit to 75. it started coming to a halt around 30.
i decided to take up go lang and hated it
the snowflake syntax
javascript lets me program however tf i want
go REFUSED TO COMPILE because i declared a variable and didn't use it
it's cucked
the compiler decided that my code wasn't production ready...i should've gone with my initial instinct to find a performant js compiler (nonexistent?) to just copypasta my code verbatim
i just gave up after
append(slice, strconv.Atoi(str[0:half]), strconv.Atoi(str[half:length]))
refused to compile
in order to parse a string i can GUARANTEE TO BE PARSEABLE INTO AN INT BECAUSE OF THE WAY THE PROGRAM IS STRUCTURED I NEED TO CREATE TWO VARIABLES ONE FOR AN ERROR THAT WILL NEVER OCCUR AND ANOTHER TO HOLD A VARIABLE THAT WILL BE INITIATED INTO A TEMPORARY ARRAY TO BE CONCATONATED WITH ANOTHER TEMPORARY ARRAY
i would be okayer with this if i could theoretically manage memory...create some kind of function for zipping arrays together and clearing the temporaries. it would be extra effort and force me to learn something. but golang is GC. it's like hey this is how we pitched the language, it's a critical feature to justify our existence so we'll just fking force anyone using this trash tier meme language to DROWN in unnecessary variables. I WRITE FUNCTIONAL JAVASCRIPT. I LIKE AVOIDING SIDE EFFECTS.
>low level
it's low IQ corporate dogwater
and i had confidence bc i downloaded version 1.23.4 and numerology is kawaii desu
>>
File: solve.png (644 KB, 5546x3452)
644 KB
644 KB PNG
idiomatic Rust solution
>>
>>103480324
it's just a bare-bones hashmap. See the static big array at the top? cache() maps keys to indexes of that array.
>>
>>103480335
Why are you typing like a troon?
>>
>>103480339
okok thanks anon, clean code have you any reading material you would advise me to read to improve in c?
>>
>>103480335
actually can't really knock the gc bc maybe the compiler does a wonderful job analyzing variable useage, it's possible
otherwise, continued:
>low level
inundated with semantics
>low level
>garbage collected
>ishygddt
>prevents me from shooting myself in the foot by shooting me in the face
https://www.youtube.com/watch?v=aHk42kDwesM
i am writing a stacking/floating window manager in javascript
computers are meant to enable logic
from a UX perspective. not even programming.
so when i start programming i should be able to do literally anything.
i know one of the devs of go was a prominent figure in early language development. rob pike?
i have to 2 theories as to what happened. either the guy is a total imposter...make that 3 theories...
or he made go as a massive middle finger to google. like he just collected a paycheck from a corporation.
3) his wife and children were held hostage until he endorsed an actual turd
4) backend developer is a euphemism for taking things up the rear and bondage is necessary for developing for servers

>>103480337
maybe i should've gone with rust but as a cyclist (steel is real) i really hate rust. also the game is cringe / autism.
another rant incoming
3 reasons rust is a terrible name for a programming language
1) oxidization bad
2) rust the videogame was released literally 2 years before the programming language or something
>gotta adlib the 3rd rzn
3) mozilla

>>103480353
why do you have my dick up your ass?
>>
>>103480364
>why do you have my dick up your ass
The fact that I'm writing this proves I don't as anyone who even touches your infected body instantly dies from aids
>>
>>103480364
>so when i start programming i should be able to do literally anything.

seems like the compiler will disagree with you there bud
>>
>>103480337
insert_entry is completely new to me, damn i could've used that before
>>
>>103480337
oh you are still here. Did you overslept today? I was starting to get worried.
>>
>>103480403
I had some issues with my LLM today
>>
>>103480301
Language?
>>
>>103480414
Squirrel. I think I figured out the problem. Give me a bit
>>
>>103480353
tripfag, enough said
>>
>>103480413
:( I am sorry
>>
File: incomplete.png (13 KB, 1267x50)
13 KB
13 KB PNG
What causes this?
>>
>>103480380
bro you have good grammar but your mind is hideous
crazy you go online to type like a fucking bot

>>103480387
which is why Go can Go fuck itself
>>
>>103480335
>>103480364
Okay tranny
If you don't know what dynamic programming is you're extremely retarded and shouldn't do coding puzzles as they clearly don't fall into your area of expertise (cutting your dick off)
That being said it's blatantly obvious you came here from either troonsky or plebbit or both, so please go back there.
>>
File: 1707265711827048.png (336 KB, 1584x2888)
336 KB
336 KB PNG
Here's the math way
Build a graph of all transitions
Use it to create a transition matrix
Take the transition matrix to the power of the number of steps
Multiply the initial state by the transition matrix
import numpy as np
from scipy import sparse
import sys


def parse(stones):
seen = set()
s = stones.copy()
transitions = {}
while s:
cur = s.pop()
if cur in seen:
continue
seen.add(cur)
if cur == 0:
transitions[(cur, 1)] = 1
s.append(1)
elif len(str(cur)) % 2 == 0:
first = int(str(cur)[: len(str(cur)) // 2])
second = int(str(cur)[len(str(cur)) // 2 :])
if first == second:
transitions[(cur, first)] = 2
s.append(first)
else:
transitions[(cur, first)] = 1
transitions[(cur, second)] = 1
s.append(first)
s.append(second)
else:
transitions[(cur, cur * 2024)] = 1
s.append(cur * 2024)

dim = len(transitions)
indices = {e: i for i, e in enumerate(seen)}
transition_matrix = np.zeros((dim, dim), dtype=int)
for (i, j), v in transitions.items():
transition_matrix[indices[i], indices[j]] = v

original_state = np.zeros(dim, dtype=int)
for s in stones:
original_state[indices[s]] += 1

return sparse.csr_matrix(transition_matrix), sparse.csr_matrix(original_state)


def main():
file_name = sys.argv[1]
stones = list(map(int, open(file_name).read().strip().split()))
transition_matrix, original_state = parse(stones)
for p in 25, 75:
print((original_state @ sparse.linalg.matrix_power(transition_matrix, p)).sum())


if __name__ == "__main__":
main()
>>
this one is just a replication similar to previous years problems.
>>
File: carbon(11).png (991 KB, 1750x982)
991 KB
991 KB PNG
Haskell.
I really thought some form of memoization would be necessary. Glad this simple approach worked.
>>
>>103480337
stupid question. this does a normal dfs with memoisation for <stonenumber, time>: <count>
?
would that not cause you to calculate a lot more state than if you just use a map of stonenumber:prevcount.
And each iteration work out the next state map?

While recursing you might get <5,10>:N but also <5,6>:O, you already computer 5 for a number larger than 6, but in your case you will calculate it again?
Or I am just reading the code wrong and is stupid.
>>
>>103480459
I'm heterosexual
stop projecting faggot
>>103480459
kill yourself noob

my experience with Go is that it is insanely static with useless conventions for people who need a language to tell them how to think

I understand the software I write

I'm assuming you don't are some software hipster that dickrides Go => Learn some manners and maybe you'll finally be able to socialize with an actual human.

>>103480459
>pounding your retarded bussy
>>103480459
>not actually
>>103480459
>because
>>103480459
>i'm straight
>>103480459
>stop @ing me
>up (you)rs
>>
eric has actually given up now right
>>
>>103480512
beautiful
>>
>>103480504
the story this year is remembering all the places from previous years, make sense that the problems are the same.
lazy eric
>>
>>103480529
nah, I think this style of problem has appeared every, at least since I started doing aoc.
>>
>>103480519
so what language do you use then?
>>
>>103480519
>Go
You just named a random language and hope I use it? I don't get your argument, I barely even understand it as your English is very bad.
I know and use regularly C, C++ and Python.
And you're not denying you're a tripfag and also probably have severe mental illness based on your post(s).
Both facts make it more probable that you came here from groomsky or plebbit so I ask you once again to go back.
Also I can easily solve 2400 rated problems on Codeforces, I'm definitely not a noob. But keep on projecting.
>>
>>103480588
>Also I can easily solve 2400 rated problems on Codeforces
wew lad
>>
>>103480033
150ms with pypy
from collections import defaultdict, Counter
import sys

stones = list(map(int, open(sys.argv[1]).read().strip().split()))
sd = Counter(stones)
for i in range(75):
if i == 25:
print(sum(sd.values()))
news = defaultdict(int)
for s, v in sd.items():
if s == 0:
news[1] += v
elif len(str(s)) % 2 == 0:
news[int(str(s)[: len(str(s)) // 2])] += v
news[int(str(s)[len(str(s)) // 2 :])] += v
else:
news[s * 2024] += v
sd = news


print(sum(sd.values()))
>>
Haskell
import qualified Data.Map as M

solve1 xs = length $ iterate (concatMap blink) xs !! 25

solve2 xs = sum $ M.elems $ iterate loop m0 !! 75
where loop m = M.fromListWith (+) [ (y, n) | (x,n) <- M.assocs m, y <- blink x ]
m0 = M.fromList $ zipWith (,) xs $ repeat 1

blink 0 = [1]
blink x = case splitDigits x of
Just (x,y) -> [x,y]
Nothing -> [x * 2024]

splitDigits x
| even n = let (xs1, xs2) = splitAt (n `div` 2) xs in Just (read xs1, read xs2)
| otherwise = Nothing
where n = length xs
xs = show x

main = do xs <- map read . words <$> readFile "input"
print $ solve1 xs
print $ solve2 xs
>>
File: day11washed.png (375 KB, 1860x2867)
375 KB
375 KB PNG
Optimized Modern C++ with double-buffering hashmaps

>>103480033
40ms bottom-up, 80ms top-down. I could make it faster by handwriting assembly to count digits, but that's not Modern C++

>>103480110
not modern enough

>>103479667
modern enough, although nested ternaries are unreadable

not seeing too many C/C++ chads right now, where are you bros?
>>
File: d11.png (1.06 MB, 2192x1320)
1.06 MB
1.06 MB PNG
Simple clojure solution
>>
>>103480488
nice, that's pretty cool anon
>>
>>103480414
Turns out Squirrel cannot handle big numbers, at all. It approximates them. Fuck, have to use Python for today. There goes my 100% squirrel streak
>>
File: 1pp3tKL.jpg (161 KB, 736x1024)
161 KB
161 KB JPG
>>103480488
woaw, I solved it but this is the first time I will be copying someone else's code to study. gj anon
>>
>>103480707
Does it only use floats?
>>
>>103480488
based
>>
>>103480748
When it gets beyond a certain point it starts estimating numbers with exponents/decimals so it stops being precise. I did not know this and wasted ~3-4 hours trying to figure out why it wasn't working.
>>
>>103480707
Can always do your own bignum if you really care
It's not too bad to just have high bits/low bits and double the precision for arithmetic
>>
File: aoc24_11.png (199 KB, 718x1734)
199 KB
199 KB PNG
Neat
>>
File: day11Clojure.png (148 KB, 997x916)
148 KB
148 KB PNG
>2021976
thanks for the hint, Eric. I got to redo one of my favorite puzzles from years ago, almost as if it were the first time.

>>103479383
you don't really need memoization for this, in fact memoization makes my solution slower, see pic. Maybe it would be different if I were to build a custom memoization cache thingy instead of using Clojure's built-in, but eh, 190ms for part 2 on a potato is fast enough for me.
>>
>>No matter how the stones change, their order is preserved, and they stay on their perfectly straight line.

>actually, order is completely irrelevant

i thought part 2 would introduce a rule that takes neighbours into account but no, just exploding fish 2.0, good thing i learned from my mistakes
>>
>>103480779
Yeah, I solved part 1 by constructing the list first, then scrapped everything when I saw part 2.
>>
>fuck up memoization problems last year
>fuck them up this year
will I ever understand?
>>
>>103480755
Rough.
>>
>>103480755
These are the kinds of bugs that I thank Zig for helping me avoid, even though I have to put up with the asanine @intCast(@as(u32, i)) shit.
But I recently discovered there is spooky lossyCast function in the standard library :^)
>>
File: silver.png (52 KB, 618x433)
52 KB
52 KB PNG
>>103480790
yeah same here, picrelated

>>103480793
see >>103480763
it's not really a memoization problem unless you want it to be. The key insight is that the stones will only be in so many different states, and it's enough to keep track of how many stones of any given kind there are.

By the end of 75 iterations, my stones have taken on only 3743 unique numbers, which is nothing for a computer with 16 gigabytes of ram.
>>
>>103480837
This is a nice approach, I will implement it. Thanks for sharing.
>>
>>103479984
interesting
>>
>>103480335
>unused variables
Just don't leave unused variables? Why do you care about this so much? You can use _ if you don't care about a function's return value.

>I need to create two variables when a function returns two values
No you don't but if you really want to chain functions together, just create a generic Must function that acts as a wrapper around functions that can err. It's simple and idiomatic.

>Low level, garbage collected
It's only low level in the sense that it compiles down to binaries. Originally it was intended to be non-gc but its concurrency model requires gc and that was deemed more important in the end.

Tbh Go should be seen as a higher-level GCed C with first-class support for concurrency, it's kinda barebones by design. It's not a great language for AOC style puzzles because it's not super expressive like python or JavaScript. Instead it mostly shines when used for networking related small-mid sized projects. Check out Protohackers if you a programming puzzle series that Go is excellent for.
>>
File: 1723637331585410.png (144 KB, 335x506)
144 KB
144 KB PNG
>>103480488
I kneel
>>
If the stones were unique in some way (say they were multiplied by a random 256-bit hash instead of 2024) where would you need to go to solve it? Random university, top research lab, top government lab?
>>
Does a 0 stone take up any space?
>>
>say the order of the stones matters
>it doesn't
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
>>
>>103480924
Nice try, CIA.
>>
File: 1708479462395390.png (1.35 MB, 889x2000)
1.35 MB
1.35 MB PNG
lol, can't believe this actually worked
>>
File: 2024-12-11_10-37.png (206 KB, 1582x1138)
206 KB
206 KB PNG
corejavabros, we just can't stop winning

>>103480033
ez
>>
>>103480033
see >>103480949
5399449821
6446795110566618681

real 0m0.029s
user 0m0.029s
sys 0m0.000s
>>
>>103480958
>strings
>>
File: day-11 (1).png (1.34 MB, 2080x3292)
1.34 MB
1.34 MB PNG
awk without recursion
>>
File: Day11.png (84 KB, 748x749)
84 KB
84 KB PNG
C#. Can't wait to see how many people get filtered by this absurdly simple memoization task.
>>
FUCK I got filtered
God do I hate dp
>>
>>103480995
>memoization
Bottom-up dp is faster and superior
>>
brootbros...
>>
>>103481023
just wait strong.
IT
WILL
FINISH
>>
>>103481023
Only need a petabyte of RAM/swap
>>
File: 1728546700842817.png (42 KB, 700x285)
42 KB
42 KB PNG
>>103481023
>>
>>103479667
>C++23
>Uses no C++23 features

>>103480643
>Still using streams to print
>>
File: 2024-12-11_10-56.png (199 KB, 1585x1176)
199 KB
199 KB PNG
>>103480976
turns out string is usually as fast on the JVM; was surprised too, but it is
anyways, here's my gift to you so you can relax about it
>>
File: day11washedmoderner.png (360 KB, 1860x2763)
360 KB
360 KB PNG
>>103481041
thanks for reminding me to update my compiler, i hate windows so much it's unreal
>>
>>103478145
stop leaking AoC++ hints
>>
>>103479547
Map#computeIfAbsent(k, F:k->v) evaluates F(k) inline of the modification
so if F(k) itself modifies the map (which it does due to recursion here), you are indeed modifying the map in a recursive call while modifying it in the parent, ergo concurrentmodificationexception

I don't like it very much either, but that's why, and why I ended up splitting the contains/put in my solution at >>103481069

>>103479569
>writing and testing multithreaded java is awful
not true btw, it's surprisingly decent for concurrent code writing/debugging
this case is merely that the API doesn't make it very obvious if F(k) is evaluated before or during modification
>>
>>103479869
>very close to O(1)
what the hell are you babbling about? what does "very close" mean? is O(1.03) very close? retard
>>
>>103480488
So if I want to know how many stones there will be after blinking once I have to build two massive matrices that will be mostly useless since transitions that will actually happen << number of all possible transitions?
Absolutely awful.
>>
File: solve_iterative.png (522 KB, 5386x2802)
522 KB
522 KB PNG
idiomatic Rust solution

>>103480033
9.3ms
>>
>>103481183
>this case is merely that the API doesn't make it very obvious if F(k) is evaluated before or during modification
I will add that both options would have made sense for implementers to pick
- if before: you avoid concurrent modification in a few cases
- if during: you get these concurrent modifications, but in the case of a thread-safe map (ie ConcurrentHashMap) you can rely on modifications happening in parallel, avoiding a couple of TOCTOU type issues
tradeoffs
>>
File: carbon.png (617 KB, 1592x2750)
617 KB
617 KB PNG
>>103480033
day 11                  time:   [3.3873 ms 3.3957 ms 3.4047 ms]
Bigboy/day 11 bigboy time: [9.8883 ms 9.9119 ms 9.9369 ms]
change: [-99.444% -99.442% -99.441%] (p = 0.00 < 0.05)
Performance has improved.

>Performance has improved.
My bigboy took 600ms+ and kept returning the same wrong answer. I spent past 30 minutes debugging this and I finally realised I used the day 1 bigboy as my input... Big worri
I guess bigboy doesn't take much longer because all the numbers loop and get cached eventually. Larger number of blinks shouldn't change much either, except for requiring bigints.
>>
time on bigboy for 10k blinks?

36322
[...] truncated because of retard spam blocker
7125
pypy3 aoc11.py < input/aoc11.bb 6.53s user 0.12s system 98% cpu 6.775 total
>>
>>
File: day11-mtx-mathematica.png (128 KB, 1270x2340)
128 KB
128 KB PNG
>>103480488
Neat. Sadly wasn't too performant compared to the memorization version. Here's my rushed implementation. Sorting the transitions made the picture prettier.
>>
>>103481239
oh i see you changed from recursive dfs to bottom-up.
>>
another victory for bruteforcechads
long live the code runtime
>>
File: plotConvBS2.png (49 KB, 1000x671)
49 KB
49 KB PNG
Today I won't overthink this and join the bruteforce ranks, I thought.
>>
>>103481351
just in time for aoc2025
>>
>>103481354
wait im retarded, i confused total with next step lol
just in time for aoc 2035 i guess
>>
>>103481354
Add at least 10 years.
>>
>>103481183
>ergo concurrentmodificationexception
I know why it happens, just annoyed that there's only one standard implementation I could find that supports recursive modification
I implemented the memoization by hand like you did for my submitted solution because I didn't find ConcurrentSkipListMap on the clock
>>
>>103481351
if it's just the retarded bruteforce the vector for the last iteration would take up like 2 petabytes
>>
We’re losing a lot of the meme langs.
>No Excel
>No Gameboy
>Assembly bros?
>The LLMS dropped recently.
>And today, the brooters.
>>
>>103481384
good
>>
>>103481384
>>No Gameboy
It's coming.
>>
>>103481384
And the calendar bro is filtered.
(not talking about you 'idiomatic' rust guy)
>>
File: idiomatic_calendar.png (2.87 MB, 9857x4112)
2.87 MB
2.87 MB PNG
>>103481410
>>
File: idiomatictrash.jpg (280 KB, 800x1137)
280 KB
280 KB JPG
>>103481415
>>
>>103481410
I told you yesterday that I'm still here, it's updated up to day 9
how about someone makes OCs for day 10 and 11
>>
>>103481446
I will try and make OC. give me a few mins
>>
File: Untitled.jpg (59 KB, 598x417)
59 KB
59 KB JPG
>>103481446
Ok here is my idea. the execution could be improved
>>
filter coming tomorrow
>>
>>103481445
good riddance
>>
File: juden.png (53 KB, 718x957)
53 KB
53 KB PNG
>>103481446
did you put this in it
>>
NEW THREAD
>>103481467
>>103481467
>>103481467



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