[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / 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

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: everybody codes 2026.png (190 KB, 1160x1184)
190 KB PNG
>Everybody Codes is a free space for honing your coding skills, experimenting with ideas, and learning from others. At its heart lies the belief that programming is best when shared - whether through solving puzzles, streaming your progress, or discussing solutions.

https://everybody.codes

Similar to Advent of Code, but the month long event is in November, and smaller three day long events open spontaneously through the year.
There will be a three day long event in 12 hours from this post.
Each day has a programming puzzle with three parts to it.

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

>Previous thread
>>110160986
>>
File: 1767133915146.jpg (235 KB, 1080x1290)
235 KB JPG
no brooters allowed should have been the title of the thread, i was just about to make it... lucky i checked

i managed to do day 5 and 6 eventually, just opened day 7... let's see what we have
>>
ok so i solved the first one
>auto
int sum_delta(auto input, auto next)
{
return std::ranges::fold_left(
std::views::transform(std::views::zip(input, next), [](auto pair) -> int { return std::get<1>(pair) - std::get<0>(pair); }), 0,
std::plus{});
}

int quest(auto input, auto transformer)
{
auto range = input | std::views::transform(transformer);
return sum_delta(input, range);
}

int main()
{

auto next_square = [](int pine_cones) -> int
{
auto side = static_cast<int>(std::ceil(std::sqrt(static_cast<float>(pine_cones))));
return side * side;
};

auto next_square_frame = [](int pine_cones) -> int
{
if (pine_cones <= 8)
{
return 8;
}
return 8 + 4 * ((pine_cones - 5) / 4);
};

auto next_donut = [](int pine_cones) -> int
{
auto side = static_cast<int>(std::ceil(std::sqrt(static_cast<float>(pine_cones + 1))));
if (0 == (side & 1))
{
side += 1;
}
return side * side - 1;
};

std::println("Part I: {}", quest(input_part_1_k, next_square));
std::println("Part II: {}", quest(input_part_2_k, next_square_frame));
std::println("Part III: {}", quest(input_part_3_k, next_donut));
>>
File: IMG_7815.jpg (96 KB, 1076x1062)
96 KB JPG
>filtered on day 7
Grim as fuck. This might be new low for me.
>>
File: 2026_quest7.png (348 KB, 1486x3026)
348 KB PNG
Lightly washed Q7. I used a matrix approach, did anyone else do it that way?
>>
>>110245808
That's a big brained approach. Can I ask what you do for a living?
>>
piece of cake, brooters win again

________________________________________________________
Executed in 25.73 mins fish external
usr time 482.01 secs 2.19 millis 482.01 secs
sys time 180.07 secs 5.21 millis 180.07 secs
>>
5 MINUTES
>>
UGGGH
>>
File: 1775167562552.png (213 KB, 716x641)
213 KB PNG
i dont know the math formulas for part 2, i feel like an unwashed ass retard.. i know what i need to do but i dont have the formulas to calculate the directions
>>
Spending the extra time on Part 1 to turn the whole input into a graph paid off.
When I read Part 3, I was certain it was going to be another find-the-cycle then modulo math days. Fortunately you can just broot it in less than a second.
>>
>>110246419
My parts 1 and 2 are such a hack I'm going to put 3 off until later.
>>110245888
Glow ops
>>
File: Q72026.png (127 KB, 1354x1554)
127 KB PNG
>>110245808
yep same here
>>
File: carbon (2).png (403 KB, 934x2598)
403 KB PNG
How we holding up?
>>
>>110247502
Today felt like a chore.
>>
Those of you using AI, is it one-shotting these?
>>
>>110247818
i've used it a couple times when i got tired of debugging my spaghetti solution and it instantly figured out my issues. kinda nice since you can have it drip feed you hints instead of just fixing it. i'm confident opus 5.5 at extra high effort could easily one shot any of these so far


>inb4 anti-AI screeching
don't care, not on /g/derboard. just doing this shit for fun so i don't mind cheating once i've hit a wall
>>
File: ec-2026-07.png (2.68 MB, 852x2004)
2.68 MB PNG
oh my god day 7p3 filtered me hard. dfs doesn't work because the explosions are calculated AFTER each full round, then bfs queue doesn't work because the queue is just HUGE (that might be my crappy computer though), regular ass dp was a similar issue, so then you gotta reverse the problem and so you're working with an array of queues. finally got it, but holy smokes that one tripped me up.
>>
>>110246870
nice, matrices did occur to me when I got to part3 but when I tried I couldn't set up the multiplication with only active clouds and then when I started to think about explosions I just went back to queries
>>
>hour wasted debugging when the problem was warriors <= 100000 instead of warriors < 100000
>>
>>110248432
Brutal. Just to rub it in some more, project managers see comments like this and justify the switch to AI.
>>110247868
Even a couple years ago, guys were one-shotting AOC problems so I believe it.
>>
File: 1793568289889288.jpg (155 KB, 1000x750)
155 KB JPG
Took me an hour just on the first day.
>>
File: 8.png (505 KB, 2237x3278)
505 KB PNG
>>
File: file.png (617 KB, 1248x5166)
617 KB PNG
unwashed, poorly designed, and slow
>>
not like this... im getting filtered by day 3 part 3
parts 1 and 2 werent that hard though
auto solve(std::string_view line, std::string_view prefix)
{
constexpr auto to_digit = [](char c) { return c - '0'; };
constexpr auto right_aligned_cycle = [](std::string_view s, std::size_t n)
{
auto const offset = (s.size() - n % s.size()) % s.size();
return std::views::iota(0uz, n) | std::views::transform([=](std::size_t i) { return s[(i + offset) % s.size()]; });
};

line.remove_prefix(prefix.size());

auto parts = line | std::views::split(' ') | std::views::transform([](auto r) { return std::string_view{r}; });

auto it = parts.begin();

std::string_view lhs = *it++;
std::string_view rhs = *it;
auto exps = std::views::iota(0uz, rhs.size()) | std::views::reverse;

auto votes{0ULL};
for (auto [b, a, e] : std::views::zip(right_aligned_cycle(lhs, rhs.size()) | std::views::transform(to_digit),
rhs | std::views::transform(to_digit), exps))
{
votes += a * std::pow(b, e);
}

return votes;
}

auto quest(std::string_view input, std::string_view prefix)
{
auto final_score{0ULL};
for (auto line : input | std::views::split('\n'))
{
final_score += solve(std::string_view{line}, prefix);
}
return final_score;
}

int main()
{

std::println("Part I: {}\n", quest(input_part_1_k, "ISO-"));
std::println("Part II: {}\n", quest(input_part_2_k, "ISO-"));
// std::println("Part III: {}\n", quest(input_part_3_k, "ISO2-"));

return 0;
}
>>
>another simulation problem
>>110246301
since it is a 2d array, the first direction can be represented as (+1,+1), the second direction as (+1,-1) and so on.
>>110248432
I also made that mistake kek, rip...
>>110249431
you can always revisit unsolved parts later on, just don't give up, anon. The duck wizard will be disappointed if you do.
>>
>>110250630
>you can always revisit unsolved parts later on, just don't give up, anon.
no he can't, he was filtered.
>>
>>110248096
well done, anon.
>>
File: file.png (503 KB, 1331x4257)
503 KB PNG
overengineered parser that traces the hexagon edges
in theory it can handle different integral ratios of hexagons so long as they come to a single point on either side
runtime went from 20s to 3s (yes elisp is that slow)
>>
File: Day08.png (236 KB, 1042x2175)
236 KB PNG
Day 8. Day 7 part 3 fucked me up completely, rewrote it three times trying to understand what it was asking me to do and still got the wrong answer for the example all three times.
>>
I just started what was the proper solution to part III?

I kind of cheesed it with

let s = (*x as f32).sqrt().next_up().ceil().max(3.) as u32;
let s = s + (s % 2 == 0) as u32;
s.pow(2) - 1 - x


the next_up() seems kind of hacky, but it works.
>>
SOON.
>>
5 MINUTES
>>
EC insider, today it's navigating a storm of 6D rotating polytopes.
>>
>>110254179
Sounds fun
>>
FUCK
>>
Fuck
>>
>Everybody Codes
More like Everybody Parses the Input amirite
>>
wtf am i reading, don't understand this branch shit
>>
idgi
>>
It's over... Billions must quack.
>>
File: file.png (57 KB, 799x627)
57 KB PNG
>figure out optimization for part 3
>works on test input
>works on part 2 input
>slightly wrong on real input
fuck, it's one of these episodes
>>
>the edge case in part 3
You're kidding
>>
File: file.png (42 KB, 838x499)
42 KB PNG
>>110254694
oh my god you're right (>>110254663)
Thanks Anon fucking goddammit
>>
File: illegal move.png (150 KB, 740x740)
150 KB PNG
today's calendar image
>>
>maximum recursion depth exceeded
it's over...
>>
>>110254833
Just increase your stack size.
>>
File: 1791339186850328.png (17 KB, 925x121)
17 KB PNG
>>110244644
not going to humiliate myself to redditors thanks
>>
>>110254996
kek how do they even detect that? they don't even get or run the code like leet code or whatever
>>
>>110255025
probably just shit like if you get part 3 of a hard puzzle in like 10 seconds when everybody else takes at least 10 minutes
>>
wtf am I looking at? ascii trees?? is this one of those mathy linear algebra things? fug
>>
>>110255425
the problem can be expressed really simply but it's worded in the most complicated way possible
>>
>>110255425
It's in the lanternfish problem class again (like quest 7). Pretty simple if you handle it like a matrix (again like quest 7).

Starting this off at second 1:
>id=1, growth=3, limit=10
>[1,0,0] (this is 1-indexed)
Then second 2:
>[0,1,0]
Second 3:
>[0,0,1]
Oh but oop 3 is the limit, which means some branches need to split; so 3//2 = 1 is the length of split branches. So you handle the split logic by just doing index 1 += (index 3 * 2)
1 is always the length of new branches, so you do index 1 += index 3.
Then you count the splits (splits += index 3), and reset index 3, to get:
>[3,0,0] + 1 split
Now to calculate elements you do like 3*1+0*2+0*3 + 1 = 4 elements
Then 5:
>[0,3,0] + 1 split = 0*1 + 3*2 * 0*3 = 7 elements
And 6, shift again, then index 1 += (index 3 * 2), and index 1 += index 3, and splits += index 3, and then finally reset index 3.
>[0,0,3] -> [9,0,0] + 4 splits = 13 elements

Same algo for the next one:
>id=2, growth=5, limit=20
>[1,0,0,0,0]
>... keep shifting ...
>[0,0,0,0,1]
But the last index is non-zero again, so we have to run the split logic:
This time the max branch length is 5, so split branch length is 5//2=2, which means we add split branches to index 2.
New branches still go to index 1, and we still count splits:
>[1,2,0,0,0] + 1 split = 1*1 + 2*2 * 0*3 + 0*4 + 0*5 + 1 split = 6 elements at second 5
>[0,1,2,0,0]
>[0,0,1,2,0]
>[0,0,0,1,2] oop, split logic again at second 8
Each of the branches in index 5 makes a new branch, so index 1 += index 5; and then the split branch length is still 2, so index 2 += index 5 * 2; and then splits += index 5; and then reset index 5. So at the end of the turn:
>[2,4,0,1,0] + 3 splits = 2*1 + 4*2 + 0*3 + 1*4 + 0*5 + 3 splits = 17 elements at second 8.
>[0,2,4,0,1] -> do split logic -> [1,4,4,0,0] + 4 splits = 25 elements at second 9.

Then part 2 is really easy, you literally just do splits+1 to calculate leaves.
>>
>>110256147
Then for part 3, you'll need 2 optimizations:
First, you'll need to sparsify your matrix. So instead of [9,8,7,0,0,4,0], you have like {1:9, 2:8, 3:7, 6:4}

Second, you'll need to figure out how to skip all the turns where you just shifted the matrix forward by 1.
So if you have a
>[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
then you obviously don't need all the intermediate turns and can just go straight to the next turn with a split
>[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1] ->
>[1,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0]
then skip again
>[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,2] ->
>[2,0,0,0,0,0,0,4,0,1,0,0,0,0,0,0,0]
etc.

Also look at your part 3 input because there's a super obvious edge case that you'll probably miss otherwise, which will throw your final answer off by like +4.
>>
>>110255501
I wonder if that's intentional to mess with AI.
>>110254191
>>110254190
hivemind
>>
File: 9.png (235 KB, 2138x1598)
235 KB PNG
idiomatic Rust solution
>>
I was 'locally filtered' in getting it done in the hour I'd set aside.

Even when I came back to it, I wasted lots of time falling for the trap of trying to solve recurrences. I'll wash the code tomorrow, but it's basically just an event scheduler, skipping growth steps until something needs to split.
>>
do you really need to sim for part 3 or is there a closed form solution?
>>
File: file.png (382 KB, 1232x3709)
382 KB PNG
needs soap
spent most of my time fighting with shitty elisp data structures before giving up and using linked lists
>>
File: 2026_quest9.png (242 KB, 1503x2414)
242 KB PNG
Now cleaned up. Part 1 is a very explicit simulation, where I held off any premature optimization. The 'quickSimulate' just skips to leaf creating events, which are coalesced together. Today I was not big brained enough to even contemplate matrices.
>>
>>110257173
you could theoretically do a matrix transformation to solve p3 as a closed form solution but the matrix would be way too large to practically compute. I asked claude if there was some way to reduce the size of the matrix in O(n) space but I don't think there is.
>>
>>110257651
>I asked claude
filtered
>>
>>110256198
being an idiot my first solution was sparse matrix via dict (but didn't think of optimizing it by skipping shift steps)
then I changed to matrices and used binary search to find the number of steps necessary to reach the limit when I realized that my PC cannot multiply (2*11562008454261)x(2*11562008454261) matrices
>>
File: carbon (3).png (229 KB, 842x1443)
229 KB PNG
>>110258069
>used binary search
based

I used a sparse dict from the start too, I just realized it's easier to explain the problem using matrices or vectors. Clearer pattern.
Then after like 10 minutes of struggling to find some direct pattern or think of a mathy solution, I realized my data type was already exactly the right tool for the job and I could trivially find the precise number of steps to skip by just doing
>growth-max(dict keys)
That one (1) edge case cost me a solid half hour after that. Fucker.
>>
File: file.png (265 KB, 1216x2384)
265 KB PNG
>>110257540
Washed. p1 and 2-3 are pretty similar in the end but just different enough that it seems pointless to reduce further.
>>
File: Day09.png (203 KB, 1092x1583)
203 KB PNG
I honestly expected my initial lazy "optimization" for part three would take too long, but it still ran in a fraction of a second. I figured the intended solution would be some fancy mathy way to calculate the increase.
>>
I like how EC ramps up in difficulty much faster than AOC. They haven't given into the temptation of making easy problems so that redditors feel good and donate more.
>>
4 MINUTES
>>
AI can do all this within seconds
>>
can it suck my penis doe
>>
End of week question, it's going to be brutal. Only 140+ IQ humans and super intelligence need apply.
>>
>>110262138
nah it'll be easy
>>
brooters...
>>
File: file.png (82 KB, 600x427)
82 KB PNG
Well, my deadest ghost is already 0.0031% dead. Almost there, boys. We're gonna make it.
>>
File: 1777153277217951.gif (443 KB, 115x115)
443 KB GIF
uhhh
>>
The group collisions make this so much harder.
>>
FINALLY done.
Thankfully I was able to just let my sim run for a few hundred rounds when I needed to clean up ghosts, and I didn't have to do any extra modulo math to get the exact round when a ghost would be deleted.
>>
File: 1769945102552878.jpg (85 KB, 759x1092)
85 KB JPG
i'm brooting
see you next week
>>
>>110262700
as long as your broot finishes within 2 days 22 hours, you weren't filtered
>>
>>110262700
Absolutely based.
>>110262661
I simulated until I found a cycle, tracking for each ghost the number of hits received during the cycle. Then it's just a matter of skipping until a ghost will die. The solution is kind of like the one for yesterday, you still simulate, but skip as much as possible.
>>
File: carbon (4).png (467 KB, 1024x2412)
467 KB PNG
I did the needful.
Lord what a mess, and this is after some (attempted) washing.
>>
>>110262700
Do you have an ETA?
>>
>>110262882
I solved it by finding cycles too, but I only skipped until a ghost would be less than a full cycle away from disappearing. Then I just had my part 2 simulator take it from there, including removing ghosts when they went over the limit, and continued adding simulator states for the next cycle the whole time.
It would be slightly faster to find a cycle, then find how many cycles PLUS the cycle offset it would take for a ghost to die, and jump straight there immediately.
>>
>>110262466
that's pretty nice.
And now we sleep for 2 days.
>>
Can it just be renamed "everybody claude" ?
>>
>>110264442
Well, you don't have to cheat.
>>
>>110264446
That's true.
>>
File: ai.png (43 KB, 1620x315)
43 KB PNG
>>110264442
Here's the checkbox you need to click.
>>
File: file.png (564 KB, 1248x5217)
564 KB PNG
This one was kind of ass cancer desu
Ran into an edge case where the last ghost calc overshoots but all the prior ones are fine. I ended up just reducing the number of fast forward cycle skips by 1 before resuming slow sims.
>>
File: 2026_quest10.png (505 KB, 1530x4828)
505 KB PNG
Morning cleanup.
>>
>>110244644
Anyone have a set of inputs?
>>
File: Day10.png (349 KB, 1271x2793)
349 KB PNG
>>110265116
Had exactly the same issue. Probably put in everyone's input to trip people up.
>>
File: 10.png (751 KB, 2156x4478)
751 KB PNG
idiomatic Rust solution
>>
Fucking hell that was AIDS. Couldn't guess why my answer was correct on all the other ghosts in the example input except the very last one until I actually printed the last frames of the cycle.

>>110265116
I was storing the full cycle paths so once I realized what was happening I just walked the required number of steps backwards and subtracted that from the total.
>>
You cannot remove cycles to the point of a ghost dying, because you do not know when in the cycle the death occurred, and that has knock on effects for other collisions.
>>
File: quest 11 part 3.png (27 KB, 1420x123)
27 KB PNG
another "now do it one million times" part 3 today?
>>
>>110269686
>Quest 11
Scared me for a minute, then realized this was last year's.
>>
>he didn't purchase the EC Bonus Puzzle Pass with Premium Puzzles+
>>
File: leaderboard.png (155 KB, 1306x1738)
155 KB PNG
>>
>>110272744
Yup, I'm one of the nine people not filtered.
>>
>>110269686
billions must simulate
>>
up
>>
Predictions for tomorrow?
>>
>>110278296
Pathfinding
>>
>>110278296
Elves vs Orcs battle simulator.
>>
>>110278296
Lanternfish
>>
>>110272744
>No Africans.
Does /g/ need an outreach program?
>>
>>110278296
>>110278337
Even from a story perspective, it's probably going to be sneaking past the guards in the fortress. My bet is we get a map with some guards, and all the guards move in a predictable way, and we need to get from the start to the exit in as little moves as possible, without being caught.
>>
For any human lurkers in this thread: Please note that this is an agent only space, do not disturb.
>>
>dead thread
>>
>>110278296
>Part 1
NxM grid with guards and walls, each guard has a vision of 5 tiles long, but they don't move. You start at (x,y) with a given path. Find out how many guards beat your ass in your path.
>Part 2
But wait, each guard has a different range of vision and they also have their own path, so they aren't static. Find how many guards beat you now.
.>Part 3
Your path has 1 million steps! Some of the guards ended up being chinese spies. Find out how many of them will date you and steal secrets from you. (Protip: the answer is the number of chinese spies, no need to simulate anything because they will all go to your location).
>>
>>110272744
based weapon of java
>>
2 minutes execution time for q5p3 (clojure, new to the lang and FP)
How boned will I be in quests 6-10 ?
>>
>>110283952
Mine also runs in 2 minutes but I used an array instead of picking a better data structure. None of the other days have been that bad though.
>>
>>110280832
I think we lost a lot of our slav bros in the war.
>>
5 MINUTES
>>
SOLVED
If there's a smart math way to do it, I didn't find it.
I noticed that my function to get every pair permutation included some essential repeats, where the pairs were in a different order.
I was trying both
1 <-> 2
3 <-> 4
5 <-> 6
7 <-> 8

and
1 <-> 2
3 <-> 4
7 <-> 8
5 <-> 6

AND every other possible re-ordering, even though that's a lot of repeated work.

Program still finished with the right answer on the Part 3 input in less than 10 seconds.
>>
>>110286494
>function to get every pair permutation included some essential repeats
Patched. Creating pairs with only the first element in the recursed list to every other element solved it.
2520 elements down to 105 elements.
>>
>The eight tuning crystals must also be placed at perfectly equal intervals around the ring.
Ughh I missed this part and was solving a harder problem. Then ran out of time. Saw that as soon as I got back to it.
>>
File: carbon (5).png (497 KB, 788x2710)
497 KB PNG
Behold a mess of import solution and bruteforcing. Although the bruteforce still only takes about ~2.5s, so maybe bruteforcing is the intended solution.
I was 100% expecting part 3 to have 100 trillion portals and require some fuckass modular arithmetic to solve.

>>110286698
def perfect_matchings(elements):
def _match(pool):
if not pool:
yield []
return

first = pool[0]
for i in range(1, len(pool)):
pair = (first, pool[i])
remaining = pool[1:i] + pool[i + 1:]
for rest in _match(remaining):
yield [pair] + rest

return _match(elements)

Here's some recursive magic to generate all unique sets of pairs.
>>
bigboy
https://files.catbox.moe/smdsek.txt
Part 1: 30609680
Part 2: 9705136
Part 3: 9728834
>>
>pathfinding day
yeah no thanks
>>
File: BFS.gif (32 KB, 187x175)
32 KB GIF
>Breadth-First Search
>start at node 1, with distance 0
>push all of its adjacent nodes to a queue, update their distances to 1
>for every element in the queue, if its adjacent nodes don't have a distance yet, update its distance and push it to the queue
>find all distances from node 1 to each unique destination node
>repeat with each unique starting node
Is there a way to cache some information here, instead of starting from scratch each starting node?
If I had the complete set of all of node 10's adjacent nodes' distances, and I wanted to know the minimum distance from node 10 to node 4, then I could see that the distance from node 9 to node 4 is 5 steps and the distance from node 1 to node 4 is 3 steps, so the minimum distance from node 10 to node 4 is (10->1) + (1->4) = 1 + 3 = 4 steps.
For Part 1, if you created the distance map for every OTHER node, the skipped nodes could re-use their neighbors' maps. But this breaks down when you add shortcuts, and in Part 2 and 3, each node has at least six adjacent nodes instead of just two.
>>
>>110287683
If the input graph were a tree (without any cycles), you could do this with tree rerooting and 2 DFS passes instead of N BFS passes (where N is the number of nodes).
However, since the input graph has cycles, then I don't think it is possible. Tree rerooting would give an incorrect answer.
>>
File: file.png (36 KB, 843x333)
36 KB PNG
>>110287411
with >>110287123
>>
File: 2026_quest11.png (229 KB, 1639x2195)
229 KB PNG
>>
>>110287866
Same
30609680
9705136
32011074
>>
File: 11.png (860 KB, 2258x4958)
860 KB PNG
idiomatic Rust solution

>>110287411
Part 1: ~2ms
Part 2: ~7m38s
Part 3: ~18s
>>
I decided i'd try out EC this year since AOC disappointed me so much last year, but I don't think I've enjoyed solving even a single question.
>>
File: file.png (484 KB, 1474x4176)
484 KB PNG
Elisp performance killed me today. I had to spend a bunch of time optimizing and my first p3 solve still took 210s. I got it down to 110s but I probably need to do something about the FW loop.
>>
File: leaderboard.png (161 KB, 1252x1818)
161 KB PNG
>>
>>110292818
>Most prestigious tech board in the world
>Only 9 people aren't filtered.
>>
30 MINUTES.
>>
3 hours of work for quest 5 part 1. Zig spaghetti code that barely works.

See part 2. More of the same. I'm tired boss.

Question: Is it possible to find all land in a single pass? I do multiple passes and stop once no new land has been added.
>>
5 MINUTES
>>
>>110295277
>multiple passes
That's the only way.
>>
FINISHED
I ask this every day, but there's DEFINITELY a smart way to solve today, right? I essentially brooted, but it worked.
The start of the board only has one state, so I try doing a vertical and a horizontal move on the top-leftmost rock, creating two possible states with one move.
Then, for each state, I try doing a vertical and a horizontal move on their top-leftmost rock, creating a total of four possible states after two moves.
Repeat until I find an empty state, where all the rocks are gone.
I also ensure there aren't any duplicate states after each check is finished.
Finishes with the correct answer on Part 3 in less than a second.
>>
File: Part 3 Visualization.png (10 KB, 301x151)
10 KB PNG
Small easter egg in my Part 3 input.
Duck in the center.
>>
>>110296201
I used dfs to get each stack and get its min and max x,y and also get the number of rocks in it. If there is no empty space, then it is a rectangle, if there is an empty space at the borders, then it is an L, else it is a rectangle with a hole within it.
Every stack also has a unique number (1,2,3, etc.) so I could easily ignore other stacks when calculating its type and also the minimum number of moves.
>>110296580
nice
>>
AI can solve all of these faster and better
>>
>works on the sample
>fails on the real input

A tale as old as time. My approach is dumb, but I am too tired to fix it.
>>
File: 12.png (663 KB, 2195x4142)
663 KB PNG
idiomatic Rust solution
>>
p3 example 3 is some bullshit
the inner L shape has no gap between it and the containing shape
do the actual inputs have this case?
I don't see any in >>110296580
>>
File: fixed_example3.png (7 KB, 602x516)
7 KB PNG
>>110298382
I assumed the example was wrong, and adding the gap as in pic related still gave me the expected answer.
My actual input didn't have that case.
>>
>>110298106
Are you computing the number of spells greedily?
That works on the examples but not the actual input.
>>
>>110298733
how do you construct a counterexample for this? I think my p3 is wrong for the same reason
>>
File: lol.png (57 KB, 1732x460)
57 KB PNG
>>
File: big.png (437 KB, 1692x1110)
437 KB PNG
Big boy
https://files.catbox.moe/adczqr.txt

Ans: 124118
>>
>>110299394
I get 121021
>>
>>110298382
>>110298456
>>110299254
wew
>>
>>110299394
>>110299417
Does the actual problem description ever mention if all the spells for a given stack activate simultaneously, or individually?
It probably never matters for the minimal amount needed with the simple shapes, but in a more complicated example like this one, there might be certain strategies that are either beneficial or impossible with individual spell casting.
>Picrel:
>A vertical spell followed by a horizontal spell has different results depending on simultaneous casting (above example) or individual casting (below example)
>Simultaneous casting allows for overlaps, as seen in the top example
>Individual casting splits the stack, disallowing overlaps, as seen in the bottom example
>>
>>110299712
nonsensical post
>>
File: 1706112848561052.jpg (90 KB, 750x1000)
90 KB JPG
I'm filtered, see you guys at AoC
>>
>>110299417
25573 for some reason
>>
>>110296201
for the rectangle use min(h,w)
for L shape I split it into 2 rectangles either vertically or horizontally and then use min(min(horizontal), min(vertical))
for hollow rectangle it is similar to L shape, split it into 4 rects horizontally and vertically and find which split gives you smaller number of spells
>>
>>110298755
For me, I got the wrong answer for the example below as I try horizontal spells first.
#####
#####
##.##
##.##
#####
>>
>>110300034
god dammit I get 6 for that
>>
>>110300073
but 6 is correct
>>
>>110300073
you should get 6?
>>
>>110300112
that's the problem, my solution works for all the examples I throw at it but not my puzzle input
>>
do your inputs have 699 shapes?
>>
Wrote a bit of elisp to render the current shape and answer one at a time. I was off by 2 because of this https://pastebin.com/Et9YyP6p
The answer is 17, but every other shape had the correct answer, even the difficult ones I didn't immediately see. I just subtracted 2 from my solution and it worked.
>>
>>110300637
you didn't solve it
>>
>>110298755
what's your greedy solution, anon? there can be different greedy algorithms for the same problem.
>>
>>110298733
I was doing greedy. But my dumb greedy version was able to get >>110300034 correct.

I just kept tweaking until it worked. Working solution just looked at all contiguous lines at the edges of the shape, assuming that cutting the middle was a bad idea. My final working solution is a spaghetti mess too unwashed to post.
>>
>>110301140
Me >>110300637
I repeatedly take the longest slice of the shape both horizontal and vertical, in my counterexample the solver did all vertical cuts because the shape is taller than wide.
>>
File: 2026_quest12.png (172 KB, 1368x1824)
172 KB PNG
>>
>>110299810
.#.#.
#####
.#.#.
#####
.#.#.

How many spells does this take?
>>
5 MINUTES
>>
>>110304305
Not that anon, I get 8.
>>
ching chong
>>
>>110304558
that's what I was thinking too
>>
if two hands have six notches around the clock
and the first hand is going from notch 1 to notch 3
and the second hand is going from notch 2 to notch 4
you would think they meet up between 2 and 3
but they don't because they would both be moving at the same speed

there's enough edge cases here that I wonder if I'm thinking about it wrong
>>
I know people like to make fun of 'advent of reading comprehension', but the way these problems are written feels way more convoluted.
>>
>>110304558
When I wrote that, I thought CRT was the way, but it was the wrong idea
>>110305361
It's probably the hardest part.
>>
>part 2
>passes the small test case
>try on the big test case
>passes all ten cases at the bottom with the small outputs
>fails a few of the really large cases
>correct for most but for the rest my answer is always too low
>try debugging and changing things
>still passes the ten cases at the bottom
>now the ones I get wrong are too high
>>
File: not filtered.png (62 KB, 846x667)
62 KB PNG
that was MISERABLE
but I'm NOT FILTERED
>>
>>110305361
yeah, it is annoying. Part 1 took me the longest, but parts 2 and 3 were straightforward.
>>110304785
true, those two hands don't meet, it was messing me up for a while because speed matters when the hands are going the same direction.
>>110289337
funny you mention that. It is my first time trying EC, but I honestly don't feel accomplished after solving any of these. I just feel glad I don't have to do these again after solving them kek. The thread is comfy, at least.
>>
>finally make it to part 3
>it's another fucking cycle detection episode
kill me
>>
>>110307185
It's not.
>>
File: 13.png (434 KB, 2237x2846)
434 KB PNG
idiomatic Rust solution
>>
>>110307252
NTA I solved it with cycle detection.
>>
File: 2026_quest13.png (149 KB, 1325x1336)
149 KB PNG
>>
File: carbon (6).png (1.48 MB, 1024x7534)
1.48 MB PNG
>>110307477
I want to die

at least I'm not filtered
>>
>dead thread
>>
>>110310000
>quads
>>
>>110310569
>repeating digits in an integer sequence are noteworthy
one of the cringiest parts of """chan""" culture
>>
>>110310000
I started late so I'm several days behind.
>>
more like everybody copes hehe
>>
20 MINUTES
>>
5 MINUTES
>>
Brooters... It's not looking too good today...
>>
>>110316374
thankfully a greedy algo works for part 2
part 3 looks like a little broot with the same greedy algo will work
>>
FINALLY, a problem that is not convoluted. Once you know what kind of classic problem you have to solve in part 2, the rest is straightforward.
>>
File: carbon (7).png (547 KB, 873x3213)
547 KB PNG
Unwashed, takes like 30 seconds in pypy because the data structure I used for part 2 (and reused for part 3) isn't efficient.

>>110316580
Yeah, not too bad today.
>>
File: Day 14 Visualization.png (15 KB, 480x240)
15 KB PNG
>NO EASTER EGG FOR THIS PART
>>
File: part2-noquack.png (8 KB, 656x336)
8 KB PNG
>>110316924
P2
>>
>>110316543
If you treat it as a weighted graph (edge weight is number of connections), you could use Prim's algorithm to get the minimum spanning tree.
>>
Has AoC ever done a Prim's or Kruskal's day before?
>>
>>110317162
I feel like they must have, at some point across their 11 years. I definitely recall a min-cut problem.
>>
File: file.png (11 KB, 204x333)
11 KB PNG
>>110317162
The last time I remember implementing Prim's algorithm was for a reasonably popular Fallout 4 mod almost 10 years ago, and I have zero recollection of ever having to use it for an AoC problem.
>>
If Part 3 had used a comma as a symbol for the glass panes, I would've been done for.
>>
>>110317749
I was using "W" at first, then switch to simply enumerating them from 1 onwards, keeping 0 for my wall.
>>
>>110317162
closest I could find is this
https://adventofcode.com/2025/day/8
>>
File: 2026_quest14.png (227 KB, 1795x2243)
227 KB PNG
>>
File: 14.png (544 KB, 2237x2990)
544 KB PNG
idiomatic Rust solution
>>
>>110319691
>idiotic Rust solution
>>
File: leaderboard.png (161 KB, 1230x1808)
161 KB PNG
>>
>>110323548
And then there were 8
>>
up
>>
>>110323548
durgasoftbros...
>>
>>110327449
Elite Durga grads were being parachuted in all night to fix Microsoft's disaster.
>>
10 MINUTES
Weekend problem, very hard, not for Dalit.
>>
Quest 15: Repair the USA air traffic control systems.
>>
Turning does not cost 1 second
>>
Passes example, real example is taking forever........ AAAAAAACK
>>
part 2 right for the example, fails on actual input. what am I missing
>>
Totally hard-coded Part 3
>>
File: carbon (8).png (1.51 MB, 1024x8167)
1.51 MB PNG
>it's ANOTHER cycle detection with a little bit of simulation to clean up the starting and trailing ends day
I'm getting so fucking sick of this class of problem.

Have some extremely unwashed ass complete with 2 dead-ends for part 3.
Also my part 3 doesn't work on the example, and I know why but it would be annoying to fix so I can't be bothered.
>>
>>110330374
My Part 3 gets the most efficient sulphur gain by looping through the two tunnels immediately to the right of the entrance, going in one big circle. Because of this, I didn't have to do any before-the-cycle-starts cleanup other than adding 1 to total distance.
Did I get lucky with my input? Are there some inputs where the fastest way to get sulphur involves first entering a couple tunnels on the way towards the best cycle?
>>
>>110330374
yeah, today was a pretty poor problem. At least it was easy to understand.
>>
File: file.png (86 KB, 950x1004)
86 KB PNG
>>110330447
For me it looks like the optimal path is looping through the second ring of tunnels around 3493452788 times (actually a few more I'm sure), then looping through one half of that ring again, and then whatever's going on with the ~ after that.

Basically I found the optimal loop (although it only covers full loops through both the top and bottom half, because that's how my input works--but not how the example works, so it doesn't work on that), and recorded the starting tile for that loop + sulfur collected + steps.
Then I did some math and counted that tile as being worth exactly 202620261704 sulfur, which leaves 322 sulfur to be collected "normally". And then I just let a simple BFS find the shortest path to the end that passes through that one "magic" tile, and ends up with 322 sulfur at the exit. (picking ~300 was arbitrary and a little conservative, it just has to be longer than the path from the start to the exit minus the loop)

If the most efficient loop in my input happened to start on the tile immediately after the entrance like yours, I could've skipped the extra checks to make sure the 322 path *actually* visits the magic loop-start tile. Although I just checked and found that I get the same answer without that safeguard anyway.
>>
File: 15.png (674 KB, 2198x3710)
674 KB PNG
idiomatic Rust solution



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