[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: 1764793718355930.mp4 (111 KB, 800x402)
111 KB
111 KB MP4
sliding window 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: >>107417323
>>
>>107424958
Wow thats kind of genius now that I see sliding window in action. Neat!
>>
File: Cha-Cha-Slide3.jpg (17 KB, 280x280)
17 KB
17 KB JPG
sliiiide to the right
>>
>Reconsider whether you really want to be on the hook for $150,000 per puzzle input copied and per copy distributed.
>>
>>107424958
Very nice. Enlightening!
>>
File: file.png (55 KB, 250x200)
55 KB
55 KB PNG
Try the prime challenge if day3 was too easy for you!
>part 1 : Return the largest prime number per row and sum them
>part 2 : The sum must be the largest prime number possible. The value of each individual row must still be prime, but they are not all required to be the largest prime.
Part 2 permits single digit primes by construction with leading 0s. Alternatively the the sum must be largest prime + 1.
>>
>>107425041
this is not in the spirit of christmas and therefor it sucks and by extension, you suck.
>>
File: 1490801951538s.jpg (2 KB, 125x117)
2 KB
2 KB JPG
>>107425065
rude
>>
PSA including this in your L->R loop saves you 10,000+ iterations
if next_max_digit == 9:
break
>>
>>107424994
>he doesn't effortlessly visualise algorithms in his head

ngmi
>>
Cool fact: when you grow your window, if the new rightmost element added to the window is strictly larger than the previous element you added to your answer, the window shrinks to length 1 (and never grows again). So if you have e.g. 3 digits, take the next 9 digits starting at that rightmost element and you're done.
>>
>>107424998
I've been looking for this song for a while now, thanks.
>burns disc
>puts into dvd wallet
>kicks it under the bed
>never looks it up again
>>
>>107425041
Does anyone know if there's a way to solve part 2 of this without extensive, computationally intensive brooting? Wouldn't it require knowing how to construct a prime number formulaicly?
>>
once again I go to bed and will probably oversleep showtime
>>
>>107425138
I'd advise against that if you're using a compiled language
modern cpus favor full loops with only one condition
>>
>>107425195
[code[8191811111111111111[/code]
?
>>
>>107425195
wrong
>>
>>107425215
My initial solution was to find the closest prime less than the sum, store that value as the drop value, and figure out which row(s) i can to pick lower primes to get that drop value.
>>
>>107425292
counter example?
>>
File: file.png (107 KB, 1200x1200)
107 KB
107 KB PNG
>>107424958
Twice as late, so I had to be twice as fast.
>>
>>107425041
>>107425065
Thanks to Obamanomics, Santa Claus has decided to only deliver toys to good kids who live at prime-numbered addresses.

Santa's elves have translated the list of nice little boys and girls into their street addresses, with one line for each street. Unfortunately, due to time constraints, street addresses were copied in order of the kids' appearances on the nice list, not in convenient ascending order of street address.

On each street, Santa wants to start his sleigh at the first house on the street (e.g. #1 Gingerbread Road) and stop at the last prime-numbered address before flying to the next street, to waste as little deer feed as possible. What is the total number of houses Santa must pass by or visit (i.e. the sum of the largest prime numbered-address on each street)?

Your input is the post below:
>>
File: file.png (59 KB, 1200x1200)
59 KB
59 KB PNG
>>
>>107425275
Never happens for that input, the rightmost element is always a 1
>>
>>107425550
>>107425561
_ ____ __ ____ ___ ___
>>
File: 1752957164778160.jpg (717 KB, 1408x768)
717 KB
717 KB JPG
>>
>>107425550
>>107425561
sovl

>>107425626
sovless
>>
>>107425550
>>107425561
I hope she's okay
>>
>>107425550
id jolt her handles (if you know what I mean)
>>
File: ex1.png (63 KB, 1292x869)
63 KB
63 KB PNG
>>107425292
Try it. Always works.

The window always grows by 1 element rightwards, while the left boundary is 1 after the element you just chose.
If you choose the new rightmost element, the window must shrink to size 1 - the element immediately after is both the left and right bound.
It can never grow larger, since it always grows by exactly 1 and must shrink by at least 1.
No element in the window can be larger than the previous element selected, otherwise it would've been the element selected. And the rightmost element added is the only new one. So if it's larger than your previous selection, you can break early, you've found the number.
>>
>>107425647
I don't anon, please explain.
>>
>>107424958
Anon... This is the monotonic stack edition you mean.
>>
>>107425755
wtf is this word salad post code
>>
File: day3.png (84 KB, 655x1151)
84 KB
84 KB PNG
Baby's second Go program.
503ms on bigboy.
>>
So no calendar this year?
>>
>>107425908
ask grok you help you make one
>>
>>107425887
Grok, post a needlessly code-golfed AoC solution with single-character variable names and no comments.
>>
File: image.jpg (298 KB, 784x1168)
298 KB
298 KB JPG
>>107425915
ok now what
>>
>>107426060
yay calendar
ai is the future
>>
>>107425887
filtered
>>
>>107426052
>>107426172
>won't post code to check
ok so it doesn't work got it
>>
THE GREAT FILT-

Day 1 filtered more people than the fucking dynamic programming day.
>>
.5s for bigboy with pypy and faster than a for loop on node. Sucks to have to do max then find but pypy can't optimize a loop enough to beat it.
import sys
def main():
total = 0
size = 12
zero = ord(b'0')
file = open(sys.argv[1], 'rb').read()
mv = memoryview(file)
linestart, lineend = 0, 0
while (lineend := file.find(b'\n', linestart)) != -1 and lineend != linestart + 1:
line = mv[linestart:lineend]
start, out = linestart, 0
for end in range(lineend - size + 1, lineend + 1):
maxx = max(line[start - linestart:end - linestart])
start = file.find(maxx, start, end) + 1
out = out * 10 + (maxx - zero)

total += out
linestart = lineend + 1
line.release()

print(total)
main()
>>
File: 2025-03-washed1.png (383 KB, 2164x1444)
383 KB
383 KB PNG
$ mix aoc.solve -y 2025 -r input/real -d 3 -p both -b 1
17074
169512729575727

Ran in 4.111ms


>new workplace has a company leaderboard with 20+ people and a fairly active channel on Teams
Feels good bros
>>
File: day3c.png (62 KB, 565x851)
62 KB
62 KB PNG
>>107425895
>exact same program in C is shorter, simpler, and twice as fast
>243ms on bigboy
Having second thoughts on learning Go.
>>107426233
That's probably all people still on the leaderboards from last year that forgot aoc was a thing.
>>
>>107424958
filtered by day 1 part 2
ama
>>
>>107426281
Why don't you just broot it?
>>
>>107426270
how is the "exact same program" shorter and simpler?
>twice as fast
compare with gcc-go or tinygo
if you're going to make an HTTP microservice that uses corporate single sign-on, or deploy statically linked executables to a very heterogenous (chaotic) server farm, you might prefer go. It's also the language of choice of modern malware - don't bother with a botnet in anything else.
>>
>>107426325
I am having a melty because I wasted so many years of my life instead of listening to /g/ and seriously studying programming and math when I was just 18~20
now I am 27 and can't even get past day 1 of aoc
>>
>>107426270
>That's probably all people still on the leaderboards from last year that forgot aoc was a thing.
It didn't occured to me, good catch. Now I'm going to delete everyone with 0 stars.
>>
>>107426379
Hey, saltyFamiliar here. Can you highlight my name so it's easier to find?
Thanks in advance!
>>
>>107426379
>>107426270
>That's probably all people still on the leaderboards from last year that forgot aoc was a thing.
The creator of the anonymous-only leaderboard reused it and didn't purge it. The main one is new this year.
>>
>>107426373
>the language of choice of modern malware
Having a lol at imagining trying to be surreptitious with one of those xbox huge binaries go produces.
>>
>>107426379
>>107426437
Used to be ordered by the last 3 digits of the user ID, but doesn't seem to be anymore. How are they ordered?
>>
>>107426373
gcc-go is 392ms, still a lot worse than C and a bunch of stuff isn't gonna work with it since no one cares about it.
I'll stick with Go through the end of AoC just for the heck of it, but it's not impressive so far.
>>
>>107424958
I hate this game
>>
>>107426495
Go's best feature is how easy it is to write parallel code with goroutines. If you're just writing single-threaded code, for something like AoC, there's probably no point in using Go and you won't get why people like it.
>>
>>107426548
>pottery
>meme terminal
>full on git repo
You're trying too hard.
>vim program.py
>./program.py
>>
>>107426185
What code do you want? I'm talking about theory.

You're looking for a 12-digit number in a list of numbers.
The first digit has to be somewhere between the start and the 11th from end (if it was e.g. the 3rd from end you'd only be able to make a 3 digit number).
You search this window and find the first digit.
The second digit must be after the first digit, but before the 10th from end.
The third digit must be after the second digit, but before the 9th from end.
The fourth digit must be after the second digit, but before the 8th from end.

Get it? Sliding window. Each time you increment the right index by 1, and jump the left index so it's 1 after the digit you just found.
If this window is ever reduced to size 1, it'll stay size 1 for the rest of the question. So you can exit the loop and just pull however digits you need to make up your 12 digit answer.
>>
File: d-c3.png (266 KB, 1230x1933)
266 KB
266 KB PNG
>>107426270
I typed this out and did i++ instead of j++ in jolt2's inner loop, so I got an infinite to have to troubleshoot. What fun!
betterC is marginally faster and occupies the same space, probably just an llvm vs. gcc difference
>>
Good news!
More AoC!

https://reddit.com/comments/1pdlat1/comment/ns5xhr1
>>
>>107426586
>pottery
I like it
>meme terminal
It looks cool
>full on git repo
I like CI pipelines
>./program.py
That won't work with python
>>
>>107426458
they're not surreptitious at all, but they get the job done.
>>
>>107426623
>That won't work with python

Yes it will, just add

#!/usr/bin/env python3

to the top of your file
>>
>>107426623
chmod +x program.py
perl -i -lpe 'print "#! /usr/bin/env python3" if $.==1' program.py
./program.py
>>
>>107426601
>if you have 7 digits left to find, and 7 digits remain in the list... those are your 7 digits

I know everyone wants to find the big brained shortcut, but this might not be the revolutionary insight you think it is.
>>
>>107426632
>>107426653
I'm not adding shebangs to my python script
>>
>>107426662
you ashamed of using a scripting language or something?
what a weirdo
>>
>>107426662
#! isn't even a stigma of scripting languages: https://lib.rs/crates/rust-script
it's just about admin-friendly tooling.
>>
>>107426662
Why the fuck not? I get this site is full of autists but this is the weirdest hill to die on.
>>
File: file.png (1.24 MB, 2560x1057)
1.24 MB
1.24 MB PNG
>>107424958
That is extremely sexy, how do you set that up anon?
>>107425895
Benchmark 1: cargo run --release big.boy
Time (mean ± σ): 312.8 ms ± 6.6 ms [User: 276.4 ms, System: 45.9 ms]
Range (min … max): 303.4 ms … 333.0 ms 100 runs

>>107426233
I thought this was a greedy problem?
>>
>>107426729
>it's just about admin-friendly tooling.

Stfu dude. You didn't even know it was possible 10 minutes before you became opinionated about it.

>i'm a devops guy
>>
>>107426859
I am literally a devops guy and I have unironically used rust-script in very poorly-advised production.
>>
File: tryrtytrty.gif (398 KB, 165x149)
398 KB
398 KB GIF
>>107425550
>>107425561
sweet lord almighty
>>
>>107425755
why does the window start at size 4? why not 6 or 8?
>>
>>107426913
Garbitrary value. I can't see how the sliding window solution is more performant than the dp solution.
>>
I'm just going to go ahead and write my grid parsing and dijkstra code now. 2 minute time incoming
>>
>>107426811
post CPU
Your code should be faster than that.
>>
>>107426469
>Used to be ordered by the last 3 digits of the user ID, but doesn't seem to be anymore.
I don't know what makes you think that but each time the script is run it the order is completely randomized. I tried to alter the ordering to make the users sorted by score on the leaderboard, before realizing that later in the script the y position is completely randomized. I'm really struggling to make meaningfully changes to how the graph is rendered so I'm gonna try to reproduce it with OpenGL.
>>
>>107426929
What is the DP solution?
I used combinatorics LMAO
>>
>>107427049
How? I didn't realise that was possible.
>>
>>107427021
>I don't know what makes you think that
The original author of the script explicitly did it that way so it was easy to find your name.
Here's an old one, technically it's reverse order but it clearly goes by the last 3 digits of each ID.
>>
>>107426943
>He doesn't have one now
Heh
>>
>>107427147
I kind of like hastily implementing my shitty code every time, its part of the fun for me. I don't even like to import itertools most of the time
>>
>>107427075
Well I basically started by skipping over the first 12 digits, then add the rest one by one, combining them each time in groups of 12 and comparing each combination against the last 12 digits to save the biggest. Then add the next digit to the last biggest and combine again in groups of twelve. In the example I ran the comparison 12*3=36 times (because I skip the first combination). Something like:

[234234234234][278]

[234234234234][278]

[2342342342342] compare this shit in groups of 12 against 234234234234
>>
C23, memory mapping the input file.
Big boy in ~ .5 s.
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef struct { HANDLE f_, m_; char* begin, * end; } MemFile;
MemFile Map(const char* s) {
MemFile f = {0, NULL, 0, 0};
do {
f.f_ = CreateFile(s, GENERIC_READ, FILE_SHARE_READ,
0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (f.f_ == INVALID_HANDLE_VALUE) break;
LARGE_INTEGER z;
if (!GetFileSizeEx(f.f_, &z)) break;
f.m_ = CreateFileMapping(f.f_, 0, PAGE_READONLY, 0, 0, 0);
if (f.m_ == NULL) break;
f.begin = (char*)MapViewOfFile(f.m_, FILE_MAP_READ, 0, 0, 0);
if (!f.begin) break;
f.end = f.begin + z.QuadPart;
} while (0);
return f;
}
void UnMap(MemFile* f) {
if (f->begin) UnmapViewOfFile(f->begin);
if (f->m_ != NULL) CloseHandle(f->m_);
if (f->f_ != INVALID_HANDLE_VALUE) CloseHandle(f->f_);
}
size_t f(char* line, int size, int digits) {
size_t n = 0;
for (int di = -1, d; d = 0, digits--; n = n * 10 + d - '0')
for (int i = di + 1; i < size - digits; ++i)
if (line[i] > d) d = line[i], di = i;
return n;
}
#include<stdio.h>
int main(int argc, char** args) {
if (argc < 2) return puts("Missing filename"), 1;
auto in = Map(args[1]);
size_t p1 = 0, p2 = 0, z = 0; auto cur = in.begin;
for (auto it = cur; it != in.end; ++it)
if (*it < '0') {
if (z) p1 += f(cur, z, 2), p2 += f(cur, z, 12), z = 0;
} else {
if (z == 0) cur = it;
++z;
}
printf("%llu\n%llu", p1, p2);
UnMap(&in);
}
>>
>>107427174
>I don't even like to import itertools
wtf the fuck?
>>
>>107426235
now try the monotonic stack version
>>
>>107427199
half the fun of dp is doing memo = {} if k not in memo them memo[k] = 5 doing @cache def dfs takes all the fun out of the entire double penetration. i like to enjoy it
>>
>>107427217
Is there real life use cases of it? I think I've only ever needed it for like some leetcode problem...
>>
>>107427278
Is showing strangers on the internet that you have a big programming-dick a real life use case?
>>
>>107427278
You might want to run an aggregation on a window of some constant size on a running stream of numbers. Although, it would be a monotonic queue, but you can use it for finding the min. and max. of the window. Avg. will be just keeping track of the sum, and subtracting elements on the left that are popped out of the window. Think of a series of data of vehicle speed. It's just a cool optimization trick, and one of the few ones where the amortized complexity matters.
>>
>>107425908
nobody cares about this anymore after the last five years were all dogshit
even indians couldn't give a fuck now
>>
>>107427339
Oh. Cool.
>>107427305
....yes
>>
>>107427278
what is the use-case for requiring everything you do to have a Verified Java Enterprise Solution Durgasoft Certified Use Case
>>
>>107427349
Good. I've seen less "um I have a job" posts in these threads so that's good.
>>
>>107427376
wait, I just looked, and even eric doesn't give a fuck anymore. Only 12 days?
lmao it's over.
>>
C23, stack version.
Big boy also in ~ .5 s.
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef struct { HANDLE f_, m_; char* begin, * end; } MemFile;
MemFile Map(const char* s) {
MemFile f = {0, NULL, 0, 0};
do {
f.f_ = CreateFile(s, GENERIC_READ, FILE_SHARE_READ,
0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (f.f_ == INVALID_HANDLE_VALUE) break;
LARGE_INTEGER z;
if (!GetFileSizeEx(f.f_, &z)) break;
f.m_ = CreateFileMapping(f.f_, 0, PAGE_READONLY, 0, 0, 0);
if (f.m_ == NULL) break;
f.begin = (char*)MapViewOfFile(f.m_, FILE_MAP_READ, 0, 0, 0);
if (!f.begin) break;
f.end = f.begin + z.QuadPart;
} while (0);
return f;
}
void UnMap(MemFile* f) {
if (f->begin) UnmapViewOfFile(f->begin);
if (f->m_ != NULL) CloseHandle(f->m_);
if (f->f_ != INVALID_HANDLE_VALUE) CloseHandle(f->f_);
}
size_t f(const char* const line, const size_t size, const size_t digits) {
char stack[16] = {0}; size_t si = 0;
for (size_t i = 0; i < size; ++i) {
auto d = line[i];
while (si && stack[si - 1] < d && digits + i < si + size) --si;
if (si < digits) stack[si++] = d;
}
size_t j = 0;
for (size_t i = 0; i < si; ++i) j = j * 10 + stack[i] - '0';
return j;
}
#include<stdio.h>
int main(int argc, char** args) {
if (argc < 2) return puts("Missing filename"), 1;
auto in = Map(args[1]);
size_t p1 = 0, p2 = 0, z = 0; auto cur = in.begin;
for (auto it = cur; it != in.end; ++it)
if (*it < '0') {
if (z) p1 += f(cur, z, 2), p2 += f(cur, z, 12), z = 0;
} else {
if (z == 0) cur = it;
++z;
}
printf("%llu\n%llu", p1, p2);
UnMap(&in);
}
>>
>>107427080
Wow, I never saw the TGF graph look like that. But I've been doing aoc only since 2021 and back then it already looked like it does now if I remember correctly. (Well, look liked the graph last year, thus year it's broken.)
I think it look way better now that, it's more visual and more meaningful.
>>
This years aocg feels like sticking around at a party after most of the people have already left and you are helping the host clean up cans
>>
>>107427442
Isn't that how 4chan as a whole is starting to feel? I don't know, I haven't been here since last year, but that's the impression I get from looking at the /g/ catalog.
>>
File: 1714364246369300.jpg (35 KB, 1024x576)
35 KB
35 KB JPG
>>107427442
Puzzles have been soulless
Now 2019? *sips*
>>
>>107425588 (checked)
Same, brother.
Same.
>>
>>107426233
What dynamic programming?
>>
>>107427442
I'm considering starting a /g/ summer of code or something; I don't want this custom to just die like this.

Would anyone be interested in helping me host/come up with puzzles?
>>
>>107427463
True, but at the same time 4chan oldfags feel like my only true peers on the internet these days. It's comfy
>>
>>107425755
I'm a math-let; can someone explain to me why the fuck this works? It seems like black magic to me.

I get that we're using a 4-wide window because we need to delete 3 numbers but I still don't get why this algorithm works.
>>
>>107427481
People say this every year, but maybe this half-year will be the wake-up call for it to finally happen. Personally I don't see myself being a founding member that makes it happen, but if it were to already exist I might contribute
>>
tested my solution on big boy and it just runs forever. I guess I'll never know if it's fast or not
>>
>>107427513
>I guess I'll never know if it's fast or not
You already know by it not finishing quickly (it's slow).
>>
>>107427518
it's impossible to know.
>>
>>107427499
>I get that we're using a 4-wide window because we need to delete 3 numbers but I still don't get why this algorithm works.
You just explained why it works? I don't understand your question.
>>
>>107427481
I was thinking it would be comfy to have an advent exclusively on parsing and PL related problems. But that's just me with my blinders...
>>
>>107427481
Sure! I'll be the prompting/ideas guy
>>
>>107427499
To make the largest number, you need the leftmost numbers to for sure be the highest. We start with the 4 wide window so we have the most choice on the left, and just grab the highest number in the window as the window shrinks so that we have the right number of digits.

It's actually pretty cool and a shame that I completely missed the sliding window way of doing it.
Instead, I found the maximum, then recursed and grabbed the next most max numbers on the right side of the list. If I found I still had extra numbers then I would recurse in the left side of the max.
It was harder than I expected it would be, but I guess I was doing it wrong.
>>
>>107427442
Because 4chan and /g/ specifically is full of angry clueless retards now and complete shit
And no, it wasn't always like this, it got way worse in the last few years
I came back for this after not posting on /g/ since last year's aoc but I'm sure many who left didn't
>>
>>107425550
>>107425561
the soul of /aocg/
>>
>>107427590
I haven't even checked the catalog, ive been /aocg/ only for like 3 years now
>>
>>107427198
>>107427400
cute ones, anon. have you compared the overhead of file IO vs mmap? how better is it?
>>
>>107425561
I'd fork her repo.
>>
>>107427472
because it was the obvious solution
>>
>>107427481
I'll make the logo
>>
>>107427635
not him but I tried that and the difference is about 200ms
>>
what times are you guys averaging for your regular input? I'm getting ~6ms which seems kind of slow. I am triple iterating the input data and didn't update my part1 with my part 2 solution but even still...
>>
>>107426913
11 characters reserved so you can always make a 12 digit number

>>107426929
What a surprise the dp retard doesn't understand programming
>>
>>107427511
>>107427548
>>107427555
>>107427754
I'll get an email address set up tonight and we can do a mailing list. I think it'd be a great idea.
>>
>>107427766
Wow, Windows is truly awful
>>
>>107427536
>>107427561
So hypothetically if we had a 100-digit number we'd need an 89-digit window?
>>
File: carbon-2.png (310 KB, 1228x1974)
310 KB
310 KB PNG
final wash before day 4. wish i was better at these kinds of problems, or could at least anticipate the part 2 a little easier
>>
ONE HOUR
>>
>>107427889
>not timing it to the second
1 HOUR
>>
1 HOUR
>>
>>107426929
See >>107422238 . Both have the same worst case time complexity, but on average case it performs more like O(n) than O(nm), n: line len, m: digits. The worst case for the sliding window is when the max number is at the beginning so all the max_ind scans are for nothing. In avg cases the left ptr shifts and reduces the search space considerably.

>>107427766
Thanks, I will have to try it. I am not sure if I/O should be even measured for these challenges. Just embed the input file.
>>
>>107427896
>>107427897
>59
>01
SAD
>>
>>107427896
>>107427897
bruh
>>
>>107427769
How are you measuring your time? Is it end to end like using time/hyperfine, or only the code region that solves the problem? I wonder what would be the best format for easily benchmarking runtime of solutions here. Maybe passing the entire input as const char*?
>>
>>107427912
Measure-Command { ... }
>>
>>107427896
>>107427897
is this what they mean by an off by 1 error? kek
>>
>>107427920
690us using stack and hyperfine for measuring
>>
>>107427922
Hey, the two off by ones average out to the right number
I've had that happen in my AoC solution before
>>
>>107427896
>>107427897
>off by one
I award you no stars.
>>
Why was day 2 so hard compared to day 1 and 3?
>>
anyone else get extremely sleep deprived every year from this despite taking 30+ minutes on each puzzle.
>>
>>107428063
Yeah, I give myself until 1am then call it quits, any more than that and my brain starts shutting down and I can't think straight anyways. Usually I can keep up for a couple weeks before they get hard enough that I get filtered and end up doing them in the evening.
I'm not good enough to be competitive on points anyways but I love the urgency night of.
>>
MASSIVE FILTER INCOMING TODAY HOLY FUUUUUUCK
>>
>>107425041
shut the fuck up
>>
>>107428132
Lol you wish
>>
>>107428127
Same. somehow i always have an above average time on the easy puzzles and a below average time on the hard puzzles. I like the urgency but I suck at it.
>>
>>107428063
Kinda. Even if I finish the puzzle I can't go straight to bed.
>>
>>107428163
>above average time on the easy puzzles and a below average time on the hard puzzles
Same, or that I drag ass figuring out part 1 and then part 2 is easy to extend from part 1.
>>
>>107428185
No better feeling than doing part 1 properly and having a 2 minute delta time
>>
>>107428058
wdym hard? the input was made such that a simple enumeration of all the invalid ids will work. use strings if you want to do it simply
>>
File: 1737209070704890.jpg (7 KB, 250x250)
7 KB
7 KB JPG
>>107428140
Couldn't solve it anon?
>>
>>107428163
Opposite. I usually figure out part 1 instantly and the time I take on it is just a reflection of how fast I can type and debug minor issues. Part 2 usually ddos's my brain as I breadth-first search through many possible solutions while running out of short term memory.
>>
>>107428196
is this what they call branch prediction? kek
>>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <bits/stdc++.h>

std::pair<const char *const, const size_t> mmap_file(const char *file_name)
{
int fd = open(file_name, O_RDONLY);
struct stat sb;
fstat(fd, &sb);
const off_t file_size = sb.st_size;
const char *data = static_cast<char *>(
mmap(nullptr, file_size, PROT_READ, MAP_PRIVATE, fd, 0));
return {data, file_size};
}

char max_sub(const char *line, int i, int j)
{
char best = '1';
while (i < j && best < '9')
{
best = std::max(best, line[i]);
++i;
}
return best;
}

uint64_t evaluate_line_1(const char *line, int length)
{
uint64_t result = 0;
int i = 0, j = length - 1;
for (int digits = 0; digits < 2; ++digits)
{
char target = max_sub(line, i, j);
while (line[i] < target)
++i;
result = result * 10 + target - '0';
++i;
++j;
}
return result;
}

uint64_t evaluate_line_2(const char *line, int length)
{
uint64_t result = 0;
int i = 0, j = length - 11;
for (int digits = 0; digits < 12; ++digits)
{
char target = max_sub(line, i, j);
while (line[i] < target)
++i;
result = result * 10 + target - '0';
++i;
++j;
}
return result;
}

int main(int argc, const char **argv)
{

auto [data, file_size] = mmap_file(argv[1]);
int line_length = 0;
while (data[line_length] != '\n')
line_length++;
int num_lines = file_size / (line_length + 1);

uint64_t part_1 = 0, part_2 = 0;
#pragma omp parallel for reduction(+ : part_1, part_2)
for (int i = 0; i < num_lines; ++i)
{
part_1 += evaluate_line_1(data + i * (line_length + 1), line_length);
part_2 += evaluate_line_2(data + i * (line_length + 1), line_length);
}
std::cout << part_1 << '\n'
<< part_2 << '\n';
}

>>107417340
21ms
>>
File: 1603361374765.gif (943 KB, 500x500)
943 KB
943 KB GIF
>>107428196
>tfw I only have to change a single number for part 2
only happened a couple times but it was satisfying as hell
>>
10 MINUTES
>>
10 MINUTES
>>
File: Capture.png (7 KB, 307x118)
7 KB
7 KB PNG
>>107428234
>off by 1 sec again
kill me

also nice captcha
>>
>>107425041
I can't even think of a solution for part 1. Is that possible for a row with >= 100 length?
>>
Shat and ready.
>>
IT'S SHITTING TIME
>>
>>107428249
is this a hint for the massive filter coming today lol
>>
>>107428163
Other way around for me. I end up with buggy, messy code when trying to solve the easy puzzles as fast as possible, resulting in spending more time debugging than writing. On later days when I take it slower and think it through, I can figure out a solution pretty quick, and what I write either works first try or I already know where to look for bugs.
>>
I HAVE NO TIME, AND I MUST POOP
>>
File: showtime.jpg (46 KB, 640x480)
46 KB
46 KB JPG
https://www.youtube.com/watch?v=hjGZLnja1o8
>>
File: blood type gaylord.gif (125 KB, 720x480)
125 KB
125 KB GIF
5 MINUTES
>>
>>107428282
cancer music
>>
>make coffee and pop snus
>bowel starts churning
oh no no no not now not now bros
>>
File: mokou-showtime.jpg (130 KB, 440x518)
130 KB
130 KB JPG
>>
File: IMG_6605.png (453 KB, 1858x1829)
453 KB
453 KB PNG
>>
because tonight it is shit time
in the middle of the streetlight
>>
>>107428289
>>107428296
kys
>>
i gotta poooooooooooooooooooop
>>
>>107428301
i'll stay safe, thank you!
>>
oy vey visit a sponsor while you wait
>>
HNNNNNNG
PHROOH
HNNNNNGMMMM
*plop*
>>
pretty hungry
gonna go make a sandwich
cant code on an empty stomach right?
>>
nightcore STARTED
shit TAKEN
tea BREWED
vim OPEN
TODAY I WILL GET A GOOD TIME
>>
inb4 cellular automata
>>
JUST WOKE UP FUCK FUCK FUCK
>>
What's going on in the printing department?
>>
hot choccy ready :^)
>>
>>107428319
networkx IMPORTED
z3 IMPORTED
>>
Today is the day, I can feel it
>>
box pushing puzzle
>>
>>107428329
based
>>
File: 1750869614123421.jpg (113 KB, 1290x706)
113 KB
113 KB JPG
this is nuts
>>
hush it's puzzle time
>>
FUCK
>>
FUCK
>>
FUCK
>>
the great filter
>>
FUCK
>>
the great filler
>>
grid day, I fucking knew it
>>
FUCK ITS A GRID PROBLEM

FUCK YOU ERIC
>>
GRID THANK YOU ERIC
>>
>>107428321
Holy shit how did you know?
>>
File: 1750769252997786.png (127 KB, 678x288)
127 KB
127 KB PNG
it's time
>>
dfs<Tab>
>>
I don't get it
>>
eric has lost his touch
Day   -Part 1-   -Part 2-
4 00:03:06 00:04:19
>>
WHAT DO YOU WANT ME DO ERIC??
>>
>highlighted "@" to thwart LLMs
cheeky cunt
>>
Opus 4.5 is now 8/8
>>
Day   -Part 1-   -Part 2-
4 00:05:51 00:09:46


baby-tier. and to think i was scared after day one
>>
File: code.png (288 KB, 1618x1698)
288 KB
288 KB PNG
Day   -Part 1-   -Part 2-
4 00:05:59 00:09:01

that was easy
i wasted an unbelievable amount of time due to not paying attention and thinking the blocks were # like he usually uses instead of @
>>
>hmm my site has dogshit contrast
>ah yes i'll use highlighting
he's not just a jew, he's a nigger too
>>
>tfw p1 fails because im checking `count < 4` not `count > 4`
Day   -Part 1-   -Part 2-
4 00:10:11 00:11:01
3 00:09:06 00:22:08
2 00:04:58 00:08:51
1 00:04:57 00:06:06
>>
File: carbon.png (115 KB, 1702x650)
115 KB
115 KB PNG
Day   -Part 1-   -Part 2-
4 00:04:56 00:09:17
>>
File: d04_021200.png (146 KB, 960x1696)
146 KB
146 KB PNG
10 mins. Simple bruter.
>>
>>107428449
at least i may have the quickest p1->p2 recovery?
time to golf and optimise, see you lads in 20
>>
eric has given up, this is embarrassing
12 puzzles and he makes them this fucking easy
>>
brootbros we keep winning
>>
Somehow it took until day 4 to get a problem where I solved both parts in 10 minutes
>>
>day 12
>the elves need your help adding all the numbers in this list
>can you save christmas???
>>
>>107428469
it's the inclusive era, we can't offend any coders now can we?
>>
Should be relatively straight forward to do in ASM as well.
>>
File: 2025_day4.png (53 KB, 1613x507)
53 KB
53 KB PNG
We got off easy today.
>>
File: carbon.png (111 KB, 421x978)
111 KB
111 KB PNG
Day   -Part 1-   -Part 2-
4 00:03:35 00:09:25

>easiest day so far
Well, alright then.
>>
>>107428476
Fuck we are screwed.
>>
come on eric, I won't even bother washing my code
>>
File: goncern.png (6 KB, 253x199)
6 KB
6 KB PNG
This should've been day 1 and day 2 should've been day 4.
>>
File: xarbon.png (16 KB, 540x772)
16 KB
16 KB PNG
what a boring no think retard day
congrats eric

Day   -Part 1-   -Part 2-
4 00:09:55 00:15:41
3 00:01:55 00:15:28
2 00:03:27 00:07:29
1 00:02:36 00:11:01
>>
>>107428474
A third of the way through, and it's still this easy. Sad.
>>
Guess this means day 5 has to be the dickpunch, right?
>>
Assuming similar difficulty scaling, this is supposed to be a day 8 problem
>>
>aoc 2025
Oops! All day 1s
>>
any non-brute algorithms?
>>
Part 1
data = open("Day 04 input.txt", "r").read().strip().split("\n")
grid = set()
for y, line in enumerate(data):
for x, char in enumerate(line):
if char == "@":
grid.add((x,y))

total = 0
for i in grid:
near = 0
for x in (-1,0,1):
for y in (-1,0,1):
if (i[0]+x,i[1]+y) in grid:
near += 1
if near <= 4:
total += 1

print total

Part 2
data = open("Day 04 input.txt", "r").read().strip().split("\n")
grid = set()
for y, line in enumerate(data):
for x, char in enumerate(line):
if char == "@":
grid.add((x,y))

removed = 0
while True:
removals = set()
for i in grid:
near = 0
for x in (-1,0,1):
for y in (-1,0,1):
if (i[0]+x,i[1]+y) in grid:
near += 1
if near <= 4:
removed += 1
removals.add(i)
for i in removals:
grid.remove(i)
if len(removals) == 0: break

print removed

Easy day. Overcomplicated it by using sets, I expected part 2 to be harder
>>
that was easier than day 1 what the fuck i didn't even have to cheat by looking at your guys solutions
>>
>>107428524
a second dictionary of coordinates -> neighboring count that you can just update as you go rather than checking every cell repeatedly would be fast
>>
This year's event feels so half-baked. The difficulty is all over the place with these puzzles. There's basically nothing interesting to this one. I think eric has developed a weed habit.
Sad.
>>
File: RISCV_day4.png.png (476 KB, 1394x3016)
476 KB
476 KB PNG
Unwashed ass. Broke part 1 to do part 2 but both worked first try which is nice.
>>
I JUST WASTED 10 MINS BECAUSE I EXCLUDED THOSE WITH 0 NEIGHBORS AAAAAAAAAAAAHHHHHHHHHHHHHHHHHHH
>>
>>107428528
i thought it was gonna be like "when you move one it actually makes all the others resettle and they move around in this really complex pattern" but no just keep iterating till you can't no more. fuckin eric, man
>>
File: 1752405380238512.png (164 KB, 517x1814)
164 KB
164 KB PNG
Day   -Part 1-   -Part 2-
4 00:16:51 00:20:57

C

why was it so easy today???
>>
part 2 should've been part 1, and the real part 2 is something like being allowed to remove ten rolls without restrictions and finding which you should remove to clear the whole grid
>>
Eric vibe coded this year's AOC.
>>
File: file.png (790 KB, 938x1013)
790 KB
790 KB PNG
good morning sir
kindly see needful answer
i make code with gorgous looks!

~ H.B. Gopalakrishnan
>>
>more money
>less puzzles
>shittier puzzles
shalom eric
>>
File: 1754113815293140.png (531 KB, 815x557)
531 KB
531 KB PNG
IT JUST KEEPS GETTING EASIER

Unwashed Nim.

Day   -Part 1-   -Part 2-
4 00:19:52 00:24:45
>>
File: swift_day4.png (240 KB, 1598x1320)
240 KB
240 KB PNG
I was about to write "brootchads won again", but this problem is easier than day 1, there is nothing to broot. Literally following the instructions step by step solves everything.
>>
holy shit this lazy motherfucker
>>
I still believe in Eric
He's been holding back
But four easy problems is enough
He's about to drop the hammer
>>
File: wastl1.png (10 KB, 600x600)
10 KB
10 KB PNG
surely it will get more difficult on the weekend right
>>
>create puzzle with claude >>107428566
>send puzzle to claude >>107428433
Umm.. we're literally becoming slaves to AI
>>
this problem isn't event interesting to try and optimize. literally the only thing that could save this puzzle is some erotic elf from the drawfriend
>>
File: 1674901779540607.jpg (31 KB, 656x679)
31 KB
31 KB JPG
A nice and easy puzzle. Too bad for all of the braggards and show offs here.
>>
brootchads won again
>>
File: 4.png (1.09 MB, 5546x3582)
1.09 MB
1.09 MB PNG
trivial day
>>
>>107428621
wow, rust is an ugly language
>>
isn't an O(n) solution very trivial?
take the first row for example
walk left and right pointers simultaneously from the left and right inwards
then do the same for the rightmost column, last row, leftmost column, etc.
>>
File: d4.png (263 KB, 1198x2131)
263 KB
263 KB PNG
why was this so easy? I expected to at least have to print the grid back out to debug it.
>>
File: Day04_CShart.png (113 KB, 774x1241)
113 KB
113 KB PNG
Easiest day so far
Task 1: 1569
Task 2: 9280
Day 04 finished in 00:00:00.2817095
>>
fuck. I had no idea how to do shit in zig
>>
>>107428621
>not a single input.shit().gobbledygook()
not idiomatic
>>
>>107428604
>inb4 "What's the most rolls you can remove while leaving the largest prime number on each row such that there are is a prime number of rolls on the grid in total"
>>
>you will NEVER experience 2019 intcode kino again thanks to redditors
>>
>>107428604
everyone will just go hyper autistic about perf then
i've got it down to 1.3ms
>>
File: carbon.png (505 KB, 1414x3426)
505 KB
505 KB PNG
ugly ass code even after trying to clean it up a little. there's just no interesting way to do this, made me think back to writing game of life in college
>>
File: d15_023307.webm (2.78 MB, 400x200)
2.78 MB
2.78 MB WEBM
>we didn't get to drive around the forklist
Sad!
>>
File: 1761231593006247.png (47 KB, 534x839)
47 KB
47 KB PNG
I lost a ton of time trying to be lazy using try-except instead of actually checking bounds, neglecting that x[-1] is a completely valid index and just wraps around instead of failing. unwashed ass
>>
File: Day 04-2.webm (270 KB, 556x556)
270 KB
270 KB WEBM
Quick visualization in AoC colours
>>
>>107428681
>no forklift simulator game where you're drunk on the job and need to avoid the roaming supervisors
>>
>>107428678
>const int SIZE
Yikes.
>>
>>107428692
looks kinda cool
>>
>the C & C++ -tards solutions are nigh identical
interdasting
>>
>>107428621
queer taylor? from georgia?
>>
>>107428692
>showing your input
you fool! eric has you doxxed now
>>
>>107428692
Very nice.
>>
>>107428706
yes, indeed
>>
>>107428524
i will try to implement this: >>107428633
if it works, it's O(n)
>>
File: strongestgird.png (731 KB, 1241x866)
731 KB
731 KB PNG
Eric COULDN'T POSSIBLY make 25 of these puzzles a year. 12 is the absolute maximum. The sheer artistry to come up with such genius and UNIQUE puzzles is incredible...... and he ONLY has ONE MONTH to make each one! Thank GOD Eric is focusing on his mental health and cut down on his output to ensure only the HIGHEST QUALITY puzzles.

Not even going to bother posting my solution today, its the same as everyone elses. What a joke. FUUUUUUCK YOU TO DEATH ERIC
>>
>>107428695
dynamically sized arrays would be wasted on this problem
>>
>got it running sub 1ms
bring on the bigboys
>>
bigboy #4
https://files.catbox.moe/pj1x30.7z
2023510
5520583
>>
File: carbon.png (78 KB, 826x493)
78 KB
78 KB PNG
>>107428494
Code golfed it down as much as I can be bothered.
>>
>>107428721
>.7z
nice virus
>>
bring on the non-virus extension big boys*
>>
>>107428494
>>107428722
>from aoc import solution
>>
>>107428726
>imports aoc library on easiest grid puzzle of all time
>still 50 lines
??????????????????????????????????????????? literally how
>>
>>107428721
>7z
>>
File: aoc_python_day4.png (1.15 MB, 818x767)
1.15 MB
1.15 MB PNG
Haha, holy boy you guys are fast. I got my answers in pretty quick so I checked the leaderboard, but ya I got smoked. GG! I always enjoy grid stuff. That robot last year was fun.
>>
>>107428692
Woah cool!
>>
File: 1744949405105861.png (61 KB, 309x1039)
61 KB
61 KB PNG
Misread the problem thinking the . where forklifts/potential positions and it was the adjacent squares around the forklift, not the rolls of paper. Tomorrow I WILL get a better time.
Day   -Part 1-   -Part 2-
4 00:30:19 00:33:28
>>
>>107428451
nice desu

>>107428717
any bfs sol will be O(n). what you are optimizing for here is queue/stack space. I am thinking of a counter example where the chain reaction starts from the center of the grid. your approach might fail for that
>>
>>107428681
That's the one! Haha ya that one was fun do and watch.
>>
>>107428692
what do people use to make their simple visualizations for grid puzzles?

If you put a gun to my head and forced me to make one without googling, I would use matplotlib to make each frame and then stitch them into a gif, but I would like to know a 'proper' way to do it.
>>
>>107428760
>your approach might fail for that
if i do a second pass (still linear time) from inside-out, then it should work, right?
>>
File: reisen.jpg (395 KB, 788x1600)
395 KB
395 KB JPG
Hello saars JSfag here
Part 1 and 2 solved in under 10 mins but then again this was another trivial puzzle...
>>
File: 23895748372.png (19 KB, 364x136)
19 KB
19 KB PNG
>>107428721
It takes one whole second for my code to solve it, but the puzzle is so ass I have no motivation to optimize it.
>>
Tfw we will never have the opcode machine ever again. Why live.
>>
https://files.catbox.moe/z039pm.txt

Bigboy day04.
>>
rustfmt is lagging lmao
>>
>>107428692
This goes to show that it's better to make a stack of every removed node and check it's neighbours instead of iterating over the entire grid... Hmmm
>>
>>107428806
>txt
nice virus
>>
>>107428781
if I were to do it without looking up docs for any libs then https://nullprogram.com/blog/2017/11/03/
Basically, you can just print ppm of each frame to stdout and pipe that to mpv specifying the fps.

>>107428789
idk anon, sounds messy. and finding edge case inputs can be challenging too. not sure how to prove correctness
>>
>>107428805
forget intcode, we will never have day 13 ever again. It's fucking over bro
>>
>>107428781
output a series of PPM images
feed it into ffmpeg.
ask ChatGPT if you don't know how to do either.
>>
>>107428823
I doubt it
That's hard to parallelize and and not a predictable memory access pattern
>>
File: 1742265019313281.gif (292 KB, 408x405)
292 KB
292 KB GIF
>>107428781
import numpy as np
from PIL import Image


newpixelsize = 3

gif = []
images = []
numpic = 0
for i in range(58):
filename = "frames" + str(numpic) + ".txt"
with open(filename, 'r') as f:
lines = f.readlines()
trees = []
width = len(lines[0])
height = len(lines)
trees = np.zeros([newpixelsize*height, newpixelsize*width])

for i in range(len(lines)):
for j in range(len(lines[0])-1):

newval = int(lines[i][j]) * 128
for m in range(newpixelsize):
for l in range(newpixelsize):
trees[i * newpixelsize + m ][j * newpixelsize + l] = newval

colortrees = np.zeros([height*newpixelsize, width*newpixelsize, 3])
for i in range(len(colortrees)):
for j in range(len(colortrees[0])):
colortrees[i][j][1] = trees[i][j]
colortrees[i][j][2] = trees[i][j] / 5
colortrees[i][j][0] = trees[i][j] / 5




array = np.array(colortrees, dtype=np.uint8)
img = Image.fromarray(array)
img.convert("RGB")
gif.append(img)
numpic +=1
print(numpic)
# img.save('trees.png')
gif[0].save('temp_result.gif', save_all=True,optimize=False, append_images=gif[1:], loop=0)


This is shit code but this is what I wrote years ago and keep reusing to make gifs such as this one
>>
>>107428830
>ppm images
ah thats basically the thing I was looking for, a minimal image format I can generate myself that plays nice with other programs. Thanks!
>>
Made my own grid for this challenge
https://litter.catbox.moe/w9lqqeemw4gl125b.txt
>>
>>107428781
Many approaches.
If you don't want to use any libraries, you can output all frames as .pbm/ppm/pgm (a trivially easy uncompressed image format), and stitch it together with ffmpeg. You could use PNG if you have a way to save it.
In this case, I used pygame to do the rendering, with a very simple wrapper to feed it directly into ffmpeg for video encoding without saving the frames in between.
>>
>>107428721
eight seconds fuck
what's the big brain way?
>>
>>107428849
i was gonna suggest you do it with bmps but those have headers
>>
>>107428857
the big brain way is not downloading obvious viruses
>>
File: d04_025439.webm (67 KB, 552x552)
67 KB
67 KB WEBM
Totally original visualization.
>>
>>107428828
i'll let you know if it shows more promise
>>
Part 3 - Find the longest perimeter remaining
>>
I knew a "it's a grid and you have to count boxes around" puzzle was coming.

Now we just need to sokoban it up.
>>
File: 1753368538033265.png (23 KB, 523x486)
23 KB
23 KB PNG
>>107428781
>>107428848
Thhe "frames" file mentioned here is just the puzzle input at each step converted to digits for different colors
>>
>>107428321
Eric?
>>
>>107428127
Just barely made it bros... AGAIN, 45 minutes for part 1, 10 minutes for part 2... and that was with stealing some code from day 4 from last year... my brain just gets slower and slower.
>>
>>107428692
Interesting
>>
>>107428894
>my brain just gets slower and slower.
this. I could have done this in sub 10 minutes 10 years ago. I fumbled this puzzle HARD and i feel like a subhuman retard. (in my defence i read the problem wrong and coded the wrong fucking thing TWICE)
>>
File: 1753740616573751.png (424 B, 178x167)
424 B
424 B PNG
>>107428850
Someone please visualize this in inverse so we can use it for the next thread's OP.
I can't be assed to write a visualizer this year.
>>
>easier than average day 4
>Its actually day 8
bros... If tomorrow isn't a filter I might retire from aoc this year is the last straw
>>
>>107428781
just open any hex editor and manually type in the correct bytes to create the gif file you want
>>
>>107428903
My mega cope is that at least I get paid three times as much for my code as 10 years ago... but this shit has been a bit of an ego check the last few years.
>>
>>107428928
Always has been.
>>
Ok, tomorrow HAS to be an absolutely ballbusting day.
Lanternfish on a 4D gird and you have to find the exact steps when they form an animated Christmas tree, from a seed to turning into dust.
>>
File: d16-p2.webm (1.26 MB, 330x330)
1.26 MB
1.26 MB WEBM
>>107428737
Copy/pasted template + copy/pasted part 1 I hastily modified into part 2 and then couldn't be bothered washing after a particularly boring day.
I also woke up early and spent all day doing manual labor, so my number of fucks to give is especially low.

>>107428781
In years past I would generate images frame-by-frame using whatever, save them all as numbered .pngs in a folder, 00001.png, 00002.png etc; then stitch it together with ffmpeg.
Here's a shitty batch file.
cd %1%

set /A fps = %2%
if %fps%==0 (set fps=60)

ffmpeg -y -f image2 -r %fps% -i %%05d.png -vf fps=%fps%,scale=-1:-1 -an -c:v vp9 -lossless 1 -b:v 160k -quality best -pass 1 -f rawvideo NUL
ffmpeg -y -f image2 -r %fps% -i %%05d.png -vf fps=%fps%,scale=-1:-1 -an -c:v vp9 -lossless 1 -b:v 160k -quality best -pass 2 ..\%1%.webm

I think lossless VP9 is still the best format for this stuff that we can post here.
>>
>>107428721
Render (80+ MB LOL): https://files.catbox.moe/e2dhgd.webm
Can't shrink it enough to post no matter what I try. If anyone wants to try, go for it.
>>
>>107428931
At this point the only joy I get are from the memes and the drawfags, otherwise I wouldn't even bother.
>>
File: d4b.png (177 KB, 1422x1405)
177 KB
177 KB PNG
>>107428634
uglified and slowed it down a bit
>>
>>107428936
>video can't be played because corrupt
You need to set -pix_fmt yuv420p
>>
File: 1751450024731012.jpg (211 KB, 1024x1024)
211 KB
211 KB JPG
>>
>>107428936
As another renderfag, lossless VP9 is my go-to for these
>>
>>107428934
I have been saying this cope every puzzle for 5 years. I don't think we are getting one. Why eric panders to the day 1 filtered audience is beyond me. He makes the puzzles easier every year to reduce filtering and the filter rate is the same. It always will intrinsically be high just for asking people to check in every day for a month. GIVE US HARDER PUZZLES ERIC
>>
>>107428063
Waking up at 6AM every morning to do these and then heading to work afterwards is fucking breaking me. I don't have the self control and surrounding life to facilitate me going to sleep any earlier than 1AM, so I sleep 4-5 hours every night.
I might keep it up until the weekend and then I'm going to do them at 9AM at the office. I'm so glad we're skipping sinterklaas this year, having the pressure of buying presents and family gatherings this weekend would've killed me.
I hope this to be the first year I don't burn out.
>>
>>107428840
Yeah I just rewrote it something like this
stack = Set
for x, y in grid:
if x, y == @: stack.add(x,y)
while stack not empty:
x,y = stack.pop
if x,y neighbours < 4:
x,y = .
count++
for x2,y2 in neighbours:
if x2,y2 == @
stack.add(x, y)


Runs like shit
Maybe all the set operations are too slow
>>
>>107428921
>>107428934
>expecting a hard puzzle on friday
Wait until the weekend, retards.
>>
okay interesting question to run by you autists
is there a single configuration which is `immune' from which all other immune blobs are composed?
.@@.
@@@@
@@@@
.@@.

this is immune... can one check how many are immune in one pass then subtract that from the total?
>>
>>107428946
Yeah, colorspace is RGB. Works on my machine, but I'll keep that in mind if there's anything worth rendering this year.
>>
>>107429007
oh and an immune blob composed of these immune units would be for example
..@@.
.@@@@
@@@@@
@@@@.
.@@..
>>
>>107428999
>expecting a hard puzzle on the sabbath
wait until monday, retard
>>
>>107429011
It may just be Firefox and a handful of codecs that bitch about not having it defined.
>>
>>107429007
>>107429019
How would you find all the immune configurations? Can a configuration such that it is not immune initially, but after some removals it is? Way more difficult than the trivial solutions.
>>
Maybe next year I'll start with a list of progressively more difficult languages and each day I have 24 hours to solve in as many as I can.
Ones I don't solve in time get eliminated.
>>
>>107429059
Can I unsubscribe from your blog
>>
>>107429046
my gut tells me anything which is not a member of such a blob is removable
just match this pattern?
~@@~
@@@@
@@@@
~@@~

where ~ is a wildcard (may be an @ but we don't care)
>>
>>107429063
Interesting, but there are other configurations that cannot be removed too, apart from these. See >>107428868 .
>>
>>107429081
ah fuck some patterns can inherit immunity from immune neighbours
>>
>>107429062
No.
>>
File: day4.gif (485 KB, 408x408)
485 KB
485 KB GIF
Yet another visual.
>>
>>107429059
once you've got it in any language, the language stops mattering. Chrestomathy is still fun but this idea isn't a test of anything but your patience.
>>107428944 (me)
looping over all 9 coords isn't so bad with this problem, which lets me drop Dirs:
bool accessible(Coord c) {
int blocked;
foreach (y; c[0] - 1 .. c[0] + 2)
foreach (x; c[1] - 1 .. c[1] + 2)
blocked += ([y, x] in g) !is null;
return blocked < 5; // +1 for self
}
>>
File: reeeeeeenc.webm (907 KB, 330x330)
907 KB
907 KB WEBM
>>107429030
I'll have to experiment with it. RGB doesn't map to YUV 4:2:0 completely cleanly, so the colors change a bit.
Although, in this particular instance it's an improvement.
>>
>the elves just spilled hydrochloric acid on the floor!
>find all the squares that are protected from all sides (including diagonals) from the spill by the remaining rolls
>>
To everyone complaining the puzzles are too easy, this is a self inflicted skill-issue. Switch your language/increase your constraints until the puzzles become sufficiently hard. Exotic hardware, make visualizations, bring the SOVL back to /aocg/
>>
>>107429136
>advent of flood-fill
>>
>>107429137
>this is a self inflicted skill-issue.
Na. The puzzles are too easy.
>>
>>107429137
>hurr durr if 2+2 is too easy for you then solve it in assembly
fuck off eric write better puzzles
>>
Trivial problem today. Done this type of shit many times at this point. Nice to get this one out of the way so I can do other stuff tonight, although a bit disappointing that the puzzles don't seem to be ratcheting up at all even after being a third of the way through already.
>>
>>107429109
he should have made part 2 be part 1 and part 2 be counting the number of islands in the final generation
>>
>>107429149
Its a solution that can and will make aoc fun again. Eric is a lazy reddit retard, harder puzzles arent going to happen and we all know it.
>>
>>107429183
then i will quit and eric can enjoy his empire of dust
>>
>>107429188
this is an empty threat if you are still here after the past 5 lackluster years, lets be real. We are here forever no matter how shitty and easy he makes the puzzles.
>>
File: 1756800633773614.webm (315 KB, 480x480)
315 KB
315 KB WEBM
>>107428907
Whatever, I made a visualizer now I guess.
>>
>>107428721
first try, 2.5min, 1.74 GB MaxRSS
after washing and figuring I made it worse, 51s and 644 MB
obviously an array solution like >>107429169
is going to do better on memory than a set of coords
>>
File: 084716.png (110 KB, 1600x874)
110 KB
110 KB PNG
Fun problem
>>
File: 1745138911233850.webm (67 KB, 501x480)
67 KB
67 KB WEBM
>>107429202
Had to make it a little random to make it disappear fully.
>>
guys its ok, eric has apologized for not making good enough puzzles: https://old.reddit.com/r/adventofcode/comments/1pdrynb/
>>
I guessed the part 2, but expected it to more complicated, like an additional instruction "if all toilet papers from a row are removed, all papers above will fall down"
>>107424958
very cool visualization
>>
>>107429063
>>107429081
oh here is a smaller immune configuration
@@@
@@@
@@@

i suppose you could bfs from these primordial immune blocks which would cut the search space down considerably
>>
>>107429251
That's not immune, the corners die
>>
>>107428721
This code >>107429169

Silver: 2023510
Gold: 5520583

real 0m1.455s
user 0m1.198s
sys 0m0.246s

Good enough for me.
>>
>>107429258
just noticed as soon as i posted
ffs
>>
>>107429242
>only 3 items
>only t-shirts
he really is fed up with aoc huh
[spoiler]good thing I got an aoc hoodie last year to celebrate 10y anniversary[/spoiler]
>>
just count the number of islands at the end of part 2 if you need a challenge goy
>>
>>107429251
Seeing diagonals count, positions can become immune by proximity to immune configurations.
It's not a winning strategy.
>>
File: 1750810395196541.webm (555 KB, 501x480)
555 KB
555 KB WEBM
>>107429234
Inverted and reversed
>>
File: next.png (10 KB, 408x408)
10 KB
10 KB PNG
>>107429173
Next!
>>
File: 1755973141588407.webm (56 KB, 501x480)
56 KB
56 KB WEBM
>>107429234
>>107429294
kek based anon
you had my idea but better
>>
>>107429296
anon they're all islands those are just the small ones..
how did you decide your cutoff?
>>
>>107429273
Still trivial
>>
>>107429007
a 5x5 square with 4 corners and the center removed is not composable by the other blobs you showed

%%
.@@@.
@@@@@
@@.@@
@@@@@
.@@@.%%
>>
it was not a good idea to try to solve this without indices / using generic shifting logic. 5 minutes to solve part 2 using 4 threads :\
>>
>>107429331
i also found this:
.@@..
@@@@.
@@.@@
.@@@@
..@@.

i think it's hopeless though
>>
>>107429327
attached to the mainland out of picture (at edges)
>>
>>107426233
Day1 was the most difficult so far desu, 2nd part had so many edge cases
>>
>>107429343
>>107429327
What my assistant said, and it's counting corners as connected.
>>
>>107429343
>>107429381
i saw it right after i posted
fair enough
>>
part 3.1 : the grid now wraps around
>>
>>107429273
>flood fill
>>
File: 1763412515808228.webm (371 KB, 408x408)
371 KB
371 KB WEBM
HE CAN'T KEEP GETTING AWAY WITH IT
>>
>>107429450
just needs to sum to 1488 and its perfect
>>
>>107428721

parse time: 3.4ms
part1: 2023510
time: 187ms
part2: 5520583
time: 216ms
>>
>part 3
>how many rolls of paper must be removed from your input for all the rolls to eventually be reachable by forklift?
>>
>>107428806
I dare people make visualisation for this one.

parse time: 1.4ms
part1: 2110
time: 24ms
part2: 2989011
time: 92ms
>>
import math

def totalFromLine(line, window):
numLine = [int(c) for c in line.strip()]
length = len(numLine)
total = 0
first = second = [-math.inf, 0]
for n in range(window):
left = second[1]
right = length - window + n + 1
first = second = [-math.inf, right]
for i in range(left, right):
if numLine[i] > first[0]:
first = [numLine[i], i]
if i + 1 < length:
second = [numLine[i+1], i+1]
elif numLine[i] > second[0]:
second = [numLine[i], i]
total += first[0] * (10 ** (window - n - 1))
return total

f = open("input.txt", "r")
p1 = p2 = 0

for line in f:
p1 += totalFromLine(line, 2)
p2 += totalFromLine(line, 12)

print(f"Silver: {p1}, Gold: {p2}")


I'm not sure the time complexity but it took me forever to come up with a non-bf algorithm. Sloppy and I think it repeats work.
>>
File: d4c.png (179 KB, 1486x1306)
179 KB
179 KB PNG
>>107429207
bigboy-optimized d wash, 600ms in 227MB, still works for input and example
also reports the number of loops as a side-effect of my not wanting some if(!silver) logic.
>>
File: 1752098169491723.png (1 MB, 1592x796)
1 MB
1 MB PNG
>>107429516
I think I'll just have another ale
>>
File: ericNo.gif (718 KB, 408x408)
718 KB
718 KB GIF
Ughh Eric, what's going on with my input?
>>
>>107429486
>part 4
>you need to walk (by foot) to each of those rolls in order to remove them
>you can hold an unlimited amount of rolls with your magical bag of holding but each roll carried adds an extra step when moving across the grid
>exiting the grid from any side will let you drop all the rolls by giving them to the elves
>you will also need to exit the grid after picking up the last roll to give it to the elves
>what is the minimum distance to reach all of the rolls
>>
>>107429521
hovers around 6.5ms i forgot to add ^^
>>
File: unwashed25.04.png (32 KB, 508x2029)
32 KB
32 KB PNG
Tomorrow will be crushing if this is what he went with today. At least that would be true if he didn't kill aoc by cutting it in half.
>>
>>107429524
Is this Zig? Looks pretty comfy. Maybe I will learn that next year
>>
>>107429537
>also if you don't finish in 30 minutes all the elephants while burn alive in lava
>>
File: carbon.png (739 KB, 1564x4022)
739 KB
739 KB PNG
ezpz
>>
>>107429585
it's been years, anon
they're all dead
>>
>>107429516
Both answers are 2 less than mine :<
Try the other bigboys that have answers posted, anon.
>>
File: 1763038710996140.png (86 KB, 375x305)
86 KB
86 KB PNG
>>107429534
>>
>>107429617
My bad, I modified the file as I was running it.
The other bigboys, the example and my input work properly.

parse time: 1.4ms
part1: 2112
time: 23ms
part2: 2989013
time: 93ms
mem usage: 204800
>>
In J this is just
in =. ('@'&=);._2 ] 1!:1 <'input_4.txt'

p =. 0:,],0:
f =. *. 3 3 (5 > +/^:2);._3 [: p p"1
] p1 =. +/^:2 f in
] p2 =. +/^:2 in - (- f)^:_ in
>>
>>107427339
>>107427278
also known as sliding window maximum
https://leetcode.com/problems/sliding-window-maximum/
>>
File: pic-window-221108-1133-39.png (177 KB, 3842x2162)
177 KB
177 KB PNG
> puzzle is clearly a game of life version with some different rules
> no one make cellular automata optimization for their solution
This board in not anymore what was a time
>>
File: lolwut.png (121 KB, 250x279)
121 KB
121 KB PNG
>>107429671
>This board in not anymore what was a time
>>
>>107429671
>cellular automata optimization
LOL. Talk about typing things you have no idea about.

>game of life version
>with some different rules
Hmm, I wonder if anyone has ever enumerated all of those “game of life” rules.
>>
>>107429450
>>107429313
>>107429294
>>107429234
>>107429534
based
>>
>>107429671
it's not game of life because you never create new cells
it's a game of death
>>
>>107429720
game of life for the '.'s
>>
>>107429671
idk bro for me it was a djikstra and flood fill problem
>>
>>107429718
Y-YYIKES!!!!!! I thought problematic racists were le stupid?
>>
>>107429727
a game of senseless reproduction
'.'s are nigger-coded
>>
>>107429741
seethe
>>
Last year I did all 50 stars for the first time, then went back and did 2015-2017 and some of 2018, reading /aocg/ here in parallel—those old days were glorious. Was greatly looking forward to starting 2025 on Dec. 1, and was a bit disappointed to read the "12 days" announcement, but fine, it was totally understandable.

Days 1 and 2 were normal but somehow today, Day 3, when I read the word "joltage", I don't know, I just ... stopped. The silly jokes, the elves and their "technology", the green-black matrix we get to live in, the Christmas tree, the whole ... universe ... is incredible. Along with this community to meme every single problem.

Today, I felt really sad.

What Eric has created here is so special. I'm very grateful for the 10 prior years, that I still have 2018-2024 left to finish, and however many 12-day years he has left in him—even if this one is the last—are enormously appreciated. Thank you.
>>
>>107429661
Reminds me of the time a long time ago when I took a course of APL at the university with a super old professor. We called APL a "write-only language". Because once you wrote a program, you couldn't read or understand it.
>>
>>107428721
easy
resultA: 2023510
resultB: 5520583

real 0m0,733s
user 0m0,612s
sys 0m0,120s
>>
>>107429775
today was day 4 though
>>
>>107429671
Well? Where is your "cellular automata optimization"?
>>
>>107428721
2023510 5520583
582ms

>>107428806
2112 2989013
58ms

The times are for both parts. P1 is essentially free with P2, so just consider these as P2 times. This includes taking input from stdin.
>>
>>107429789
Optimizations borrowing from hashlife. Using hashing and quadtrees. desu most input are too dense to yield any significant improvement
>>
File: common-lisp.png (284 KB, 909x1056)
284 KB
284 KB PNG
common lisp today since scheme isn't a good fit
>>
>>107425275
8191811111111111111
>>
File: aoc04.png (160 KB, 1280x1479)
160 KB
160 KB PNG
another comfy day thanks eric
>>
File: carbon.png (155 KB, 1574x830)
155 KB
155 KB PNG
>>107429996
This weekend we'll get some hard ones, surely. We won't get another weekend…
>>
File: cat.jpg (127 KB, 1024x999)
127 KB
127 KB JPG
>>107430077
>We won't get another weekend…
eric did not think this one through wtf
>>
>>107430087
>over in bit over a week
this fucking sucks
>>
I'm too depressed this year to do it and I haven't been in any of the threads. How has it been? Are the questions at least better given there are only 12 of them?
>>
>>107430113
no they have all been incredibly easy
>>
>>107430113
day 1 was a rough start but compared to elephants or lanternfish or THE CUBE it has been relatively easy
>>
>>107430136
was it worse than... I think 2 years ago there was a day 1 question that everybody thought was abnormally difficult? It wasn't 'hard' just unexpectedly hard.

>>107430123
well it's still only 4 days in, things don't start to get kind of difficult until the mid/late teens, so day 7or 8 probably if things map onto it the same.
>>
>>107430152
it was way easier than twone
>>
>435 replies
>inb4 another retarded op image baked thread

keep it up faggot
>>
>>107430194
I will
>>
>>107430113
>I'm too depressed this year
Stop being a faggot and get gud. ffs.
>>
>>107430113
that was kind of me last year
>>
Well, that was easy
>>
i got 0.5s in python for day 4 buy just adding padding rows and columns on the sides and not worrying about boundary conditions. is there a way to make it faster
>>
>>107430077
>We won't get another weekend…
I'm mad that this is true
>>
>>107430113
Well, Day 1 was good for a Day 1. Day 2 was better. Day 3 and Day 4 are webdev tier.
>>
>>107430289
Yep.
>Rewrite it in a good language
>Remove the padding
>>
waow can't believe this unexpected devilish twist in Part 2 required me to... loop Part 1 solution a few times? Bravo Eric
>>
>>107426379
Why can't you sort them based on their score?
>>
File: file.png (3 KB, 216x116)
3 KB
3 KB PNG
>>107427016
If I wasn't the original poster I would think I was samefagging as an excuse for my slow code.
>>
>>107426379
>-13%
OH NO NO NO NO NO NO NO NO
>>
NEW THREAD >>107430428
>>
>>107428721
  Time (mean ± σ):     12.337 s ±  0.242 s    [User: 12.268 s, System: 0.037 s]
Range (min … max): 12.133 s … 12.805 s 10 runs

Parse: 1764841009.508678s
Silver: 1764841011.543498s
Gold: 1764841021.2640292s


Not even going to post the code. My problem is that I used too many allocation and my code is too stupid. I have some ideas of optimization like bitmapping and storing number of neighbors.
>>
You guys are being too negative. Imagine how good the puzzles will be next year when he cuts the event down to a single week, then he'll REALLY be able to focus on quality.
>>
>>107430514
I'm happy with the quality of this year's puzzles so far
>>
I would prefer if it was 12 days and every 2 days with the final day on christmas, not the first 12 days.
>>
>>107430524
or maybe a part 3 every 2nd day
>>
File: day3.png (164 KB, 1312x1128)
164 KB
164 KB PNG
my unwashed day3 solution
>>
File: code.png (322 KB, 1672x2188)
322 KB
322 KB PNG
Python



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