>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
no cutting down the trees
previous >>110492229
← /g/
/aocg/ - Advent of Code General #3
New launches split creator fees 50% to the poster and 50% to the launcher. No tripcode is needed to launch; poster claims require verified ownership.
it is hard to come up with good op images ok
>>110501980
Visualizations are always an option, there were a couple in the last thread.
Visualizations are always an option, there were a couple in the last thread.
Which year would you say was the best year?
smolboy for slowanons
https://files.catbox.moe/6uq5vr.txt
silver 17132
gold 4471945
https://files.catbox.moe/6uq5vr.txt
silver 17132
gold 4471945
>>110502058
2021-2022 for me since those were my first but I hear good things about intcode
need to get around to it at some point
2021-2022 for me since those were my first but I hear good things about intcode
need to get around to it at some point
>>110502056
I have over 10 years of Rust experience.
Furthermore, I have all stars in advent of code, all ducks in everybody.codes and solved 317 project euler problems.
Lower your voice when speaking to me.
I have over 10 years of Rust experience.
Furthermore, I have all stars in advent of code, all ducks in everybody.codes and solved 317 project euler problems.
Lower your voice when speaking to me.
>>110502058
>>110502069
2019 (intcode) was good but it was definitely far from difficult, every problem description was just a step by step guide on what to do, there was not much thinking involved at all, which is probably why /g/ likes it so much. I liked the year with lantern fish and that infinite tape, whichever year that was.
>>110502069
2019 (intcode) was good but it was definitely far from difficult, every problem description was just a step by step guide on what to do, there was not much thinking involved at all, which is probably why /g/ likes it so much. I liked the year with lantern fish and that infinite tape, whichever year that was.
>>110502058
2017 hands down
2017 hands down

>>110502105
woah watch out, we have a badass over here
woah watch out, we have a badass over here
>>110502105
Good girl!
I was just asking, perhaps you can comment on yours compared to the other anon's solution? My rust is not very good, and I find yours less readable.
Good girl!
I was just asking, perhaps you can comment on yours compared to the other anon's solution? My rust is not very good, and I find yours less readable.
>>110502106
The challenge was having a working interpreter.
The challenge was having a working interpreter.
2021 was a ball puncher in general. Pretty even difficulty throughout.
>>110502105
Wow based
Wow based
>>110502105
I'm sorry but Gemini is better than you and it's not even close
I lower my typing noise when talking to her, you're nothing in comparision
I'm sorry but Gemini is better than you and it's not even close
I lower my typing noise when talking to her, you're nothing in comparision

>>110501964
I like mine more
I like mine more
>>110502398
yours is extremely inefficient though
yours is extremely inefficient though
can we deport this fucking indian immigrant agniggha from the leaderboard?
>>110502178
so the challenge was following step by step instructions
so the challenge was following step by step instructions

>>110502506
you won't do shit, timmy.
you won't do shit, timmy.
>>110502546
that's not agniggha though
that's not agniggha though
anons, if you use HashSet to look up only two tree locations. it will cut the execution cost from 140s to 4s
>>110502105
I want to get into Rust myself. What brand of estrogen do you recommend I take?
I want to get into Rust myself. What brand of estrogen do you recommend I take?
>>110502676
indexing into an array is cheaper than hashing the key and then probing the hashtable.
sop talking nonsense.
indexing into an array is cheaper than hashing the key and then probing the hashtable.
sop talking nonsense.
In Prolog, this is just
:- initialization(main, main).
:- dynamic t/2.
square(R, C, DR, DC) :-
t(R, C),
t(R2, C2), DC is C2 - C, DC > 0, DR is R2 - R, DR >= 0,
R3 is R + DC, C3 is C - DR, t(R3, C3),
R4 is R2 + DC, C4 is C2 - DR, t(R4, C4).
% part 1
count(1, N) :- aggregate_all(count, square(_, _, 0, _), N).
% part 2
count(2, N) :- aggregate_all(count, square(_, _, _, _), N).
load(File) :-
read_file_to_string(File, Str, []),
split_string(Str, "\n", "", Lines),
forall((nth0(R, Lines, Line), sub_atom(Line, C, 1, _, '#')),
assertz(t(R, C))).
main :-
current_prolog_flag(argv, Argv),
(Argv = [P|Rest] -> atom_number(P, Part); Part = 1, Rest = []),
(Rest = [File|_] -> true; File = input),
load(File),
count(Part, N),
format("~d~n", [N]).
:- initialization(main, main).
:- dynamic t/2.
square(R, C, DR, DC) :-
t(R, C),
t(R2, C2), DC is C2 - C, DC > 0, DR is R2 - R, DR >= 0,
R3 is R + DC, C3 is C - DR, t(R3, C3),
R4 is R2 + DC, C4 is C2 - DR, t(R4, C4).
% part 1
count(1, N) :- aggregate_all(count, square(_, _, 0, _), N).
% part 2
count(2, N) :- aggregate_all(count, square(_, _, _, _), N).
load(File) :-
read_file_to_string(File, Str, []),
split_string(Str, "\n", "", Lines),
forall((nth0(R, Lines, Line), sub_atom(Line, C, 1, _, '#')),
assertz(t(R, C))).
main :-
current_prolog_flag(argv, Argv),
(Argv = [P|Rest] -> atom_number(P, Part); Part = 1, Rest = []),
(Rest = [File|_] -> true; File = input),
load(File),
count(Part, N),
format("~d~n", [N]).

>>110501961
my p1 solution had a naive kinda raycaster thing going on, gave up and did it the proper way for p2
my p1 solution had a naive kinda raycaster thing going on, gave up and did it the proper way for p2
>>110502690
1. put tree coordinates in set
2. pick each pair from set
3. check 1st is topmost, 2nd is rightmost
4. derive next pair
5. check next pair in set
much cheaper
1. put tree coordinates in set
2. pick each pair from set
3. check 1st is topmost, 2nd is rightmost
4. derive next pair
5. check next pair in set
much cheaper
>>110502706
based
we need more like this in this thread
there used to be so many anons solving in niche languages
can't believe how rare you niggers have become now
based
we need more like this in this thread
there used to be so many anons solving in niche languages
can't believe how rare you niggers have become now
>>110502747
1. put tree coordinates in a list
2. pick each pair from list
3. check 1st is topmost, 2nd is rightmost
4. derive next pair
5. check next pair in list
notice how I'm not hashing anything?
1. put tree coordinates in a list
2. pick each pair from list
3. check 1st is topmost, 2nd is rightmost
4. derive next pair
5. check next pair in list
notice how I'm not hashing anything?
i dont wanna google an algorithm, someone give me a hint on how you rotate a square
>>110502834
(x, y) rotated 90 degrees around (0, 0) is (-y, x).
(x, y) rotated 90 degrees around (0, 0) is (-y, x).
>>110502841
90 degrees is the easy one, its all the degrees in between that confuse me
90 degrees is the easy one, its all the degrees in between that confuse me
>>110502812
is this a witness reference
is this a witness reference

>>110502885
here is a tip
here is a tip
>>110502800
I don't need to. Checking each pair in the list will cost more than simply indexing an array to see if there's a # there
I don't need to. Checking each pair in the list will cost more than simply indexing an array to see if there's a # there
>>110502871
https://en.wikipedia.org/wiki/Taxicab_geometry
If you're still confused. You rotate the slope basically.
https://en.wikipedia.org/wiki/Taxic
If you're still confused. You rotate the slope basically.
>>110502990
>simply indexing an array to see if there's a # there
but that's what I'm saying, see >>110502690
>simply indexing an array to see if there's a # there
but that's what I'm saying, see >>110502690
>>110502794
pretty based
pretty based
Tried a set solution for part A. Increased my time from 2 sec to almost a minute. Good experiment, though. Unfortunately I'll just have to accept my bigboy time at 25 min single threaded.

Lanternfish! While we wait for day 4, BigInt edition.
5,3,2,2,1,1,4,1,5,5,1,3,1,5,1,2,1,4,1,2,1,2,1,4,2,
4,1,5,1,3,5,4,3,3,1,4,1,3,4,4,1,5,4,3,3,2,5,1,1,3,
1,4,3,2,2,3,1,3,1,3,1,5,3,5,1,3,1,4,2,1,4,1,5,5,5,
2,4,2,1,4,1,3,5,5,1,4,1,1,4,2,2,1,3,1,1,1,1,3,4,1,
4,1,1,1,4,4,4,1,3,1,3,4,1,4,1,2,2,2,5,4,1,3,1,2,1,
4,1,4,5,2,4,5,4,1,2,2,4,2,2,2,1,3,5,2,5,1,1,4,5,4,
3,2,4,1,5,2,2,5,1,4,1,5,1,3,5,1,2,1,1,1,5,4,4,5,1,
1,1,4,1,3,3,5,5,1,5,2,1,1,3,1,1,3,2,3,4,4,1,5,5,3,
2,1,1,1,4,3,1,3,3,1,1,2,2,1,2,2,2,1,1,5,1,2,2,5,2,
4,1,1,2,4,1,2,3,4,1,2,1,2,4,2,1,1,5,3,1,4,4,4,1,5,
2,3,4,4,1,5,1,2,2,4,1,1,2,1,1,1,1,5,1,3,3,1,1,1,1,
4,1,2,2,5,1,2,1,3,4,1,3,4,3,3,1,1,5,5,5,2,4,3,1,4
part 1, 80 days: 359789
part 2, 256 days: 1631058187388
part 3, 10000 days: picrel
5,3,2,2,1,1,4,1,5,5,1,3,1,5,1,2,1,4
4,1,5,1,3,5,4,3,3,1,4,1,3,4,4,1,5,4
1,4,3,2,2,3,1,3,1,3,1,5,3,5,1,3,1,4
2,4,2,1,4,1,3,5,5,1,4,1,1,4,2,2,1,3
4,1,1,1,4,4,4,1,3,1,3,4,1,4,1,2,2,2
4,1,4,5,2,4,5,4,1,2,2,4,2,2,2,1,3,5
3,2,4,1,5,2,2,5,1,4,1,5,1,3,5,1,2,1
1,1,4,1,3,3,5,5,1,5,2,1,1,3,1,1,3,2
2,1,1,1,4,3,1,3,3,1,1,2,2,1,2,2,2,1
4,1,1,2,4,1,2,3,4,1,2,1,2,4,2,1,1,5
2,3,4,4,1,5,1,2,2,4,1,1,2,1,1,1,1,5
4,1,2,2,5,1,2,1,3,4,1,3,4,3,3,1,1,5
part 1, 80 days: 359789
part 2, 256 days: 1631058187388
part 3, 10000 days: picrel
HashSet::contains(tree) -> bool
is a 3500% improvement over
Iterator::contains(tree) -> bool
and that's a fact
is a 3500% improvement over
Iterator::contains(tree) -> bool
and that's a fact
>>110503508
even as the source of the Iterator gets smaller gets smaller it is much worse than a full size HashSet lookup
even as the source of the Iterator gets smaller gets smaller it is much worse than a full size HashSet lookup
>>110503508
well how are you building the hashset? by checking what each iterator contains and copying it over, retard
well how are you building the hashset? by checking what each iterator contains and copying it over, retard
I know how to optimize this but I don't feel like writing the code for it
>>110503508
I have to admit. i did break something in Part2 and now it's wrong. even though i didn't change any logic
I have to admit. i did break something in Part2 and now it's wrong. even though i didn't change any logic
people are going to get filtered
>>110503508
no shit?
no shit?
>>110503582
also this. you niggas aren't really using a hashset for this problem right? I could understand if you have like a 500+MiB text file where only like 1% are trees, but really.
also this. you niggas aren't really using a hashset for this problem right? I could understand if you have like a 500+MiB text file where only like 1% are trees, but really.
>>110502853
Not needed for this problem. However in general, it's best not to memorize formulas, rather you want to know why it works. Ask AI or consult books to walk you through it, here's a prompt:
>Don't give me the rotation matrix upfront. Walk me through discovering it. Start with the standard basis vectors in 2D, show how arbitrary vectors are built from them, then investigate what happens when the basis vectors are rotated. Use that to motivate matrix multiplication as a transformation, and eventually derive the rotation matrix. Ask me questions along the way rather than immediately giving me the answer.
Not needed for this problem. However in general, it's best not to memorize formulas, rather you want to know why it works. Ask AI or consult books to walk you through it, here's a prompt:
>Don't give me the rotation matrix upfront. Walk me through discovering it. Start with the standard basis vectors in 2D, show how arbitrary vectors are built from them, then investigate what happens when the basis vectors are rotated. Use that to motivate matrix multiplication as a transformation, and eventually derive the rotation matrix. Ask me questions along the way rather than immediately giving me the answer.
>>110498727
I have no fuckling clue where to begin on making sense of this. Can anyone give a breakdown on how this shit works? I already got the two stars but my approach is looks at all pairs of points and checks the squares on the edge pairs using math.
Explaining how this works might require a whole ass blog post so i don't really expect anyone to do it. But still it could help people learn how to do ts.
I have no fuckling clue where to begin on making sense of this. Can anyone give a breakdown on how this shit works? I already got the two stars but my approach is looks at all pairs of points and checks the squares on the edge pairs using math.
Explaining how this works might require a whole ass blog post so i don't really expect anyone to do it. But still it could help people learn how to do ts.
>>110503797
you forgot "make no mistakes", fucking imbecile
you forgot "make no mistakes", fucking imbecile
>>110503499
I mean... snoreville? shit runs instantly or will overflow u64 if too large...
I mean... snoreville? shit runs instantly or will overflow u64 if too large...
>>110503811
kek.
>>110503797
anon, this shit is trivial babby shit though.
https://en.wikipedia.org/wiki/Rotation_matrix
literally instant google result. since you only get cardinals 90, 180, 270 it's as trivial as swap, negate as already said. You can't do any other rots because that opens up the doorway to floating point inexactness.
kek.
>>110503797
anon, this shit is trivial babby shit though.
https://en.wikipedia.org/wiki/Rotat
literally instant google result. since you only get cardinals 90, 180, 270 it's as trivial as swap, negate as already said. You can't do any other rots because that opens up the doorway to floating point inexactness.
>>110503854
>shit is trivial babby shit though
Which you weren't born knowing. Googling is will give you a direct answer, but won't develop any understanding.
>shit is trivial babby shit though
Which you weren't born knowing. Googling is will give you a direct answer, but won't develop any understanding.
// if hashset.contains(&key_bottom_left) && hashset.contains(&key_bottom_right) {
// squares += 1;
// }
if coordinated.iter().any(|&k| k == key_bottom_left) && coordinated.iter().any(|&k| k == key_bottom_right) {
squares += 1;
}
the hashset solution doesn't work because the above are not equivalent and i don't know why
// squares += 1;
// }
if coordinated.iter().any(|&k| k == key_bottom_left) && coordinated.iter().any(|&k| k == key_bottom_right) {
squares += 1;
}
the hashset solution doesn't work because the above are not equivalent and i don't know why
>>110503913
what? if you took trig in skool, you could figure it out from first principles.
what? if you took trig in skool, you could figure it out from first principles.
>>110503920
Well the anon is old enough to enter an AoC contest and said he had trouble with other rotations, so I guess he didn't...
Why is it that when you try to help one retard, a bigger idiot comes along to brag that he already knows it?
>HURRR THING I KNOW MENTIONED.
Well the anon is old enough to enter an AoC contest and said he had trouble with other rotations, so I guess he didn't...
Why is it that when you try to help one retard, a bigger idiot comes along to brag that he already knows it?
>HURRR THING I KNOW MENTIONED.
>>110503943
the wikipedia page I linked is a better place to learn than any LLM slop.
the wikipedia page I linked is a better place to learn than any LLM slop.
Never spoon feed the retards! You will regret doing it every single time. Retards will always be retards, because they prefer to be. It's like giving money to the poor, it changes nothing, they'll be poor tomorrow.
>>110502706
I kneel, this is the first program I ever wrote in prolog and it sucks
:- initialization(main, main).
:- dynamic pair/3.
:- dynamic npair/4.
rpair(Lines, R, C1, D) :-
nth1(R, Lines, Line),
string_chars(Line, Cline),
nth1(C1, Cline, '#'),
nth1(C2, Cline, '#'),
C2 > C1,
D is C2 - C1.
r2pair(Lines, R1, C1, Dx, Dy) :-
nth1(R1, Lines, Line1),
string_chars(Line1, Cline1),
nth1(R2, Lines, Line2),
string_chars(Line2, Cline2),
nth1(C1, Cline1, '#'),
nth1(C2, Cline2, '#'),
C2 > C1,
R2 =< R1,
Dx is C2 - C1,
Dy is R1 - R2.
main :-
read_string(user_input, _, In),
split_string(In, "\n", "", Lines),
forall(rpair(Lines, R, C, D), assertz(pair(R, C, D))),
aggregate_all(count, (pair(R, C, D), R2 is R - D, pair(R2, C, D)), Result),
format("~d~n", Result),
forall(r2pair(Lines, R, C, Dx, Dy), assertz(npair(R, C, Dx, Dy))),
aggregate_all(count, (npair(R, C, Dx, Dy), R2 is R - Dx, C2 is C - Dy, npair(R2, C2, Dx, Dy)), Result2),
format("~d~n", Result2).
I kneel, this is the first program I ever wrote in prolog and it sucks
:- initialization(main, main).
:- dynamic pair/3.
:- dynamic npair/4.
rpair(Lines, R, C1, D) :-
nth1(R, Lines, Line),
string_chars(Line, Cline),
nth1(C1, Cline, '#'),
nth1(C2, Cline, '#'),
C2 > C1,
D is C2 - C1.
r2pair(Lines, R1, C1, Dx, Dy) :-
nth1(R1, Lines, Line1),
string_chars(Line1, Cline1),
nth1(R2, Lines, Line2),
string_chars(Line2, Cline2),
nth1(C1, Cline1, '#'),
nth1(C2, Cline2, '#'),
C2 > C1,
R2 =< R1,
Dx is C2 - C1,
Dy is R1 - R2.
main :-
read_string(user_input, _, In),
split_string(In, "\n", "", Lines),
forall(rpair(Lines, R, C, D), assertz(pair(R, C, D))),
aggregate_all(count, (pair(R, C, D), R2 is R - D, pair(R2, C, D)), Result),
format("~d~n", Result),
forall(r2pair(Lines, R, C, Dx, Dy), assertz(npair(R, C, Dx, Dy))),
aggregate_all(count, (npair(R, C, Dx, Dy), R2 is R - Dx, C2 is C - Dy, npair(R2, C2, Dx, Dy)), Result2),
format("~d~n", Result2).
>>110503964
I used to be a total retard and some people in the python irc channel were incredibly patient with my retarded questions about every other paragraph in the tutorial/official docs
I used to be a total retard and some people in the python irc channel were incredibly patient with my retarded questions about every other paragraph in the tutorial/official docs
>>110503950
Wikipedia is a horrible place to learn, mostly just formula dumps.
>LLM slop
Ah, you're an anti-AI retard. Well, your LLM could be instructed to use the 'Socratic method' to teach, and in the process discover what small piece anon was lacking.
Wikipedia is a horrible place to learn, mostly just formula dumps.
>LLM slop
Ah, you're an anti-AI retard. Well, your LLM could be instructed to use the 'Socratic method' to teach, and in the process discover what small piece anon was lacking.
>>110503973
had it as a part of a course I had and I could not wrap my head around the prolog strategy of appending to a list
had it as a part of a course I had and I could not wrap my head around the prolog strategy of appending to a list
>>110503805
It's not nearly as interesting as it might look, anon. Your solution is guaranteed better, in fact. I thought I was being clever in part 1 and rather than doing it properly in part 2 I kinda just kept churning.
Each row of the map becomes one big number, with a 1 bit wherever there's a tree. ANDing two rows then tells you every column where both have a tree, all at once for the given set of rows.
It's not nearly as interesting as it might look, anon. Your solution is guaranteed better, in fact. I thought I was being clever in part 1 and rather than doing it properly in part 2 I kinda just kept churning.
Each row of the map becomes one big number, with a 1 bit wherever there's a tree. ANDing two rows then tells you every column where both have a tree, all at once for the given set of rows.
>>110503993
They were grooming you.
They were grooming you.
why would I do this when claude could solve it in second?
>>110504039
In that case take a sit in the cuck chair while you see the AI doing it for you.
In that case take a sit in the cuck chair while you see the AI doing it for you.
>>110504054
ok snailcoder
ok snailcoder
>>110504039
fleshcels will NOT be able to reply because they know it's over for them
fleshcels will NOT be able to reply because they know it's over for them
>>110503997
not that anon but I sometimes have questions where I dont know if I can trust the llm explanations because the explanations are hard to verify
mainly for stats and ml stuff where I guess an example that comes to mind is asking why you optimize for a taylor or newton approximation of the loss or gradient instead of the loss or gradient in some cases
and while the llm answer might make sense you have no way of knowing whether it is making stuff up or if the actual reason is something else
not that anon but I sometimes have questions where I dont know if I can trust the llm explanations because the explanations are hard to verify
mainly for stats and ml stuff where I guess an example that comes to mind is asking why you optimize for a taylor or newton approximation of the loss or gradient instead of the loss or gradient in some cases
and while the llm answer might make sense you have no way of knowing whether it is making stuff up or if the actual reason is something else
>>110504088
ok cuckcoder
ok cuckcoder
>>110504026
think everyone brooted today, is there actually a smarter solution?
think everyone brooted today, is there actually a smarter solution?
>>110504026
only if your solution sucks, anon. mine completes in a few seconds.
only if your solution sucks, anon. mine completes in a few seconds.
>>110504120
I don't believe so.
I don't believe so.
>>110504123
What’s your solution?
What’s your solution?
>>110504026
squares=26584377 in 97.768641s
on a i5-2400 CPU
i would really like to know how fast it would be on a good one
squares=26584377 in 97.768641s
on a i5-2400 CPU
i would really like to know how fast it would be on a good one
>>110504120
There can be n^2 squares and I can't see any way to avoid enumerating every square
There can be n^2 squares and I can't see any way to avoid enumerating every square
>look over 2025 stuff
>remember problems that Eric protected babbies from edge cases
why did he do it?
>remember problems that Eric protected babbies from edge cases
why did he do it?

>>110504144
not that anon but you cant call your solution a broot if you at any point iterated over trees instead of rawdogging the whole (padded) array and every possible side-vector
not that anon but you cant call your solution a broot if you at any point iterated over trees instead of rawdogging the whole (padded) array and every possible side-vector
>>110504002
The teacher for the course I was supposed to learn it in had a sabbatical, the temporary replacement one taught us haskell instead
The teacher for the course I was supposed to learn it in had a sabbatical, the temporary replacement one taught us haskell instead
>>110504196
I can probably make it faster with parallelization.
I can probably make it faster with parallelization.
>>110504039
Good question, anon. You should ponder it as you close the tab.
Good question, anon. You should ponder it as you close the tab.
>>110504199
The class is called "logical and functional programming", so its just kinda stupid in that regard
The class is called "logical and functional programming", so its just kinda stupid in that regard
>>110504267
I would expect a bit of both to be fair rather than just one or the other
I would expect a bit of both to be fair rather than just one or the other
>>110504276
I would expect the same desu
I would expect the same desu
>>110504362
pre- and post-increments are so gross
pre- and post-increments are so gross
C, and mapping file to memory.
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef struct { HANDLE f_, m_; PBYTE begin, end; } MemFile;
void MapF(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 UnMapF(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 N;
int main(int argc, const char** args) {
if (argc < 2) return puts("Missing filename");
MemFile in; MapF(args[1], &in);
N s = 0;
for (auto p = in.begin; p != in.end; ++p) if (++s, *p == '\n') break;
N h = (in.end - in.begin + 1) / s;
N p1 = 0, p2 = 0, x = 0, y = 0;
for (auto p = in.begin; p != in.end; ++p) {
const char c = *p;
++x;
if (c != '#') {
if (c == '\n') x = 0, ++y;
continue;
}
const N mx = s - x, my = h - y, m = mx < my ? mx : my;
for (N l = 1; l < m; ++l)
if (p[l] == '#' && p[l * s] == '#' && p[l * s + l] == '#')
++p1, ++p2;
for (N l = 2, ls = s + s; l < my; ++l, ls += s)
for (N r = 1, rs = s; r < l; ++r, rs += s) {
if (x + l - r >= s) continue;
if (x <= r) continue;
if (p[l + rs - r] == '#' &&
p[ls - r - rs] == '#' &&
p[ls + l - r - r] == '#') ++p2;
}
}
printf("%u\n%u\n", p1, p2);
UnMapF(&in);
}
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef struct { HANDLE f_, m_; PBYTE begin, end; } MemFile;
void MapF(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 UnMapF(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 N;
int main(int argc, const char** args) {
if (argc < 2) return puts("Missing filename");
MemFile in; MapF(args[1], &in);
N s = 0;
for (auto p = in.begin; p != in.end; ++p) if (++s, *p == '\n') break;
N h = (in.end - in.begin + 1) / s;
N p1 = 0, p2 = 0, x = 0, y = 0;
for (auto p = in.begin; p != in.end; ++p) {
const char c = *p;
++x;
if (c != '#') {
if (c == '\n') x = 0, ++y;
continue;
}
const N mx = s - x, my = h - y, m = mx < my ? mx : my;
for (N l = 1; l < m; ++l)
if (p[l] == '#' && p[l * s] == '#' && p[l * s + l] == '#')
++p1, ++p2;
for (N l = 2, ls = s + s; l < my; ++l, ls += s)
for (N r = 1, rs = s; r < l; ++r, rs += s) {
if (x + l - r >= s) continue;
if (x <= r) continue;
if (p[l + rs - r] == '#' &&
p[ls - r - rs] == '#' &&
p[ls + l - r - r] == '#') ++p2;
}
}
printf("%u\n%u\n", p1, p2);
UnMapF(&in);
}
>>110504541
It works with Wine in Linux.
It works with Wine in Linux.

>>110504592
actually i guess just do both parts at the same time
actually i guess just do both parts at the same time
>>110504624
now, bigboy
now, bigboy
>>110504641
too slow, i gave up
im sure theres better ordering/pruning that could be done to make it work, dunno if i can be bothered though
too slow, i gave up
im sure theres better ordering/pruning that could be done to make it work, dunno if i can be bothered though
>>110501961
ugliest site ever award
ugliest site ever award
>>110504689
you have not seen many sites
you have not seen many sites

simd brute
>>110502054
Silver: 839913
Gold: 700901761
Performance counter stats for './3 ../../../inputs/3/bigboy.txt':
75,818,714,058 cycles:u
155,693,512,192 instructions:u
19.060802172 seconds time elapsed
>>110504026
Silver: 361674
Gold: 26584377
Performance counter stats for './3 ../../../inputs/3/aoc_2026_day3_cg.txt' (100 runs):
0 user_time
0 system_time
902,013,085 cycles:u ( +- 0.08% )
2,031,030,792 instructions:u ( +- 0.00% )
0.227341747 +- 0.000174865 seconds time elapsed ( +- 0.08% )
>>110502054
Silver: 839913
Gold: 700901761
Performance counter stats for './3 ../../../inputs/3/bigboy.txt':
75,818,714,058 cycles:u
155,693,512,192 instructions:u
19.060802172 seconds time elapsed
>>110504026
Silver: 361674
Gold: 26584377
Performance counter stats for './3 ../../../inputs/3/aoc_2026_day3_cg.
0 user_time
0 system_time
902,013,085 cycles:u ( +- 0.08% )
2,031,030,792 instructions:u ( +- 0.00% )
0.227341747 +- 0.000174865 seconds time elapsed ( +- 0.08% )
>>110501961
Today's could be brute forced. Yes, there are faster options, but brute force worked enough.
I'm guessing that from tomorrow I might need to start thinking about algorithms, lol.
Today's could be brute forced. Yes, there are faster options, but brute force worked enough.
I'm guessing that from tomorrow I might need to start thinking about algorithms, lol.
>>110504837
brooters dont give up
brooters dont give up
can we have a normal conversation instead of posting code that nobody reads.
like how do we figure out who the group leader is?
like how do we figure out who the group leader is?
>>110504977
the one that posted the best solution is the group leader, but since no one reads the posted solutions, we'll never find out.
the one that posted the best solution is the group leader, but since no one reads the posted solutions, we'll never find out.
>>110504046
Ran it for >>110502054
Day 3 Part 1 (142.8311599s): 839913
Day 3 Part 2 (927.3642393s): 700901761
Ran it for >>110502054
Day 3 Part 1 (142.8311599s): 839913
Day 3 Part 2 (927.3642393s): 700901761
yo Rust coders. how can we measure cycles instead of seconds. i think that makes so much more sense to compare
>>110505076
Just add more digits to your time measurement.
Just add more digits to your time measurement.
probably just me but bigint problems are uninteresting unless you implemented your bigint library yourself
>wowee I changed my longs to bigint haha gocha :D
>wowee I changed my longs to bigint haha gocha :D
tf is bigint, you mean int64 or is it some other mental illness
>>110505201
so certain yet you know so little. i could tell you, as long as you understand the rules of the house.
*unzips*
so certain yet you know so little. i could tell you, as long as you understand the rules of the house.
*unzips*
>>110505201
For most architectures it is the same as a double word.
For most architectures it is the same as a double word.
>>110505282
usually it means a type to represent arbitrary ranges of numbers
usually it means a type to represent arbitrary ranges of numbers
>>110505106
No. You're gay.
No. You're gay.
>>110506174
beautiful
beautiful
Lol nobody gives a shit about advent of shit now that everybody has AI. its not going to boost your linkedin anymore

$ mix aoc.solve -r input/real -y 2026 -d 3 -p b --bench 1
283
947
Ran in 89.21ms
Muddled through last night but just now finished washing. For part 1 I only enumerated pairs of trees within the same row, but I threw that out for brevity since part 2 practically solves both anyway. I might redo part 1 at some point since I had the idea of just making one pass over the input string, maintaining a list of candidate squares and checking for trees in the bottom left/right corners as you reach them.
283
947
Ran in 89.21ms
Muddled through last night but just now finished washing. For part 1 I only enumerated pairs of trees within the same row, but I threw that out for brevity since part 2 practically solves both anyway. I might redo part 1 at some point since I had the idea of just making one pass over the input string, maintaining a list of candidate squares and checking for trees in the bottom left/right corners as you reach them.
>>110506303
I basically got my interview for my current job because one of the senior engineers checked my Github and saw that I'd done a bunch of problems in his favorite niche language, lol.
I basically got my interview for my current job because one of the senior engineers checked my Github and saw that I'd done a bunch of problems in his favorite niche language, lol.
>>110506303
Look we get it, you were filtered. Fuck off to your desktop thread.
Look we get it, you were filtered. Fuck off to your desktop thread.
>>110506318
that's basically it. you still gotta be someone to get invited to the big companies to get a slice. Everybody uses AI but everybody is still a nobody to someone who can give you something.
if it wasn't programming, maybe it would be a sport or something
that's basically it. you still gotta be someone to get invited to the big companies to get a slice. Everybody uses AI but everybody is still a nobody to someone who can give you something.
if it wasn't programming, maybe it would be a sport or something

>>110506652
Day 1 was the gnarliest for some reason, I assumed step 2 would be to do for N first items, but I could just use 3 accumulators in hindsight
Gotta love short names when being a noob with vi
Day 1 was the gnarliest for some reason, I assumed step 2 would be to do for N first items, but I could just use 3 accumulators in hindsight
Gotta love short names when being a noob with vi
>>110506755
Initially int data[][2] vas void*, didnt want to bother with zeroing, then too much casting made me forsake the genericity of my vector
Initially int data[][2] vas void*, didnt want to bother with zeroing, then too much casting made me forsake the genericity of my vector

Calendar image proposal for day 3 based on
>>110499834
>>110499834
>>110506379
what font is this?
what font is this?
>>110506802
looks like iosevka curly slab
looks like iosevka curly slab
>>110506772
static char a[256][256]?????????????
static char a[256][256]?????????????
>>110506849
>char arena[142][142];
> ld: warning: reducing alignment of section __DATA,__common from 0x8000 to 0x4000 because it exceeds segment maximum alignment
You mean I just need to add static???
>char arena[142][142];
> ld: warning: reducing alignment of section __DATA,__common from 0x8000 to 0x4000 because it exceeds segment maximum alignment
You mean I just need to add static???

Javashitscript again.
>>110504026
24secs on this one and still running on the other. I don't know if I can keep doing this javascript thing bros.
>>110504026
24secs on this one and still running on the other. I don't know if I can keep doing this javascript thing bros.
>>110506880
yes nigger static means put this in .bss so it's initialized to zero at startup
yes nigger static means put this in .bss so it's initialized to zero at startup
>>110506781
kek nice
kek nice
>>110506897
My raw estimate is 40 mins for the other.
My raw estimate is 40 mins for the other.
>>110506897
wtf are your tab indents 8 spaces?
wtf are your tab indents 8 spaces?
>>110504153
Probably the one that uses SIMD to work with 256 bit flags at the same time getting ~ 100x speed boost.
Probably the one that uses SIMD to work with 256 bit flags at the same time getting ~ 100x speed boost.
>>110502834
if you just look at the examples you'll notice that the top left vertex slides right along the top row, the top right vertex slides down the right column, the bottom right vertex slides left across the bottom row, and the bottom left vertex slides up the left column. they all move the exact same amount of tiles for any given rotation angle / the taxi cab distance is constant. this means you can take your part1 expanding distance check and simply add an offset to it based on the current distance you're checking to 'slide' the 4 vertexes to all possible positions.
if you just look at the examples you'll notice that the top left vertex slides right along the top row, the top right vertex slides down the right column, the bottom right vertex slides left across the bottom row, and the bottom left vertex slides up the left column. they all move the exact same amount of tiles for any given rotation angle / the taxi cab distance is constant. this means you can take your part1 expanding distance check and simply add an offset to it based on the current distance you're checking to 'slide' the 4 vertexes to all possible positions.
>>110506968
Thanks, it's Monaspace Xenon.
>>110506995
>>110506997
It's the default and I don't feel like changing it.
>>110506984
...and still going. I give up.
Thanks, it's Monaspace Xenon.
>>110506995
>>110506997
It's the default and I don't feel like changing it.
>>110506984
...and still going. I give up.
>>110507020
its alright i figured out a way to do it
its alright i figured out a way to do it
>>110506997
>im a nigger
tabs for indentation, spaces for alignment
kill yourself
also this argument is obsoleted by formatters
>im a nigger
tabs for indentation, spaces for alignment
kill yourself
also this argument is obsoleted by formatters

>>110502804
kino
kino
just checked the AoC++ leaks, it's going to be an advent of parsing day
bigboy
2secs part 1
30mins part 2
used a digital tablet to approach the second part, it was fun
2secs part 1
30mins part 2
used a digital tablet to approach the second part, it was fun
>>110507064
what do you mean by aoc++ leaks? Do aoc++ get early access to the problems?
what do you mean by aoc++ leaks? Do aoc++ get early access to the problems?
>>110507136
Depending on your AoC++ tier, you can get hints a few hours before the puzzle drops, and a small head start (access to the puzzle a couple minutes before everyone else).
You also get a bonus Part 3 every now and again.
Depending on your AoC++ tier, you can get hints a few hours before the puzzle drops, and a small head start (access to the puzzle a couple minutes before everyone else).
You also get a bonus Part 3 every now and again.
I don't know if you changed it, but Eric gave you a minute head start for every $10 you donated. The AoC++ puzzles are sometimes fun, but the real value is the head start.
>>110507293
*you->he
*you->he
>less than 90k gold on day 1 after 3 days
Yeah this shit is niche again.
Yeah this shit is niche again.
>>110507293
A couple years ago my company group all pitched in to donate $14,400 on one account so that we could have a full day head start on the problems.
A couple years ago my company group all pitched in to donate $14,400 on one account so that we could have a full day head start on the problems.

>>110507454
C version because why not. see you nerds in an hour!
C version because why not. see you nerds in an hour!
Good evening everybody you're playing AoC. My name is Eric Wastl we have a great challenge for you tonight, very excited to be back here with you tonight on Thursday. We have a lot to solve tonight, lots to get into, big challenge.
they don't know i am elon musk aka Kekius Maximus :P
>>110507752
It better be, don't flake out on us Eric, you delivered a good day 3, don't mess it up now.
It better be, don't flake out on us Eric, you delivered a good day 3, don't mess it up now.
Today is the Great Wall of our Congress' representative's enemy China
im bored of waiting can you release it early today eric
I need to sleep can you wait 8 more hours to release it eric thx
>>110507869
this is misogynistic and antisemitic
this is misogynistic and antisemitic
>>110507869
my terminal literally looks like this when I'm working THO
my terminal literally looks like this when I'm working THO

>>110507821
was she the one who made a video on drawing a square with turtle/scratch
and the code was wrong but anyone who pointed it out in the comments was jumped at by whiteknights
was she the one who made a video on drawing a square with turtle/scratch
and the code was wrong but anyone who pointed it out in the comments was jumped at by whiteknights
>>110507939
I'd shoot some crazy strings on her IYKWIM ;)
I'd shoot some crazy strings on her IYKWIM ;)
i don't get it
>>110507953
You know, I don't think I know what you mean! Can you recommend me an index in the library I can look up more information at?
You know, I don't think I know what you mean! Can you recommend me an index in the library I can look up more information at?
>>110507944
idk but I need to see this video
idk but I need to see this video
>>110507985
Yesterday was the night, actually. It's easy from here on out.
Yesterday was the night, actually. It's easy from here on out.
>>110507752
but today is friday
but today is friday
>>110508016
It's Saturday here.
It's Saturday here.
>>110508016
No, it'll be Friday in 7 minutes, it's still Thursday night
No, it'll be Friday in 7 minutes, it's still Thursday night
>>110502862
the knight moves to all the closest squares the queen can't move to
the knight moves to all the closest squares the queen can't move to
>>110507897
I get that showing the Xs is helpful for the user and that trying to keep track of the invalid squares without them would be annoying, but they also make it a bit trivial as the lone valid square in each region almost instantly reveals itself.
I get that showing the Xs is helpful for the user and that trying to keep track of the invalid squares without them would be annoying, but they also make it a bit trivial as the lone valid square in each region almost instantly reveals itself.
GET READY. IT STARTS IN 5 MINUTES
I have no toilet paper in here
I'm out of Human-AI tokens... aAAAAACCCKKK
by shooting crazy strings I mean ejaculating streams of semen onto karly's stomach, preferably nowhere near her vagina so I don't accidentally procreate with her and generate a litter of midwits also she seems like a bitch so I don't want to raise kids with her
its too peaceful here, someone start a calendar so we can all fight about it
>>110508052
She's married to Jared Kushner's brother.
She's married to Jared Kushner's brother.
I NEED TO SHIT
xQc screaming in the background. intense focus required. I'm feeling comfy, it's a good 6am
>>110508055
someone made a template in the first thread but nobody has suggested images for it
someone made a template in the first thread but nobody has suggested images for it

>>110507944
>>110507976
>>110507821
https://www.youtube.com/watch?v=BGeT8IyKd2M
I think this is fukken it
ok time to lock in for showtime
>>110507976
>>110507821
https://www.youtube.com/watch?v=BGe
I think this is fukken it
ok time to lock in for showtime
>>110508055
ah, the good ole days, when the first week was 90% fighting over calendar images
ah, the good ole days, when the first week was 90% fighting over calendar images
>assembly interpreter on day 4
WOW Eric is really stepping up the difficulty this time
WOW Eric is really stepping up the difficulty this time
>>110508057
and?
and?

>>110508065
kek
kek
advent of grids
FUCK
wtf am i reading
uhhhhhh
it was a good run fellas
oh fuck
????????????????????????????
= 1 mhm mhm
= 1 mhm mhm
so, uh, how the fuck do you even do this?
bleh for the second day I'm working right up to drop time, and this rainbow (gay) task is resisting my interest
it seems like you could get away with simply counting how many unique colors are present for some of them, but the ones with the ????s separating the valid colors complicate it
Over half the lines in my input can be trivially filtered as single-instruction ones.
Any trailing ?s can be ignored I think.
Then what? Just broot the rest?
Any trailing ?s can be ignored I think.
Then what? Just broot the rest?
>>110508165
breadth-first search that ends as soon as it recreates the barcode
then probably part 2 breaks that
breadth-first search that ends as soon as it recreates the barcode
then probably part 2 breaks that
what the fuck is the edge case this shit works with the examples but wrong for the input
>>110508236
Nope, because like
>???fag
would be producible with just fag, but
>??fag
would require agf
Although the length is 3 either way.
Nope, because like
>???fag
would be producible with just fag, but
>??fag
would require agf
Although the length is 3 either way.
easy day :|
you guys are seriously overcomplicating it it's only day 4
CHINESE REMINDER?????
>>110508271
the fuck, I'm doing the exact same but it fails for my input
the fuck, I'm doing the exact same but it fails for my input
I thought part 2 was going to give a way to fill in the question marks and then solving for part 1 on the completed bar codes
>>110508294
ok I'm fucking retarded, I was missing the = in the length iterator
ok I'm fucking retarded, I was missing the = in the length iterator
btw if it took you more than one minute to solve part 2 after part 1 you were filtered
washed webshit
let repeats = (barcode, idx, step) => {
let a = barcode[idx];
while (idx < barcode.length) {
let b = barcode[idx];
a = a == '?' ? b : a;
if (a != b && b != '?') return false;
idx += step;
}
return true;
};
let findSize = barcode => {
let size = 0;
outer: while (++size && size<barcode.length) {
for (let i=0; i<=size; i++) {
if (!repeats(barcode, i, size))
continue outer;
}
break;
}
return size;
};
let solve = input => {
let barcodes = input.split('\r\n');
let p1 = barcodes.reduce((a, b) => a + findSize(b), 0);
let p2 = findSize(barcodes.join(''));
console.log(p1, p2);
};
let repeats = (barcode, idx, step) => {
let a = barcode[idx];
while (idx < barcode.length) {
let b = barcode[idx];
a = a == '?' ? b : a;
if (a != b && b != '?') return false;
idx += step;
}
return true;
};
let findSize = barcode => {
let size = 0;
outer: while (++size && size<barcode.length) {
for (let i=0; i<=size; i++) {
if (!repeats(barcode, i, size))
continue outer;
}
break;
}
return size;
};
let solve = input => {
let barcodes = input.split('\r\n');
let p1 = barcodes.reduce((a, b) => a + findSize(b), 0);
let p2 = findSize(barcodes.join(''));
console.log(p1, p2);
};
>part 2 running for 5+ minutes
>damn are we needing to memo or sumshit?
>realise I wasn't incrementing the counter
>solves instantly
fml
>damn are we needing to memo or sumshit?
>realise I wasn't incrementing the counter
>solves instantly
fml
We're visiting a factory tomorrow
Can't believe I'm going to have to broot this hard this early on...
>part2: are you a brooting retard or do you know how to solve a puzzle
Okay Part 2 is filtering me. I don't know substring trickery. I brooted part 1. Can a mathfag give me a hint of how to approach the problem?
Did any of you retards start building strings?
>part 2
brootbros....
brootbros....
>>110508457
part 1 solution solves part 2 just fine though?
part 1 solution solves part 2 just fine though?
>>110508457
it's not a math thing, you just have to look at the problem in a different way
it's not a math thing, you just have to look at the problem in a different way
>a good puzzle in 2026
eric-sama...... I kneel.......
Advent of Code is dead. Long live the 12 days of codemas
eric-sama...... I kneel.......
Advent of Code is dead. Long live the 12 days of codemas
>>110508457
I didn't use any math tricks, but you don't need to brute the '?'
I didn't use any math tricks, but you don't need to brute the '?'
>>110508400
wtf
wtf
>>110508457
If the shortest length were n, then
s[0]==s[0+n]
s[1]==s[1+n]
s[2]==s[2+n] etc...
Find the first n that works.
If the shortest length were n, then
s[0]==s[0+n]
s[1]==s[1+n]
s[2]==s[2+n] etc...
Find the first n that works.

>>110508471
I went with logical code which is already slow enough but works fine with a cap of 8 instructions
I'm sure this works for part 2 as well but it's glacially slow
I went with logical code which is already slow enough but works fine with a cap of 8 instructions
I'm sure this works for part 2 as well but it's glacially slow
>>110508400
Welcome to Earth, traveller.
Welcome to Earth, traveller.
part 2 brooters, how we holding up?

>>110508527
Sadly my part 1 broot didn't hold up at all
Sadly my part 1 broot didn't hold up at all
>>110508555
uhhhhh you mean the trick to part 1, right?
uhhhhh you mean the trick to part 1, right?
>>110508563
no i brooted that shit
no i brooted that shit

>>110508555
guess it was pretty simple after all
guess it was pretty simple after all
so let me get this straight:
instead of generating a possible pattern, we want to take a substring of the barcode of increasing length - and the only way it can be validated is if we run through the whole barcode and check if the substring has a color that isn't the same color as the barcode has at that position? the question marks are just redundant, because if there's a ? in the barcode and not in the pattern we're testing, that's fine, and if there's a ? in the pattern but not the barcode we can just set that position in the pattern to whatever the barcode has?
instead of generating a possible pattern, we want to take a substring of the barcode of increasing length - and the only way it can be validated is if we run through the whole barcode and check if the substring has a color that isn't the same color as the barcode has at that position? the question marks are just redundant, because if there's a ? in the barcode and not in the pattern we're testing, that's fine, and if there's a ? in the pattern but not the barcode we can just set that position in the pattern to whatever the barcode has?
>>110508695
You can probably skip the first bit of barcode that's the length of the substring, and all the ? that pads the end of the barcode. That's what I did
You can probably skip the first bit of barcode that's the length of the substring, and all the ? that pads the end of the barcode. That's what I did
>>110508695
Well, the substring can't have a ? that ends up aligning with two different colors in the barcode so you need to keep track of that, too.
Well, the substring can't have a ? that ends up aligning with two different colors in the barcode so you need to keep track of that, too.

>>110506688
What am I doing
What am I doing

>>110508695
interesting. took me a while to understand what was happening.
interesting. took me a while to understand what was happening.

>>110508796
I had the same approach. I used Qt because it has the classes QByteArray and QByteArrayList, basically char[] and char[][] with .length().
I had the same approach. I used Qt because it has the classes QByteArray and QByteArrayList, basically char[] and char[][] with .length().
>stuck on part 2
>realize you don't have to bfs at all
>just leave the ? in your candidate until it HAS to be something and then use that in your validation
dam this was simple in retrospect, my part 2 runs waaaay faster than my part 1
>realize you don't have to bfs at all
>just leave the ? in your candidate until it HAS to be something and then use that in your validation
dam this was simple in retrospect, my part 2 runs waaaay faster than my part 1
def check(bcode, cand):
if not cand:
return False
for idx,c in enumerate(bcode):
if c == "?":
continue
cidx = idx % len(cand)
if cand[cidx] == "?":
cand = cand[:cidx] + c + cand[cidx+1:]
if c != cand[cidx]:
return False
return True
ans = 0
idx = 0
cand = ""
for idx,c in enumerate(bcode):
cand += c
if check(bcode, cand):
ans += len(cand)
break
print(ans)
ezpz
if not cand:
return False
for idx,c in enumerate(bcode):
if c == "?":
continue
cidx = idx % len(cand)
if cand[cidx] == "?":
cand = cand[:cidx] + c + cand[cidx+1:]
if c != cand[cidx]:
return False
return True
ans = 0
idx = 0
cand = ""
for idx,c in enumerate(bcode):
cand += c
if check(bcode, cand):
ans += len(cand)
break
print(ans)
ezpz
>>110508813
code?
code?
It's a throw out the broot and try again day.

>>110508614
about 1m
about 1m
>>110508900
at this point I doubt that even compiles
at this point I doubt that even compiles
>>110508930 (You)
what am I even memcpying for lmao
what am I even memcpying for lmao
>>110508942
what? why wouldn't it compile?
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=fc1524614fce4dc4459ab2cc70c988bf
what? why wouldn't it compile?
https://play.rust-lang.org/?version
>>110508899
Why can't you broot?
Why can't you broot?

>>110508930
0.5s, much better now
0.5s, much better now
>>110509019
by broot, i assume he means BFS where you just try every color in place of a question mark. works fine on part 1 but fucks you on part 2
by broot, i assume he means BFS where you just try every color in place of a question mark. works fine on part 1 but fucks you on part 2
How many digits in the final solution?
I'm already up to 11 character substrings in under 5 minutes and I'm wondering if I should wait around for the result or go to bed.
I'm already up to 11 character substrings in under 5 minutes and I'm wondering if I should wait around for the result or go to bed.
>>110509098
~1k 2k
~1k 2k
>>110509098
You mean how many instructions for the super long barcode? I had just under 2000.
You mean how many instructions for the super long barcode? I had just under 2000.
>>110509041
Try reduce branching by replacing && with & and using less ifs
Try reduce branching by replacing && with & and using less ifs
>>110508273
I still have no idea what the chinese reminder theorem is, and I have all stars from all years.
I still have no idea what the chinese reminder theorem is, and I have all stars from all years.
It makes me sad that programming is dead.
>>110509169
Programming isn't dead. AI still occasionally makes mistakes which I have to ask it to fix, and it doesn't even work that much faster than I do, only about 20x. Plus, LLMs are fundamentally flawed and not capable of true reasoning, so they won't get much better than they currently are.
Sorry cuckcoders, programming is here to stay.
Programming isn't dead. AI still occasionally makes mistakes which I have to ask it to fix, and it doesn't even work that much faster than I do, only about 20x. Plus, LLMs are fundamentally flawed and not capable of true reasoning, so they won't get much better than they currently are.
Sorry cuckcoders, programming is here to stay.

>>110508912
Will try to improve it tonight
Will try to improve it tonight
>>110509286
Goyim in abundance.
Someone invite Peter Norvig to our leaderboard
https://github.com/norvig/pytudes/blob/main/ipynb/Advent-2026.ipynb
Goyim in abundance.
Someone invite Peter Norvig to our leaderboard
https://github.com/norvig/pytudes/b
> works on example
> your answer is too low
aight see you next year
> your answer is too low
aight see you next year
>>110509286
there was a previous day in advent of code history where reddit complained about slurs in a randomly generated input right? and eric responded to it? or did i make that up?
there was a previous day in advent of code history where reddit complained about slurs in a randomly generated input right? and eric responded to it? or did i make that up?
>>110509368
FAG appeared and they had to reissue corrected inputs.
FAG appeared and they had to reissue corrected inputs.
Part 1:
data = open("Day 04 input.txt", "r").read().strip().split("\n")
def search(code, inst="", pos=0):
#print inst
if len(inst):
for num, char in enumerate(code):
if char != "?" and char != inst[num%len(inst)]:
break #fail
else:
return len(inst)
best = len(code)
for opt in "roygbv":
if code[pos] == "?" or code[pos] == opt:
result = search(code, inst + opt, pos+1)
if result < best:
best = result
return best
total = 0
for line in data:
total += search(line)
print total
Part 2
data = "".join(open("Day 04 input.txt", "r").read().strip().split("\n"))
def check(length):
assigned = {}
for offset in range(length):
for char in range(offset, len(data), length):
if data[char] == "?": continue
if offset in assigned:
if assigned[offset] != data[char]:
return False
assigned[offset] = data[char]
return True
for length in range(1, len(data), 1):
if check(length):
break
print length
Started late. Overthought part 1, for part 2 I had to pivot to the sieve approach I really should have been using from the beginning.
data = open("Day 04 input.txt", "r").read().strip().split("\n")
def search(code, inst="", pos=0):
#print inst
if len(inst):
for num, char in enumerate(code):
if char != "?" and char != inst[num%len(inst)]:
break #fail
else:
return len(inst)
best = len(code)
for opt in "roygbv":
if code[pos] == "?" or code[pos] == opt:
result = search(code, inst + opt, pos+1)
if result < best:
best = result
return best
total = 0
for line in data:
total += search(line)
print total
Part 2
data = "".join(open("Day 04 input.txt", "r").read().strip().split("\n"))
def check(length):
assigned = {}
for offset in range(length):
for char in range(offset, len(data), length):
if data[char] == "?": continue
if offset in assigned:
if assigned[offset] != data[char]:
return False
assigned[offset] = data[char]
return True
for length in range(1, len(data), 1):
if check(length):
break
print length
Started late. Overthought part 1, for part 2 I had to pivot to the sieve approach I really should have been using from the beginning.
>>110509381
I hate the faggy text it automatically adds.
I hate the faggy text it automatically adds.
>>110509303
Some of the best python I've seen.
Some of the best python I've seen.
>>110509393
yeah well blame eric for shoving the pride rainbow into all the puzzles. Real rainbows typically have seven colors
yeah well blame eric for shoving the pride rainbow into all the puzzles. Real rainbows typically have seven colors
>>110509286
I received 2 "goy" lines in my input.
I received 2 "goy" lines in my input.

>>110509399
mines better
mines better
>>110509441
Post code
Post code
>>110509458
already did
already did
>>110502150
Holy shit is that Reboot?
Holy shit is that Reboot?
>succeed on example
>fail on input
FUCK
is eric fucking me with cutting off sequences at the start or is that part 2
>fail on input
FUCK
is eric fucking me with cutting off sequences at the start or is that part 2
>>110509709
Part 2 is easy when you've completed part 1. But it does require you do do part 1 in an efficient way or it will take forever.
Part 2 is easy when you've completed part 1. But it does require you do do part 1 in an efficient way or it will take forever.
>>110509709
Are you getting any sequences that require the entire sequence length in order to print a valid barcode?
Are you getting any sequences that require the entire sequence length in order to print a valid barcode?
>>110509747
I didn't do the part 1 that's why I am asking
>>110509749
yes
found answer of len 3 for g?y (fulllen: true):
gry
found answer of len 2 for gy (fulllen: true):
gy
found answer of len 7 for vg???yo (fulllen: true):
vgrrryo
Overall my answer is too high
there are probably some more efficient solutions if I could cut off the start but Im not sure if that's allowed by the wording of the part 1, it seems like a good twist for part 2
I didn't do the part 1 that's why I am asking
>>110509749
yes
found answer of len 3 for g?y (fulllen: true):
gry
found answer of len 2 for gy (fulllen: true):
gy
found answer of len 7 for vg???yo (fulllen: true):
vgrrryo
Overall my answer is too high
there are probably some more efficient solutions if I could cut off the start but Im not sure if that's allowed by the wording of the part 1, it seems like a good twist for part 2
>>110509763
I've written a first implementation in Python this morning that took 12 seconds for part 2. Thought about it for a bit and then came to the conclusion that I'd done it the wrong way round. My second implementation in C++ was faster. Basically I try to compose a program for the barcode and see if it fits. If it doesn't fit, I start with a new program that is one instruction longer, and so on until it fits and then I output the number of instructions. Part 2 can use the exact same function.
I've written a first implementation in Python this morning that took 12 seconds for part 2. Thought about it for a bit and then came to the conclusion that I'd done it the wrong way round. My second implementation in C++ was faster. Basically I try to compose a program for the barcode and see if it fits. If it doesn't fit, I start with a new program that is one instruction longer, and so on until it fits and then I output the number of instructions. Part 2 can use the exact same function.
I figured it out, printing out my permutations helped
instead dividing my permutation country by 6^(nth ?) i was just dividing it by (nth ?)
instead dividing my permutation country by 6^(nth ?) i was just dividing it by (nth ?)
wtf eric forgot the lube
I have reviewed every posted solution in these threads thus far and have come to the conclusion that I'm the only one actually writing code. You faggots all use AI.
>>110509854
>permutation
What? Why? Don't you realize that the positions in your programs are dictated by the colors in your incomplete bar code? There's no need for permutations. In fact I think if you do permutations, part 2 will run for a long time.
>permutation
What? Why? Don't you realize that the positions in your programs are dictated by the colors in your incomplete bar code? There's no need for permutations. In fact I think if you do permutations, part 2 will run for a long time.
so what's the fastest way to do it? i settled on
>put letters into x bags in a cyclical loop, where x is instruction length i'm testing
>ignore ?, if more than one letter would go into given bag it means the instruction length is impossible
>increase instruction length by one, repeat
200ms in python
>put letters into x bags in a cyclical loop, where x is instruction length i'm testing
>ignore ?, if more than one letter would go into given bag it means the instruction length is impossible
>increase instruction length by one, repeat
200ms in python
>>110509967
Yes, that's the way I did it on my 2nd attempt.
The new puzzle comes out at 6 in the morning in my timezone. I wasn't really awake yet and I didn't get much sleep last night, so on my 1st attempt I made the program the length of the barcode and then tried to reduce the program until I reached a minimal length. That worked, but it took 12 seconds to complete for part 2.
Yes, that's the way I did it on my 2nd attempt.
The new puzzle comes out at 6 in the morning in my timezone. I wasn't really awake yet and I didn't get much sleep last night, so on my 1st attempt I made the program the length of the barcode and then tried to reduce the program until I reached a minimal length. That worked, but it took 12 seconds to complete for part 2.
On my fixed version I start with a max len of 1 up to the length of the target string and I fill a list with ?
Then I move that mask along the target comparing it to the target, any ? that align with letters are converted into that letter, if a letter in the mask aligns with a different letter in the target then it is invalid.
The first one that covers the entire target will be the shortest. 200ms compared to like 40s for my original solution.
Then I move that mask along the target comparing it to the target, any ? that align with letters are converted into that letter, if a letter in the mask aligns with a different letter in the target then it is invalid.
The first one that covers the entire target will be the shortest. 200ms compared to like 40s for my original solution.
>>110509948
Yeah
Yeah
>>110509948
damn, I thought I didn't but on second thought, maybe I did after all...
damn, I thought I didn't but on second thought, maybe I did after all...
>>110510202
I reverse engineered the steps, including the prompt. First you took your moms credit card and bought a video tutorial on "efficient prooompt engineering" and then you pasted todays problem description into chatGPT, told it what language to use and to avoid importing solutions, bare minimum core lib utility. This didn't work, so you copied something you found on reddit and carbon'd it. The absolute state of /g/...
I reverse engineered the steps, including the prompt. First you took your moms credit card and bought a video tutorial on "efficient prooompt engineering" and then you pasted todays problem description into chatGPT, told it what language to use and to avoid importing solutions, bare minimum core lib utility. This didn't work, so you copied something you found on reddit and carbon'd it. The absolute state of /g/...
rust
I had to take my beautiful permutation-based solution out back and blast it after reaching the 6^13 point. Hence this ugly allocating solution, yuck!
I had to take my beautiful permutation-based solution out back and blast it after reaching the 6^13 point. Hence this ugly allocating solution, yuck!
>>110510342
People are always solving days late.
We are still well below normal day 1 numbers, though. Also, day 3 filtered a quarter of people.
People are always solving days late.
We are still well below normal day 1 numbers, though. Also, day 3 filtered a quarter of people.

>>110510370
forgot fmt
forgot fmt
>>110510372
>day 3
Yeah, I was worried for a moment over part 2 and was asking myself "how do I detect rotated squares?". But when you read the examples, you realize that if corner 2 is 3 steps to the right and 1 step down, then corner 3 is going to be 1 step to the left and 3 steps down, and so on. Yesterday an anon tried to explain that with vectors and the cross product, and technically he was right. Practically though you can work it all out with simple addition and subtraction arithmetic on the x and y coordinates.
>day 3
Yeah, I was worried for a moment over part 2 and was asking myself "how do I detect rotated squares?". But when you read the examples, you realize that if corner 2 is 3 steps to the right and 1 step down, then corner 3 is going to be 1 step to the left and 3 steps down, and so on. Yesterday an anon tried to explain that with vectors and the cross product, and technically he was right. Practically though you can work it all out with simple addition and subtraction arithmetic on the x and y coordinates.
>>110509778
my broot could not even broot the second demo example after waiting for a few minutes
my broot could not even broot the second demo example after waiting for a few minutes

























































