[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: 1764580836705340.jpg (75 KB, 720x960)
75 KB
75 KB JPG
modulo 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:
224303-2c132471
anonymous-only leaderboard:
383378-dd1e2041

Previous thread: >>107379367
>>
File: codeimage-snippet_1.png (74 KB, 679x424)
74 KB
74 KB PNG
bigboy: >>107391620
gn lads
>>
>>107391931
what did you use to take a code image?
>>
>>107391939
code image: https://codeimage.dev/
>>
File: AoC-01.png (70 KB, 741x799)
70 KB
70 KB PNG
Absolutely awful code. I need to finish adjusting my sleep schedule from staying up late for EC to getting up early for AoC.
>>
File: day1_revised.png (497 KB, 622x503)
497 KB
497 KB PNG
i made some adjustments
>>
File: 1.png (626 KB, 5546x2412)
626 KB
626 KB PNG
idiomatic Rust solution
>>
>>107391931
>gold doesn't fit in a double
bruh
>>
>>107392012
why the hell are you using floating point?
>>
Ok, penis check. Take your pants off.
>>
File: AoC Stars.png (44 KB, 357x544)
44 KB
44 KB PNG
Finally finished up 2024.
>>
>>107392025
I am not wearing pants.
>>
File: image.png (17 KB, 808x39)
17 KB
17 KB PNG
The first day ... is strong
>>
>>107391298
Optimized mine(>>107391311).
https://fi.c99.st/5jy6081e.c

clang with O3
real    0m0.082s
user 0m0.078s
sys 0m0.004s
>>
>>107392075
He didn't put any good test cases in the sample and people are too lazy to write their own. I almost got filtered by my programmer brain expecting to count transitions instead of landing on 0. It's a good sign I think, hope this is a good year.
>>
>>107392075
>People are actually filtered by a modulo
We are so doomed
>>
d1 think I found a compiler bug in futhark
>>
>>107392122
it's not just a modulo
there was already a modulo in part 1
it was just very tricky
>>
I'm adding some golds when I shouldn't be adding some golds. Not cool.
>>
>>107391999
Cute anal.
>>
Since there's only 12 days of problems this year, I wonder how much of a difficulty spike will it be tomorrow. Grids? Dynamic programming? Reading comprehension?
>>
>>107392001
Fails with the bigboy: >>107391620

This C code works:
#include<stdio.h>
typedef unsigned long long N;
int main() {
N silver = 0, gold = 0, g = 0, dial = 50, n = {};
const N max = 10'000'000'000'000'000'000ull;
for (int left = {}, c; (c = getchar()) > 0;)
(unsigned)c - '0' <= 9 ?
n *= 10, n += c - '0' :
c == '\n' ?
gold += n / 100u, n %= 100u,
gold += dial && (left ? dial <= n : dial + n >= 100),
gold >= max && (gold -= max, ++g),
dial += left ? 100 - n : n, dial %= 100u,
silver += dial == 0 :
(n = 0, left = c == 'L');
printf("%llu\n%llu%llu", silver, g, gold);
}
>>
File: AoC_day1.rs.png (1.77 MB, 1024x1024)
1.77 MB
1.77 MB PNG
>>
>>107392191
Of course it fails with this bigboy because you need at least 76 bit to store the part 2 result.
dumb retard.
>>
>>107392211
bigboy needing bigint is always dumb
you are just testing your bigint library at that point
>>
>>107392211
You are going to break down internet again with that attitude.
>>
Can somebody send me the text of the challenges so I can violate the wittle faggot who doesn't want them reposted?
>>
>12 days
actually based. I waste so much time on this shit every year
>>
>>107392001
what the fuck is that anon you're getting btfo in idiomatic-ness. lock in before you crash out
>>
File: 1647423589157.jpg (121 KB, 750x715)
121 KB
121 KB JPG
>>107392243
I dont want to get /marked/ by eric by sharing my input
>>
>>107392243
Forwarded your IP to Eric, your life is over kiddo
>>
Yeah part 2 is filtering my simpleton solution, landing on exactly zero is causing issues.
>>
>>107392291
it is day 1 you can allow yourself an if statement
>>
File: day 1.png (53 KB, 649x695)
53 KB
53 KB PNG
I don't want to think too deeply or too long about this useless problem.
>>
File: day01emu.webm (77 KB, 598x519)
77 KB
77 KB WEBM
A couple of dumb mistakes held me up a little bit.
>>
File: aoc2025-01.png (99 KB, 468x889)
99 KB
99 KB PNG
My what a pain
I should have just iterated each click
>>
File: 20251201_194519601.webm (1.09 MB, 853x480)
1.09 MB
1.09 MB WEBM
>>107392330
Of course it runs on hardware.
>>
>>107392400
based
>>
>>107392306
I instead implemented it in a retardproof way (loop that adds/subs 1 and checks if %100 is 0) and turns out I was 3 off in my initial solution.
>>
>>107392408
>turns out I was 3 off in my initial solution
same, 3 too high
>>
File: day01.png (2.89 MB, 4899x5256)
2.89 MB
2.89 MB PNG
>>107392400
Here is the full assembly.
The actual solution code is from Run_solution to Menu_return, and I'll only post that section from day 2 onward.
>>
>>107392466
And I don't want anyone on my case about looping subtracting 100 for the gold part. Division takes 36 cycles while basically every other operation aside from multiplication is a single cycle, plus the EE is dual issue, so the values need to be consistently above 1000 or something to be faster doing division.
>>
>>107392488
>Division takes 36 cycles
even integer division?
>>
>>107392466
This is super cool! Do you have a github or socials anywhere or do you just post these here?
>>
@grok,
scan this thread
>>
File: carbon.png (397 KB, 1028x2424)
397 KB
397 KB PNG
I hate it
>>
File: ps2ww.png (105 KB, 1358x788)
105 KB
105 KB PNG
>>107392504
Actually it was 37 cycles, and yes.
Floating point division is actually faster, at 8 cycles, but I'd also have to do a conversion to get the remainder out which would take some more cycles.
>>
>we're rushing this year and starting on day 13 difficulty
ugh
>>
>>107392541
https://en.wikipedia.org/wiki/Division_algorithm#Division_by_a_constant
>>
+/0=100|+\50,diffs(¨1¨raw)×1+¯2×'L'=⊃¨raw⊃NGET'1.in'1
>>
>>107392581
It is like day 4 difficulty, it is easy, just kinda ugly. I wanted to say it is day 1 tier, but day 1 can be just parsing.
>>
File: code.png (233 KB, 1542x1242)
233 KB
233 KB PNG
WASHED ASS
i figured out how to do it the nice way with maths so im now satisfied
>>
>>107392330
I kneel
How long did this take you? I want to do something like this but with 2 kids under 3 years old right now I am resigned to using Python for now.
>>
File: carbon.png (592 KB, 1732x2606)
592 KB
592 KB PNG
>wake up four hours late
>poop, eat something
>carefully read all of Eric's flavour text
>spend an hour doing it the hard way
Ahh, I missed this time of year
>>
File: day01bbemu.webm (69 KB, 600x517)
69 KB
69 KB WEBM
>>107391209
Of course, once all the values are in the 1 billion range, using div makes a lot more sense.
>>
>>107392611
Getting the solution running took a couple hours, but getting the template ready took about half a year.
I was stuck on reading controller input for months.
>>
In C this is just
#include <stdio.h>
int
main(void) {
char lr;
int silver, gold, x, n;
silver = gold = 0;
x = 50;
while (scanf("%c%d ", &lr, &n) == 2) {
x = x ? (lr == 'L' ? 100-x + n : x+n) : n;
gold += x/100;
x %= 100;
if (!x)
silver++;
else if (lr == 'L')
x = 100-x;
}
printf("%d\n%d\n", silver, gold);
}
>>
>>107392700
ok, but there are no silver stars
>>
>>107392243
sent :^)
>>
>>107392355
What's the deal with the apostrophes?
>>
File: file.png (10 KB, 208x319)
10 KB
10 KB PNG
>>107392054
Nice work anon
I finally cleaned up the last few puzzles I had left yesterday

>>107392122
It genuinely took me 2 hours to fix all the edge cases in my mathy solution.
Today was a midwit trap, where the smart solution will send you straight to the pits of off-by-one+edge case hell and completes instantly, while the grug broot solution is trivial to shit out in like 3 minutes flat and also completes instantly.
>>
>>107392755
Part of the variable names
Variables in F# are usually immutable, so for example I'll use the name pos as the original variable, and pos' for the updated one to be used in the next iteration
>>
>>107392824
Looks like brootchads won once again
>>
>>107392611
>>107392673
I would say, if you want to try then start with a console that uses tiles.
Something like the SNES would be much easier to get started with than newer consoles. NES is pretty easy to get stuff displaying, but being 8 bit and only having three registers makes solutions very verbose.
GBA had a lot of registers and was still tile based, it was pretty easy to get going last year.
>>
File: out.png (84 KB, 1920x1080)
84 KB
84 KB PNG
>>107391909
I made it analog lel
>>
>>107391909
>one bigboy requires bignum
>the other gives wrong answer with brute force solution
let's try again
https://gofile.io/d/5ZvkyQ
99755/611023275013
>>
do it in assembly, COBOL
>>
>>107392963
>7z
nice virus
>>
>>107393057
it's the tradition here
linuxfags don't like rar/zip
winfags don't like gz/xz/etc.
>>
>>107392911
true brute forcer. now let's see a bigboy
>>107392963
I get the same values
>brute force gives wrong answer
really? that doesn't make sense
>>
>>107392755
academic tardism
>>
>>107393075
>linuxfags don't like rar/zip
zip is fine
>it's the tradition here
kys
>>
>>107393134
it won't change just because one tranny said so
>>
>>107393151
>it won't change just because one tranny said so
you have been told to use something since the beginning. your constant refusal doesn't make it a tradition


Literally no one will complain about zip files but you insist on using a vulnerable format for no valid reason.

go post malware somewhere else nigger
Why are
>>
>>107393299
>reddit spacing
didn't even read
>>
>>107393338
funny how you have no good justification for using .7z
>>
>>107393349
touch grass
>>
>>107393361
Oh look, another vulnerability 7z that is just 1 WEEK OLD.

https://nvd.nist.gov/vuln/detail/CVE-2025-11001
This vulnerability allows remote attackers to execute arbitrary code on affected installations of 7-Zip.
>>
i can't do the KJ12 big boy, im getting 8.807909812247263e+21
>>
>>107393411
filtered
>>
>>107393422
i am for the big boy, im doing a loop for each rotation in the line for part 2 :p
>>
File: 1764594819474.jpg (169 KB, 904x864)
169 KB
169 KB JPG
>To play, please identify yourself via one of these services:
>>
>>107393400
>yet another AI-generated nothingburger
>>
File: kys.png (289 KB, 390x512)
289 KB
289 KB PNG
>>107393443
>>
i'm starting to not like doing this in JS, i want to be able to bruteforce big boys, is Go fast enough or do i need to go for something like c++?
>>
>>107393459
just use Rust, it's basically JS according to geets
>>
>>107393447
why are you lying, glowie?

https://www.cve.org/CVERecord?id=CVE-2025-11001
>severity HIGH
>Remote Code Execution
>>
File: file.png (297 KB, 1360x2738)
297 KB
297 KB PNG
Weren't we supposed to get cooler problems now that there are only 12 days?
>>
>>107393481
>https://www.cve.org/CVERecord?id=CVE-2025-11001
how is this any different from your other link rajesh?
>>
File: 1761274271394477.png (677 KB, 2526x3756)
677 KB
677 KB PNG
i dont know if the bigboy would ever finish with my code
>>
>>107393400
>in a zip file
So not .7z
>>
File: 1757708221525189.png (46 KB, 1606x287)
46 KB
46 KB PNG
im FOOOOOLDING
>>
>>107393541
>if the file name ends with .7z the file can't contain a zip archive
>>
>>107393400
Also,
>fixed in v25.0
So fixed 5 MONTHS AGO.
>>
>>107393559
>one RCE was fixed so that means there aren't others
>>
>>107393481
>Remote Code Execution
If you actually read it, it's a path traversal issue. It is not RCE within 7zip, IDK why they'd dilute the term by labeling it like that.
It's patched either way.
>>
>>107393515
How is cve.org AI generated slop, glowie?
>>
>>107393568
There are always other RCEs, no matter what the software.
But you're not complaining about fixed and undiscovered RCEs in other software. Why are you hyper focused on 7-zip?
>>
>>107393582
>no matter what the software
not in software written in Rust
>>
>>107393483
The statement was that the difficulty curve will change to match the 12 days.
Obviously the first day is still going to be piss easy.
>>
>>107393597
Rust does not protect against logic errors.
Not every RCE is memory corruption.
>>
>>107393616
cope
>>
>>107393625
I accept your concession.
>>
>>107393625
7z it is then
no one else is against it
>>
>>107393649
>everyone disagreeing with me is the same person
>>
>realised ive been using the wrong hotkey for years and running my code with debugger attached when i never used the debugger
>takes like 3 times as long to startup/run
all those wasted seconds...
>>
>>107393649
>7zip
>for a singular text file
why are big boy posters so fucking stupid?
>>
>>107393669
lmao
>>
>>107393400
does anyone know if these CVEs apply to Windows 11 or libarchive?
Windows since like, inception has its own 7zip (un)archiver but you can only use it from explorer shell with the new dogshit context menu. I know Windows also ships with bsdtar + libarchive. wonder if the context menu uses that for making 7z's.

for Linux users, I wouldn't touch p7zip with a 10 ft pole, should just use libarchive.
>>
>>107392963
>wget link
>try and uncompress it
>html file
can you please use a file share that isn't shit or a direct link at least?
>>
>>107393400
what is this report?
where is the affected .dll
it's always some 3rd party dll
fucking hell
>>
>>107393717
0x0.st doesn't work and catbox is too slow
where else would you like it?
>>
>>107393654
>>everyone
One person complaining about 7z.
>>
>>107393753
I complain, I just don't care. I think it's retarded. just do file.txt.zst....
>>
>>107393733
>0x0.st doesn't work
skill issue—I just uploaded this: https://0x0.st/KJOY.mp4
>>
>>107392963
>611023275013
I get 611023275274...
>>
>>107393765
>>
File: skill issue.png (89 KB, 1528x1093)
89 KB
89 KB PNG
>>107393778
skill issue
>>
>>107393778
anon... your shit may be broke. corporate spyware device?
>>
>>107393793
gofile it is then
>>
>>107393805
nigga... you might want to figure out why your shit is broke.
>>
any haskellfrens here to show me some cool haskell tricks for this one?
>>
>>107393766
can anyone share their regular inputs? mine works for the example & actual input but I'm not sure if I'm doing something wrong here.
>>
>>107393858
>can anyone share their regular inputs?
sry, that's not allowed
>>
>>107393858
https://files.catbox.moe/3wndfi.txt
1059/6305
>>
>>107392075
Do AIs struggle with edge cases?
People shouldn't have that much problem with this.
>>
>>107393582
>Why are you hyper focused on 7-zip?
Because it's more vulnerable than others.

Why are you refusing to use .zip files?
>>
>>107393882
spooky. perhaps I didn't get the same edge cases as you guys.
>>
>>107393649
who is against .zip besides you? or .tar.gz for that matter?
>>
>>107393887
Gpt-5 solved it on second try after I pointed out that actual answer is different.
>>
>>107393888
>>107393897
samefag btw.
since there is only one person against 7z, I'll continue to use 7z. thanks for your input.
>>
>>107393895
show code?
>>
>>107393882
I got 6312 btw. so that's funny. my maffs must be off.
>>
>>107393908
yes both are me but I'm not the only one

WHO IS AGAINT ZIP FILES MOTHERFUCKER?
>>
>>107393926
I do euclidean division for part 2 and just add the result

(dial + rot [neg for left]) `euclid_div` 100
>>
>>107393935
oh and the absolute value of the div... forgot that part.
>>
>>107393908
>since there is only one person against 7z,
you are the only person pro 7z
>>
>>107393935
yeah, that's wrong
>>
>The puzzles still start on December 1st so that the day numbers make sense (Day 1 = Dec 1), and puzzles come out every day (ending mid-December)
What a clown show
>>
File: file.png (62 KB, 1200x960)
62 KB
62 KB PNG
If Eric gives us half as many problems...
>>
>>107393960
I can't see how though. at least I can't construct a counter-example. whatever. I'll revisit it later. allegedly I have my stars so fuck it.
>>
File: file.png (76 KB, 1200x960)
76 KB
76 KB PNG
I'll have to draw twice as many girls.
>>
>>107394086
L50
L100

part 1: 2
part 2: 2
>>
>>107392963
part1: 99755
part2: 611023275013

real 0m0.196s
user 0m0.192s
sys 0m0.004s


>>107393717
https://fi.c99.st/7fvrd7m5.txt.7z
>>
>>107394208
>.7z
nice virus
>>
>>107394208
give us a token anon
>>
Anyone else glanced at the example, saw L99, and ASSUMED all input is in range 1..99? (kinda makes sense for real world safe with dial combination lock).
>>
>code been running for 2 hours on the big boy

guess ill skip it
>>
>>107392963
>>107394208
I extracted and uploaded it uncompressed: https://0x0.st/KJW6.txt
>>
>>107394076
>>107394087
based drawanon
>>
>>107394340
>.txt
nice virus
>>
>>107394340
what's the solution?
>>
>>107394373
Only if you use C to parSegmentation fault (core dumped)
>>
>>107394247
Contact admin via XMPP.
>>
File: Untitled.png (187 KB, 1032x1000)
187 KB
187 KB PNG
>>107391298
Silver: 40254
Gold: 21475708151366

Performance counter stats for './1 ../../../inputs/1/bigboy.txt' (500 runs):

30,214,262 user_time ( +- 0.01% )
1,403,598 system_time ( +- 0.22% )
118,274,388 cycles:u ( +- 0.03% )

0.0316698 +- 0.0000168 seconds time elapsed ( +- 0.05% )


>>107391620
Silver: 257513
Gold: 49952593196376656314868

Performance counter stats for './1 ../../../inputs/1/bigboy2.txt' (500 runs):

16,774,271 user_time ( +- 0.01% )
746,568 system_time ( +- 0.32% )
65,326,236 cycles:u ( +- 0.04% )

0.0175513 +- 0.0000104 seconds time elapsed ( +- 0.06% )
>>
Anybody got links to the thread archives of previous years? I never get around to doing AoC while it's running, but I enjoy the communal aspect of it
>>
>>107394434
Easy enough to just search /aocg/ on desuarchive.org (or any other archive or your choice). Every one since it started in 2017 is there.
For the last few years an anon has also been aggregating thread IDs so it's easy to jump back to the beginning from any thread you find.
>>
>>107393842
fugg I coulda used divMod :DDD
>>
>>107394471
>Every one since it started in 2017 is there
It started in 2015 but I don't think it was discussed here before 2017.
>>
>>107394434
>>107394471
https://desuarchive.org/g/search/subject/%2Faocg%2F/type/op/
desuarchive is shitting itself at the moment so you may need to reload it a couple times to get results
>>107394500
AFAIK a few people did it in 2015/2016 in other programming threads, but it didn't really become a thing on /g/ until 2017.
>>
>>107394434
>archive
Every year I have participated it has basically been the same thing.
>time to get filtered
>Rockefeller Street
>FUCK FUCK
>I just bruteforced it
>>bruteforcing X problem
>edgecase is not in the example
>idiomatic rust code
>bigboy
>>.7z virus
>Is bigboy wrong?
>PS2/Console Anon
>calendar image
>>
>>107394471
>>107394434
Just a heads up, desuarchive seems to be down for queries at the moment
>>
>>107394527
rust didnt exist in 2015/16/17
>>
>>107394532
Refresh and it will work eventualy
>>
>>107394537
https://blog.rust-lang.org/2015/05/15/Rust-1.0/
>>
>>107394545
nobody used it on /g/ before they got USAID money for propaganda
>>
>>107394562
I used it on 8/tech/
>>
File: 1755915051714840.png (715 KB, 2727x3420)
715 KB
715 KB PNG
>>107393532
bigboy runs correctly now
(i cheated by asking the AI to explain me the math on how to get rid of the 2x loops)
>>
ElvishSafe elvishSafe = ElvishSafe.factory().notchCount(100).initalPosition(50).build();

GUYS AM I ON THE RIGHT TRACK?
THANKS GREG
>>
>>107391909
Can I learn code by using this with only very rudimentary knowledge of coding?
>>
>>107394654
no
>>
>>107394654
yes
>>
Abysmal dogshit. Tomorrow I'm doing it in PHP.
>>
>>107394654
maybe
>>
>>107393842
>>107394479
I can't seem to make the lambda for p2 not uggo...
whatever at least it completes the bigboy :DD
p1, p2 :: [Int] -> Int
p1 = length . filter (==0) . scanl (flip mod 100 .: (+)) 50
p2 = fst . foldl' (\(n,a) b -> first ((n+) . abs) $ (a + b) `divMod` 100) (0,50)
>>
>>107394340
thanks anon
>>
>day 1
>thread already dead
>>
>>107394527
i started the pooing meme and it wasnt forced i just really had to poop that time
>>
>>107395158
9-5 people doing 9-5 things
>>
>>107394087
>only 1 star in backpack

did elf-chan get filtered already?
>>
>>107395158
Anon, this problem is pretty basic.
>>
File: img-2025-12-01-17-23-04.png (373 KB, 1000x920)
373 KB
373 KB PNG
>>107395181
>usa is the only country
>>
>>107395246
why is uk utc and france utc+1 if they're on the same vertical line? who's the retard?
>>
>>107395246
yes, it's 17:27 in my timezone
if I do outdoor activity after work, then I start aoc around 19 or 20
>>
>>107395271
>who's the retard?
you are
https://en.wikipedia.org/wiki/Time_in_the_United_Kingdom
https://en.wikipedia.org/wiki/Time_in_France
>>
nothing crazy. I got lazy with counting the overflows for part2 and just did it with +1 -1 step, still finishes immediately but I can theoretically get fucked by bigboy massive numbers
>>
>>107395298
>int

ngmi
>>
Can someone explain what bigboy is?
>>
>>107395376
no
>>
>>107395376
bigger, better, badder inputs designed to filter slow solutions.
>>
>>107395407
and where do I find them?
>>
>>107395376
missed edge case? YOU'RE GETTING EXPOSED
O(retard) complexity? YOU'RE GETTING EXPOSED
>>
>>107395418
you have to buy aoc++
>>
>>107395355
yeah I suppose. maybe I should just start to always use int64_t instead of only when it fails. gonna save me some debugging
>>
>>107395246
I start AOC at 06:00 local time (UTC+1), and I assume other anons do as well. There is not much to talk about after the inevitable bigboy discussion is over.
>>
>>107395441
the answer to smallboy is 75 digits
>>
>>107395444
cope—in the past we managed to fill up 5 threads on day 1
>>
>>107395481
I feel like every year there has been
>thread already dead
post
>>
>>107395418
ctrl+f bigboy
>>
Am I retarded; what am I doing wrong?

BEGIN { FS = "L|R"; a = 50 }

{
c = /R/ ? 1 : -1
b = a+c*$2
if((b<0 && a) || b>100) {
p2 += int(b/100) * (b>0 ? 1 : -1) + (b>0 ? 0 : 1)
}
a = (b+100)%100
}

!a { p1++ }

END { print("Part 1: " p1 "\nPart 2: " p1+p2) }


I'm not doing any fancy algorithm bullshit; I'm literally just storing the value in an accumulator and doing the basic checks from the problem. I have no idea why I'm messing up.
>>
>>107395555
>what am I doing wrong?
using awk
>>
>>107395555
No clue what your code is doing but b>100 looks sus since the dial goes from 0 through 99, excluding 100 as well.
>>
>>107395598
I'm counting 100 as zero, since it just gets zeroed out in the modulo step, so that shouldn't matter.
>>
>>107395650
it's wrong though
>>
>>107395555
you are using runes instead of a programming language
>>
>>107395673
Well, changing it to 99 gives me a ton of false positives, so I know that's not it.
>>
>>107395555
>
a = (b+100)%100

Why the +100? 100%100 is 0. You are also removing from p2 if it goes backwards. Like L1000 would be -10. Why?
>>
>>107395690
ok, sounds like your input is bugged then. write eric an email.
>>
>>107395555
> a = (b+100)%100
 a = (b%100)+100%100
>>
File: 1742748357230006.png (26 KB, 556x258)
26 KB
26 KB PNG
First time programming in clojure. Managed to get the first part done, now I'm going to cry for a bit before attempting part 2
>>
>>107395185
she's brooting part 2
>>
>>107395704
>>107395718
AWK was being retarded and adding 100 was the only way to get the mod operator to behave.
>>
>>107395841
it's not the modulus operator
>>
>>107394076
>>107394087
Seriously the drawfags are the only reason I bother coming back to this thread anymore... thanks anon.
>>
>>107391620
My unwashed code id decent I think
resultA: 257513
resultB: 49952593196376656314868

real 0m0,247s
user 0m0,218s
sys 0m0,029s
>>
File: carbon.png (279 KB, 1228x1974)
279 KB
279 KB PNG
brought shame and dishonor to my ancestors by bruteforcing. please forgive me.
>>
>>107396022
there are no silver stars
>>
>>107396033
I think Cornelius would disagree.
>>
File: 1.png (111 KB, 695x968)
111 KB
111 KB PNG
>>107395555
it's easier than that
>>107392963
$ time awk -f 1.awk bigboy.txt
99755 611023275013

real 0m12.177s
user 0m11.970s
sys 0m0.075s
$
>>
>>107395555
Fixed it; I'm an idiot. Rewrote it in C and it's working fine.

behold the power of the pentium
>>
File: 1752039401400643.png (10 KB, 234x127)
10 KB
10 KB PNG
>>107396033
>
>>
>>107396098
cool. how come pythonistas never post time?
>>
>>107395704
many languages handle % operator as remainder after division, not modulo. difference is with negative numbers

-1 % 100 is -1 because -1/100==0
you achieve modulo with
((n % base) - base) % base
or conditions.
last time I benchmarked, conditions are faster than second modulo
>>
File: img-2025-12-01-18-37-10.png (177 KB, 5072x408)
177 KB
177 KB PNG
>>107396204
>Collect stars by solving puzzles. Two puzzles will be made available on each day; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!
>>
>>107396221
>pythonistas

there are no women here
>>
File: b3yjmeemwg391.jpg (67 KB, 636x445)
67 KB
67 KB JPG
>>107392113
no you're just a jeet larping
>>
>>107396221
i dont care about bigboys, im on winblows so dont have a convenient command to time things, timing competitions are pointless anyway because most of the time its just whoever has a faster pc or is using the faster language
>>
>>107396328
>dont have a convenient command to time things

you're just a jeetard

 Measure-Command { ./file.exe | Out-Default } | Select-Object TotalSeconds, TotalMilliseconds   
Measure-Command { ./file.exe | Out-Default }


>B-but it's verbos..
retard, you can make an alias for it called time
>>
>>107396351
blaming people for not knowing about the obscure commands windows does its best to hide away from its users and make inaccessible is pretty low
>>
>>107396351
there's a lot going on on windows at all times there's no point in measuring commands
>>
>>107396351
alright here you go then:
part A 99755
part B 611023275013

TotalSeconds : 8.2263073
TotalMilliseconds : 8226.3073
>>
>>107396430
>8.23s
holy shit, of course you were reluctant to time it
>>
File: 1740671245844295.png (640 KB, 680x1069)
640 KB
640 KB PNG
>>107396430
bhaaaaaaaaaaaaaaaaaaaaahahahahhaha
>>
>>107396445
it's good enough for python
>>
>>107396445
my algorithm is close to optimal, thats python and large file reading
>>
File: 1741594844948267.png (138 KB, 1104x1243)
138 KB
138 KB PNG
>>
>>107396468
that's the wrong bigboy
>>
>>107396445
>>107396454
To be fair, windows anons may have shitty antivirus causing them process spawning penalty on top of the fact that process spawning in general is retardedly slow compared to Linux anyway.
>>
>>107396480
>windows defender is responsible for 8s
cope
>>
>>107396479
what's the correct one?
>>
>>107396461
no it's not, my js and python solutions run in 300ms
>>
>>107396499
bullshit you run the bigboy in 300ms including file reading/parsing
>>
>>107396504
yes, including reading/parsing, are you indian by chance?
>>
>>107396515
retard
>>
>>107396494
>>107392963
>>
>>107396553
>babyboy to fit the cniles

wrong one
>>
>>107396430
completely optimized one timings:
part A 99755
part B 611023275013
Execution time: Parsing 3258.236 ms, solving 3296.981 ms

TotalSeconds : 6.7566261
TotalMilliseconds : 6756.6261

so just parsing it takes up a massive chunk of the time, as well as general overhead which is not insignificant
>>
File: 1734778106530812.png (29 KB, 729x248)
29 KB
29 KB PNG
>>107396553
>>107396479
>>
>>107396595
257513
49952593196376656314868

TotalSeconds TotalMilliseconds
------------ -----------------
0.56 562.30


its means your code is shit
>>
>>107396618
>not even the same bigboy
get lost retard
>>
bigboys that are just testing your io/speed or bignum library are never really particularly interesting

hopefuly we will get some brootebuckling bigboys the coming days
>>
>>107396670
literally does not make a difference, how mentally deficient are you? they're the same size
>>
>>107396491
at work, Avecto + Forcepoint + whatever other dogshit is an easy +2 seconds.... I am not even joking.
>>
File: carbon-2.png (77 KB, 1498x588)
77 KB
77 KB PNG
sorry I'm late

been working on an optimizing bytecode compiler for slouch. Compiler optimizations are really satisfying to implement! Hopefully this will make slouch viable for more brute-force problems.
>>
>>107396860
beautiful
>>
>>107396860
sexy language. what is this?!?
>>
>>107396860
gorgest
>>
>one thread per day
where did everyone go
>>
>>107396699
nah, the other will take longer
>>
>>107397027
https://github.com/lukechampine/slouch
>>
>>107397069
looks fun
keep it up
>>
File: full retard.jpg (79 KB, 640x733)
79 KB
79 KB JPG
my modulo code did not work for part two
embarrassing
>>
First time participant, it took around 80 minutes and I have a longer & worse solution than anyone ITT. That second question threw me for a loop because I didn't realize not all cases were covered by the example data.
>>
>>107397222
just bruteforce it as first solution, it shouldnt take you that long, then when you got the stars you can spend time doing other strategies
>>
>no global ranks
>only 12 days
>/g/ leaderboard not even close to full, fewer participants than ever
>slow threads
aoc feels so soulless and dead this year
>>
>>107397258
Yeah, I'll try that next time. I just realized I've pretty much written it like I would at my day job.
>>
File: 1762210885976152.png (306 KB, 1024x259)
306 KB
306 KB PNG
Idiomatic Nim
>>
>>107397524
>n.floormod(100)
>>
>>107397536
what about it
>>
>>107397544
oh I thought you were avoiding brackets
>>
>>107397559
Right I missed that one, thanks.
>>
it's only 12 days, so the great filter will arrive at days 4-6
>>
>>107397050
I guess the change to 12 days killed the hype.
>>
>>107396860
do llms handle slouch or do they have a melty
>>
>>107397580
>>107397050
Traffic on the entire board is halved vs last year..
>>
>>107397639
I wonder why....
>>
>>107397639
so im not the only one that noticed that, sometimes you can go some fat few minutes even on pol before anyone makes a post/reply, let alone on this board
>>
realizing now that a good deal of my confusion on this was because i thought the test input on part 2 was supposed to be 9, not 6, meaning my code actually isn't passing the test. guess my dumb ass is dyslexic now
>>
File: G54zK1vWoAANJZ2.jpg (176 KB, 1486x1520)
176 KB
176 KB JPG
>>107397619
I wondered the same thing recently! Claude one-shotted it no problem, GPT struggled and produced invalid code ‾\_(ツ)_/‾
>>
>>107397559
>>107397561 (Me)
Fun thing about it is, I'm learning so much about the syntax rules, and how sometimes this freeform syntax doesn't mix well with certain kinds of statements.

It might be intuitive to say "var x = floormod 100, 10", but because the "var" syntax introduces a new context for commas, you can't use a comma in there without adding parentheses.
The non-parens syntax ends up only working out when you either discard the result (e.g. echo), or the function only takes one parameter and you want it to take everything until the end of line or the next comma/end of enclosure as a parameter. Sometimes for two-parameter functions the "x.y z" syntax works out, with similar limitations to the one-parameter functions.

I still find a lot of this syntax baffling, but I'm enjoying stretching it to its limits.<
>>
>my friend was already filtered by part 2
kek wtf?
>>
>>107397750
I've never used nim. Doubt I ever will.
Parens being optional but them also changing semantics when there is a comma in a declaration would drive me up the wall.
It's cool that you're able to have fun with it for something like this.

Personally I've grown to really appreciate verbosity in my programs.
>>
>>107396480
>shitty antivirus
Microsoft's security these days is actually very good. If Defender is causing slowdowns for development, then use a "Dev Drive".
>>
File: Untitled2.png (316 KB, 1200x1300)
316 KB
316 KB PNG
>>107394408
managed to squeeze a bit more performance out of this for the non-bigint bigboy
Silver: 40254
Gold: 21475708151366

Performance counter stats for './1 ../../../inputs/1/bigboy.txt' (500 runs):

24,816,407 user_time ( +- 0.01% )
1,260,686 system_time ( +- 0.16% )
97,190,559 cycles:u ( +- 0.10% )

0.0261356 +- 0.0000353 seconds time elapsed ( +- 0.13% )
>>
>>107397580
12 days is about what I have patience for so maybe i'll actually complete the whole year this time
>>
solution has been provided for u ,,, sirs
#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>

int angle = 50;
int zeroes = 0;

int main(void) {

ssize_t r;
size_t len = 0;
char *line = NULL;
FILE *f = fopen("input.txt", "r");

while ((r = getline(&line, &len, f)) != -1) {
int num = atoi(line + 1) % 100;

if (line[0] != 'L') {
angle -= num;
if (angle < 0) {
angle = (-angle) % 100;
angle = 100 - angle;
}
} else {
angle += num;
if (angle >= 100) {
angle %= 100;
}
}

if (angle == 0) {
zeroes++;
}
}

printf("%d\n", zeroes);
fclose(f);
return 0;
}
>>
>>107397910
same, i think 15 was the farthest i've ever made it and i was really forcing myself to give a shit at that point
>>
>>107397881
based simdanon
>>
>>107397822
One of my buddies used AI and was 50% slower than me. Still I won't celebrate too early, he might start beating me in the later stages.
>>
Where the float bigboy at?
>>
>>107397996
>each time the dial is within epsilon distance of zero
>>
>>107397828
Yeah, there's definitely more than a few surprising things in here, like learning that I can't "map(seq, splitWhitespace)" because it's unable to disambiguate between the splitWhitespace function or iterator, and the only way to beat that is doing "mapIt(seq, splitWhitespace(it))" which is some kind of macro. The whole syntax is very prone to generating bizarre errors like that, which make no sense to a beginner like me.

I honestly like lua's solution to the comma problem, which is basically to always require parens when more than one parameter is involved. This allows you to make functions that take a single table as input and just call them like "func{param1=99, param2=100}", making them *almost* look like regular function calls. Despite this, Lua's syntax manages to be very predictable.

But yeah, verbosity's nice. I usually write C, but with how tedious it is to get new projects off the ground, it's started to become frustrating. When looking at languages like C++ and Rust, I really start to see the appeal of Go's syntax, being boring with very few surprises or syntax sugars to learn, while being way less tedious than C. I really wish there was some Python or Lua-like with batteries included that didn't go full retard with its syntax.
>>
>>107398042
>R3.6
>L14.4
>>
File: 223355.png (30 KB, 1551x333)
30 KB
30 KB PNG
I really need to implement block expressions
>>
File: 1763434411084052.gif (989 KB, 340x183)
989 KB
989 KB GIF
>>107391931
>silver
>gold
>>
>>107398092
>R0.1
>R0.2
>L0.3
>>
>>107392206
>.unwrap()
are you trying to crash the whole internet?
>>
import System.IO
import qualified Data.List as T

main = do
handle <- openFile "input" ReadMode
contents <- hGetContents handle
let rotation = map calcRotation (lines contents)
print (T.foldl' day01a (50, 0) rotation)
print (T.foldl' day01b (50, 0) rotation)
hClose handle

calcRotation line
| "L" `T.isPrefixOf` line = -val
| "R" `T.isPrefixOf` line = val
where val = read (drop 1 line)

day01a (lock, score) rotation =
(current, score + if current == 0 then 1 else 0)
where (rotations, current) = (lock + rotation) `divMod` 100

day01b (lock, score) rotation =
(current, score + abs rotations)
where (rotations, current) = (lock + rotation) `divMod` 100


>>107397881
what are you using SIMD for? I can't really understand your solution
>>
File: 84937949.png (4 KB, 375x539)
4 KB
4 KB PNG
>wanted to see if deepseek with deepthink could solve part 2
>gave it the code i abandoned in favor of brute force as a starting point
>it tried three times to give me the right answer, got within 3 once but that's it
>on the fourth attempt, without me asking it to, it completely abandoned my original code for a brute force approach
>worked first try
holy based
>>
I'm filtered by day 1, I just can't think in lisp
>>
>>107398170
>what are you using SIMD for
just number parsing
>>
>>107398250
I vaguely remember reading something about it on daniel lemire's blog. Never had a chance to do it desu
>>
>>107396504
Just memory map the file like all the cool kids do it.
#include "aoc.h"
int main(int argc, char** argv) {
MmFile in(argc > 1 ? argv[1] : "");
bool left = false;
N silver = 0, gold = 0, g = 0, n = 0, dial = 50;
const N max = 10'000'000'000'000'000'000ull;
for (unsigned c : in) {
if (auto u = c - '0'; u <= 9) {
n *= 10, n += u;
} else if (c == '\n') {
gold += n / 100u;
n %= 100u;
if (dial) gold += left ? dial <= n : dial + n >= 100;
if (gold >= max) gold -= max, ++g;
dial += left ? 100 - n : n;
dial %= 100u;
silver += dial == 0;
} else {
n = 0, left = c == 'L';
}
}
printf("%llu\n%llu%llu", silver, g, gold);
}
>>
>>107398122
this would only trip up the rarest of noobs
>>
File: day1.png (331 KB, 557x459)
331 KB
331 KB PNG
i fixed mine up now
>>
>>107398281
Post the header file
>>
I'm off by 11 for part 2 and I don't know why, are there any edge cases that come to mind for anyone?
>>
>>107398350
The only definitions there are the MmFile class to memory map files, and N that is an alias of 64 bits unsigned integer.
>>
>>107398370
starting at 0 and going backwards to 99 doesn't count as passing 0, but starting at 1 does.
>>
>>107398370
Input:
L50
R100

Should give 2 for part1 and part2.
>>
>>107398434
>>107398478
Yeah that's it, thanks. It works correctly for part one, but I changed my approach for part 2 and that doesn't work with this
>>
>>107394317
I looked at the input.
>>
>>107398434
afaik, this is the only "edge case" that really fucked me in the ass as well. the start at zero case.
>>
>>107394317
No, I instantly assumed it can be any integer > 0.
>>
File: nelua1.png (221 KB, 974x1801)
221 KB
221 KB PNG
decided I wasn't going to do it at midnight this year, then forgot about it entirely.
also forgot about deciding what language to do it in, so here's Nelua
>>
>>107394317
no, no that really doesn't make sense. you can turn a safe dial 5 gigagorillion bazillion degrees and more
>>
>>107397524
Thanks for making me feel like an idiot.
>>
>>107393908
just use fucking plaintext retard
if your bigboy relies on being >512 mb then don't even post it
>>
>>107398913
>still complaining about 7z for no reason
>>
part 2 solution delivered kindly for u sirs ,,, what is big boy btw?
#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>

int angle = 50;
int zeroes = 0;

int main(void) {

ssize_t r;
size_t len = 0;
char *line = NULL;
FILE *f = fopen("input.txt", "r");

while ((r = getline(&line, &len, f)) != -1) {
int num = atoi(line + 1);
int laps = num / 100;
int startedZero = angle == 0;
num %= 100;
zeroes += laps;

if (line[0] == 'L') {
if (num > angle && !startedZero) {
zeroes++;
}

angle -= num;

if (angle < 0) {
angle = -angle;
angle = 100 - angle;
}
} else {
angle += num;
if (angle > 100 && !startedZero) {
zeroes++;
}
angle %= 100;
}
if (angle ==0 && !startedZero) zeroes++;

}

printf("%d\n", zeroes);
fclose(f);
return 0;
}
>>
>>107398894
Your solution looks way more sensible, I'm just making it look shit for no good reason.
Only thing I can suggest is to use "for line in lines("day1.txt")", it's a really nice builtin iterator that doesn't need to allocate memory for the seq containing all the lines beforehand.
>>
File: for_|g|.png (120 KB, 1021x506)
120 KB
120 KB PNG
[day one; part b]
Some slop for ya.
>>
File: day1 code.png (391 KB, 1418x2382)
391 KB
391 KB PNG
Idiomatic java solution

bruteforced because i got fucked by fencepost errors.
>>
>>107399644
where's your solution factory?
>>
>>107399672
I am a factory that turns coffee into solutions
>>
File: v1.png (165 KB, 1678x1669)
165 KB
165 KB PNG
>>107398709
v. yeah I hate this.
1. why is mutability part of a struct definition?
2. why does vfmt punish more readable Dial initialization by making it take multiple lines, vs. Dial{50, 100}?
3. how is EOF handling this dumb? Basic I/O is catastrophically wrong.
>>
>>107399688
but are you durgasoft core java certified?
>>
>>107399644
can you explain the algorithm please i dont understand
>>
why are you guys using modulo and also timing your code?
you do realise if you put a modulo in your code you have already lost
>>
>>107399808
mod constant isn't division
>>
>>107399872
interesting, tell me more
>>
>>107399808
Show us your moves then.
>>
I did part a in Scratch, took more time than I expected
>>
File: day1.png (918 KB, 2048x3856)
918 KB
918 KB PNG
Managed to get the bigboy running well on this one
>>
>>107399808
modulo is an objectively cool operator
>>
File: d1.png (143 KB, 1150x1372)
143 KB
143 KB PNG
>>107399694
d has named arguments finally?
alright, going with d this year.
>>
where's the bingo card?
>>
>>107400031
it's cool but it sucks, you're better off just pointing at the last 2 characters of the string (or all but the last two)
>>
File: adventofjeet.png (133 KB, 574x1240)
133 KB
133 KB PNG
Behold the jeet solution.
>>
>>107400351
i thought about doing this at first
>>
Somewhat dumb C code.
#include <stdio.h>
#define DIAL_ANGLES 100
#define INITIAL_ROTATION 50

int main(){
int rotation = INITIAL_ROTATION, rot = 0, numZero = 0;
char dir = 0;
while(scanf(" %c%d", &dir, &rot) != EOF){
if(dir == 'L') rotation = ((rotation - rot) % DIAL_ANGLES + DIAL_ANGLES) % DIAL_ANGLES;
else rotation = (rotation + rot) % DIAL_ANGLES;

numZero += (rot-1)/DIAL_ANGLES;
if(!rotation) numZero ++;
else if(dir == 'L' && rotation + rot%DIAL_ANGLES > DIAL_ANGLES) numZero++;
else if(dir == 'R' && rotation - rot%DIAL_ANGLES < 0) numZero++;
}
printf("%d\n", numZero);
}
>>
File: 1742052184417093.png (67 KB, 1444x449)
67 KB
67 KB PNG
dumb solution that checks every click one-by-one because off-by-one errors were driving me nuts

>>107395801
hello sir, while doing these I recommend checking the Clojure cheatsheet for helpful functions in the standard library
https://jafingerhut.github.io/cheatsheet/clojuredocs/cheatsheet-tiptip-cdocs-summary.html
>>
somebody bake?
>>
File: 1.png (12 KB, 279x373)
12 KB
12 KB PNG
C, bigboy: https://0x0.st/KJ12.txt
Memory mapping + custom parsing instead division/modulus:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef struct { HANDLE f_, m_; PBYTE begin, end; } MemFile;
void Map(const char* s, MemFile* o) {
o->m_ = NULL, o->begin = o->end = 0;
o->f_ = CreateFile(s, GENERIC_READ, FILE_SHARE_READ,
0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (o->f_ == INVALID_HANDLE_VALUE) return;
LARGE_INTEGER z;
if (!GetFileSizeEx(o->f_, &z)) return;
o->m_ = CreateFileMapping(o->f_, 0, PAGE_READONLY, 0, 0, 0);
if (o->m_ == NULL) return;
o->begin = (const PBYTE)MapViewOfFile(o->m_, FILE_MAP_READ, 0, 0, 0);
if (!o->begin) return;
o->end = o->begin + z.QuadPart;
}
void UnMap(MemFile* o) {
if (o->begin) UnmapViewOfFile(o->begin);
if (o->m_ != NULL) CloseHandle(o->m_);
if (o->f_ != INVALID_HANDLE_VALUE) CloseHandle(o->f_);
}
#include<stdio.h>
typedef unsigned long long N;
N getN(const unsigned char* buf, int n) {
N res = 0;
for (int i = 0; i < n; ++i) res = res * 10 + buf[i];
return res;
}
int main(int argc, char** args) {
if (argc < 2) return puts("Missing filename");
MemFile in; Map(args[1], &in);
N silver = 0, gold = 0, g = 0, n = 0;
unsigned d = 0, u = 0, c = 0, m = 0, dial = 50, left = 0;
const N max = 10'000'000'000'000'000'000ull;
unsigned char buf[24];
for (auto it = in.begin; it != in.end; ++it)
c = *it, u = c - '0',
u <= 9 ?
buf[d++] = u :
c == '\n' ?
u = d < 3 ? 0 : d - 2,
n = getN(buf, u),
m = getN(buf + u, d - u),
gold += n,
gold += dial && (left ? dial <= m : dial + m >= 100),
gold >= max && (gold -= max, ++g),
dial += left ? 100 - m : m,
dial >= 100 && (dial -= 100),
silver += dial == 0,
m = d = n = 0 :
!d && (left = c == 'L');
printf("%llu\n%llu%llu", silver, g, gold);
UnMap(&in);
}
>>
>>107400092
This is actually not a bad idea in this case.
We ingest the input as a string to begin with, so splitting it before conversion to int likely saves cycles.
>>
>>107400351
Oh, my shining bright Durga!!!
>>
>>107400780
Since MSVC cl.exe doesn't support C23 when compiling C files use PBYTE instead auto.
>>
>>107394076
Very nice, please keep doing what you're doing drawfriend

>>107393842
Also very nice, my Haskell programming is nowhere near as crazy.
When I code I mostly use it as more of a statically typed scheme.
>>
>filtered on the first day
>>
new thread
>>107400869
>>107400869
>>107400869
>>
>>107399872
Multiply by constant and divide by power of 2 with shift, add error term if necessary
>>
>>107394076
>>107394087
thank you for these
>>
>>107400782
In practice the compiler optimizes division using multiplication and shift, 3 + 1 cycles in current CPUs, from there it can optimize modulus with a multiplication and subtraction, also 3 + 1 cycles. The real speed booster is memory mapping the input file and processing in one pass, 6x speed compared with working with standard input.



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