[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: Day 15.png (148 KB, 590x591)
148 KB
148 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 in November. Puzzles drop at 4PM EST with weekends off

>oh no I started late
Can sort leaderboards by "local time" which doesn't start the clock until you open the puzzle. Not used for global ranking but still fun to be able to compare how you did

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

Last >>107265692
>>
Solved.
If there's a pure math way to solve part 2, I don't know it.
>>
I have no idea what part 3 is asking
>>
>>107317088
It is asking you to find how long the wall is.
>>
>>107317088
Part 1 wanted you to find the total blocks used in a wall given its length.
Part 3 wants you to find the total length of a wall given its total blocks used.
>>
File: EC-16.png (120 KB, 854x1264)
120 KB
120 KB PNG
There's probably a clever maths way of doing part 3, but given calculating the blocks for a given length is trivial I just binary searched for the answer.
>>
File: carbon.png (231 KB, 632x1630)
231 KB
231 KB PNG
>write part 3 as binary search
>never calculates a wall of exactly the given length
>try submitting one of the numbers near where it gets stuck
>the first one I pick is right
>realize while writing this that my input can't construct a wall of exactly 202520252025000 blocks, it's either 1 short or 1 over, and I luckily picked the right one before
goddammit that's a dirty trick

Haven't bothered to fix it yet, here's some lightly washed ass.
>>
File: carbon.png (220 KB, 1196x1286)
220 KB
220 KB PNG
At first I tried to lcm the third part but that's way higher than number of blocks so I did the same as >>107317215
All in all, an easier day.
>>
File: quest16.png (59 KB, 592x757)
59 KB
59 KB PNG
>>107317215
Did something similar except for instead of binary searching I just find the right digits one by one.
>>
Came here feeling ashamed of my binary search solution, see everyone else did it.
>>
I wonder if anyone got that in their inputs but what happens if you have multiple of the same value in you spell, making your wall look like this?
[1,1,1,5]

This should translate to [1,4,4,4,4] spell.
>>
haven't gotten to today's yet, how was it? similar to most of last week or more like friday?
>>
>>107317329
Why feel ashamed? If your code runs in < 5 ms then there is absolutely no need to feel any shame.
>>
>>107317354
Easy street
>>
File: eq.png (48 KB, 1732x163)
48 KB
48 KB PNG
>>107317215
I don't think there's a math way, you cannot get rid of those floors. It's cheap to calculate only one-way, so searching is going to be the best way.
>>
>>107317283
the ol' decimal search method
>>
>>107317329
I didn't even use binary search, I just did linear search from an initial estimate
>>
>>107317343
I accounted for this possibility but it looks like my input has unique values only.
>>
This was way more of a pain than it should have been.
I did an LCM on the spell so I knew the number of full cycles it'd do, and then just linearly searched the rest. But I fucked up somewhere so it'd work on every example but not my real input. So I did a second linear search around my initial answer to get the real answer.
>>
does the difficulty ramp up for the last few days last year?
>>
>>107317615
Not sure how the LCM helps here, it resulted in a number very yuge, the likes of which no one has ever heard before.

136 duodecillion 463 undecillion 565 decillion 177 nonillion 293 octillion 340 septillion 984 sextillion 580 quintillion 650 quadrillion 731 trillion 481 billion 21 million 692 thousand 880
>>
>>107317428
It worked for my papa, it works for me!
>>
>>107317682
Sounds like your mother's bodycount. Oh, snap!
>>
>>107317697
Yeah well, I'm the sperm that made it so...
>>
bigboy generator
>create a wall with the spell: [1,2,3]
>get the quantity of blocks in every column until they LCM: [1,2,2,2,1,3]
>use this list as a spell to create another wall, and get its columns until the spell LCMs: [2,5,3,5,2,6]
>if the resulting spell has no 1s in it, add one: [2,5,3,5,2,6,1]
>use this list as a spell to create another wall, and get its columns until the spell LCMs [1,3,2,3,3,5,1,3,2,5,1,5,1,3,4,3,1,5,1,5,2,3,1,5,3,3,2,3,1,7]
>repeat ten times
>>
Easy day makes for a dead thread, huh?
>>
>>107318862
it was never that active desu and gets more dead with each friday filter
>>
File: top10.jpg (57 KB, 645x387)
57 KB
57 KB JPG
>>
File: 16.png (843 KB, 5440x4752)
843 KB
843 KB PNG
>>
>>107319069
Yeah, even the AoC threads would always start dying by the end of the month, with ~10x as many active anons.
>>
>>107319455
i'm kind of surprised we've got 20 lads on the /g/derboard who are still doing it, i'd guess most of them never post in the thread
>>
>>107319506
>lads
Cool it with the gendered language, we have at least two ladies on the leaderboard (tagged).
>>
File: carbon(14).png (346 KB, 1330x1592)
346 KB
346 KB PNG
It was quicker to solve part 3 by hand than to fail at writing a digit solver.
>>
>>107319619
ladies (male) don't count
>>
File: d16.png (1.1 MB, 557x1046)
1.1 MB
1.1 MB PNG
I felt like a genius solving P2 so quick. Then I felt like an idiot after I struggling on P3. Overall feeling neutral. Have a good week boys!
>>
File: carbon(15).png (392 KB, 1330x1852)
392 KB
392 KB PNG
>>107319633
and here's the same with the bugs in my part 3 solver worked out
>>
File: ec2025-16a.png (179 KB, 967x1402)
179 KB
179 KB PNG
>>107317682
Guess that was actually my issue
I stored it in an int32 and it overflowed, resulting in a value around 100M, and I assumed that was the correct lcm.
Curiously it did get me very close to the correct answer (first 6 digits were correct), so I was able to linear search from there.

In the end I managed to spend more time on this puzzle than on day 15.
>>
File: haskell16.png (485 KB, 1690x1971)
485 KB
485 KB PNG
I did it with a binary search too
>>
>>107317615
It was a trick, the example made the lcm look viable
>>
File: programming_explain.jpg (359 KB, 3000x1680)
359 KB
359 KB JPG
Can you guys explain day 15? I got hard filtered on it when I tried DFS and A*. I checked the hints last thread and my understanding is we can still solve it with A* but we only add corner points to the path and check wall intersections every move?
>>
File: 15.png (855 KB, 2906x3528)
855 KB
855 KB PNG
>>107324168
>>
File: ec_day16.rs.png (279 KB, 750x1043)
279 KB
279 KB PNG
>>
File: rust supremacy.png (113 KB, 3760x800)
113 KB
113 KB PNG
>wagelets on suicide watch
>>
>>107324168
I did

>consider each wall to be bordered on each side by paths
>extend paths until they collide with a wall or hit map boundaries
>intersections between paths are nodes, paths are edges
>dijkstra or any search algorithm on this graph will solve instantly

You can do similar with corners, which looks like the more popular approach. tldr is you need to compress the graph in some way.
>>
>>107325714
You do understand that I'm beating all of your averages, but you happen to be two compared to my one? But great that you beat the unemployed guys I guess
>>
>>107326033
Rustchads are too busy at their 6 figure dayjobs to nolife every challenge the moment it releases
>>
File: maxresdefault (4).jpg (91 KB, 1280x720)
91 KB
91 KB JPG
>>107325864
that actually makes a lot of sense thanks!
>>
5 MINUTES
>>
>part 3
uhhh
>>
Anyone got a HTTP error when opening the quest?
It's fine when I am not logged in though.
>>
>>107327514
Seems like it's fixed now. Thanks for wasting an hour Emil.
>>
SOLVED
WHEW
I was scratching my head for a while there. I think I didn't start programming anything until starting at Part 3 for like 20 minutes.
Also I solved it in a really inefficient way and it took half an hour to run.
But I got my ducks.
>>
File: carbon.png (580 KB, 1450x2452)
580 KB
580 KB PNG
Path has to go through a line to the left, down and right of the center. So I calculate best path for each combination of points on those lines that fits the radius, then, if nothing is found, I increase the radius.
./17.py  724.28s user 0.10s system 99% cpu 12:06.29 total

nuff said
>>
File: EC-17.png (265 KB, 1083x2591)
265 KB
265 KB PNG
Absolute unwashed ass. I used 3D voxels rather than 2D points for part 3, creating a copy of the top half of the map extending upwards into the Z direction. I swapped the start with an end target in this new section, trimmed the joins to make sure valid paths could only go around the volcano, the just dijkstra-ed over the thing for each stage of the volcano limited to the max allotted time until I hit on a solution. About 15 seconds to run.
>>
File: EC Refresh.png (15 KB, 497x173)
15 KB
15 KB PNG
>>107327514
No, but I've had this pop up and refresh the page every few minutes.
>>
File: ec2025-17.png (380 KB, 595x3205)
380 KB
380 KB PNG
Wew that turned ugly
I improvised a priority queue structure, but then forgot to actually use it and kept using the basic linked-list based queue I used on day 15
Takes 120 seconds to run
>>
111111S111111
1999999999991
1999999999991
1999999999991
1999999999991
1911199999991
191919@999991
1119199999991
9999199999991
9999199999991
9999111111111
9999999999999
9999999999999

A: 47


111111S111111
1999999999991
1999999999991
1999999999991
1911111119991
1919999919991
191999@919991
1119999919991
9999991119991
9999991999991
9999991111111
9999999999999
9999999999999

A: 166
>>
damn, this is still going on? i stopped caring like a week and a half ago
>>
>>107328567
You mean you got filtered on quest 10
>>
>works on all examples but not my input
I think this is it for me
>>
File: aaaargghhhhhh.png (39 KB, 756x755)
39 KB
39 KB PNG
That part at the top killed me. If I hadn't visualized it, I'd still be stuck. My code removed the entire left side of the start from consideration, so it was never able to find the very best way home.

The bastard got me.

>>107328567
>Ugh you guys are STIIIILLLL doing this!?
Filtered.
>>
wtf is this part 3? haven't even written a line of code for it yet and i'm not sure i will
>>
>>107329080
I think I've seen this in science class. Is this what they call "sexting"?
>>
File: quest17.png (232 KB, 3598x3592)
232 KB
232 KB PNG
>>107329649
Art is in the eye of the beholder.
>>
Didn't know this was running.
Compared to advent of code, which has been kind of shit for the last four years, is this any good? Are the puzzles actually satisfying at all?
>>
>>107329935
I thought today's was fun, it certainly grows on you.
>>
File: 17.png (1.21 MB, 2960x4744)
1.21 MB
1.21 MB PNG
>>
File: dandelion.jpg (540 KB, 1613x1950)
540 KB
540 KB JPG
>>107329909
>>
>>107326033
>I'm beating all of your averages
You don't though.
>>
>>107330883
No, I still do in both teams and local teams. If you normalize the Rust score by dividing it by the number of people they are suddenly trailing behind my CPP score. I'm close behind treui7, but unfortunately he is dragged down by his sister purplefirefly who is just atrocious.
>>
>>107316573
>free
>please verify your identity through one of our chosen big-corpo partners
remind me why I have to get undressed so some codefags can pose a problem?
>>
>>107331576
>filtered by the registration
You're not off to a good start.
>>
>>107331642
>yes, I suck big corpo dick and because I do, I have to do everything in my power to shame others into it too, so I'm not alone
Again, why do I have to register in this way? Except to make you feel good about being a slut of course
>>
File: ec2025-17a.png (294 KB, 581x2270)
294 KB
294 KB PNG
>>107328187
Cleaner
Also actually using my proper(?) priority queue now, so the total runtime went from 120 seconds to ~5.
>>
>>107331691
To track your progress throughout the competition. You sound like a freetard so this cannot be the first time you've had to make up a fake name on one of these services, just do that.
>>
File: carbon.png (624 KB, 973x3362)
624 KB
624 KB PNG
>>107328094
I started off by doing that, then realized I could have it only pass through two lines in an inverted V shape from the volcano, and then finally realized I could make it only one line if I take the left and right lines I'd commented out, and alternately use them to just block off half the grid for each half of the search.
I also had a max_cost param in my Dijkstra's at first, to kill any paths that would take too long for the current radius, but I fucked up the math somewhere and it would overly aggressively cull good paths for some reason.
Eventually it occurred to me that I could find the shortest path but with no volcano at all initially, and then calculate the next volcano radius based on the cost of the shortest path. So the first iteration cost was 493//30=16s, so it would bump the radius (and cull destroyed tiles), re-find shortest path, second iteration was 726//30=24 so bump radius to that. The first time the recalculated radius doesn't change, the last shortest path you calculated is the answer, and for my input it only takes about 8 iterations to get to the answer.

Took me ~3 hours just for part 3.

Post-completion I generalized how those lines are generated for any S/@ placement, so you can tweak the input and see what happens in the little ASCII render, it's kind of fun.

Also FUCK I completely forgot it's trivial to tweak Dijkstra's to find the shortest path to all nodes instead of one at a time. Then for the second half, I think I should be able to reinitialize the Dijkstra with the output of the first iteration (all positions+costs) and then path back to the start from all midpoints at once. Those together should cut my runtime by a factor of at least 50 (and it's about 50s currently, too).
>>
File: q7.png (1.51 MB, 2110x9006)
1.51 MB
1.51 MB PNG
I'm doing 2024 just to get my feet wet.
Having the inputs change is kinda an ass. My biggest problem with part 3 was that I was parsing the single opponent input incorrectly, but it still takes 25 seconds to run.
It's fine. I don't care. I should have made my own permutation generator earlier.
>>
>>107329909
I hate that I saw it immediately
>>
File: carbon.png (632 KB, 973x3343)
632 KB
632 KB PNG
>>107332017
1.4s runtime in pypy, hell yeah.
However, CPython now produces the wrong answer for part 3. Wtf did I do?? Ugh, I'll investigate later.
>>
>>107332017
>just block off half the grid for each half of the search.
What if the path zig-zags and passes the border more than once THOUGH?
>>
>>107332506
>You must create a Recurlia loop around the volcano
>>
File: file.png (77 KB, 346x706)
77 KB
77 KB PNG
>>107332506
It would have to pass a line drawn straight left from the volcano, then the midpoint straight down, then back to the left, before going back below, then straight right of the volcano.
I'm sure you could contrive an input that did that, but I guarantee none of the official inputs do that.
>>
File: ec_day17.rs.png (431 KB, 868x1516)
431 KB
431 KB PNG
Unwashed answer, 45ms runtime, wtf are you all doing
>>
>>107332017
You're overcomplicating it.

>pick a random line out from the volcano
>when you cross the line, flip a bit
>when two states match (same location with opposite bit) you've found a loop
>>
File: filtered again.png (35 KB, 940x470)
35 KB
35 KB PNG
lol
>>
File: 17.png (3.56 MB, 1024x1536)
3.56 MB
3.56 MB PNG
Yesterday was cool. I'm still on Part 3. Part 1 and 2 we're fun. For Part 3 I tried just deleting some columns and rows and A*'ing to the furthest hole point and back, but my loop isn't tight enough. No one likes a loose loop. Good luck today you mother duckers!
>>
>>107335874
That's potentially a valid strategy, fundamentally, but you have to look for every point on the line segment under the volcano instead of a single arbitrary one on it.
Recall that it's trivial to tweak Dijkstra or A* to return the lowest cost to every reachable node all at once (or a specific subset etc), instead of just one. Then for your second search back, feed all the points you were searching for with their lowest costs back into the algorithm simultaneously as the starting state. You can trim it down to the same 2 algo runs for each volcano radius you check, while still being able to check the shortest path that passes through every single point on the lower line.

>>107332489
Realized while sleeping that my bug was forgetting to set the heapq back up properly for the second Dijkstra (just doing a heapq.heapify() on it), and because of some implementation detail, pypy still worked, but CPython didn't.
Corrected CPython runtime is ~2.4s.
>>
>>107335874
>I'm still on Part 3
Less than 2 hours 15 minutes until you're filtered. TICK TOCK.
>>
>>107337152
ahh cool thanks!
>>107337528
Haha ya these last few part 3s took me a while. The programming parts I can mostly do, but figuring out the puzzle parts I’m too low IQ for. Mostly I’m just in it for the AI duck gens.
>>
>>107337152
The blind leading the blind
>>
half an hour left
>>
>>107338419
There's no significant runtime difference compared to >>107333056 and it's closer to what AIduckanon already has, what's the problem?
>>
>trees
fuck I'm self-taught, I don't know how to tree
>>
reading comprehension
>>
>part 3
ugh
I don't want to have to figure out what this ghetto neural net is doing internally.
>>
Solved!
Basically like those AoC days where you have to make an interpreter and then find out what the code is actually doing.
The "Trick" was pretty simple though. I thought of it after paying close attention to my input, and my hunch was correct.
>>
File: file.png (28 KB, 467x546)
28 KB
28 KB PNG
>>107340295
Yippee
Yeah, I had the same hunch and it turned out to be right. Definitely a problem you're supposed to exploit a quirk of the input for, without any particularly deep analysis of the neural net thing it makes.
>>
Fucking hell, this quest was once again a great reminder to fucking go to bed and solve the task tomorrow instead. Because I'm fucking stupid after 00:00.
And WTF was that input on part 1?
>>
>>107339299
I'm also self taught. Trees are easy. You just have some sort of reference between the nodes that are connected, but you don't need to store it like parent -> child, it can be child -> parent or parent <-> child depending on how you're actually doing the calcs later on. And you don't need to store it as pointers, you can just put the tree in an array and then have the reference be an index in the array.
>>
So how to solve part 3 for general input? Some kind of backpropagation?
>>
>>107340994
I guess I would go plant by plant and check for sign changes, if none then either turn on or off. If there are, calculate the weight and determine if it is a net negative or net positive. But I don't think this approach can handle every input, there arre most likely weird edge cases that would make me look stupid.
I dunno, this is hard problem.
>>
File: EC-18.png (251 KB, 817x2287)
251 KB
251 KB PNG
Very much an "I'm amazed this shit worked" day. For part 3 I took the best of the tests as a starting point, then went through each leaf node, swapping it and seeing if it made the max brightness better.
>>
>>107340994
The whole tree can be reduced to a boolean math equation but I don't know how you would handle
>If the total incoming energy is less than the thickness of the plant, it will not glow and will not emit any energy to the next plants.
>>
>>107341110
maybe integer linear programming is the way
>>
I solved part 3 by locating the "free states" which never had a negative edge on their way to the final plant. For all of these, I fixed them to on.

Then I just did a greedy search through the remaining states, turning which ever one increased the overall score. Repeating until no further improvement.
>>
>>107341269
>Then I just did a greedy search through the remaining states, turning which ever one increased the overall score. Repeating until no further improvement.
And how many states can be turned on this way?
>>
>>107341281
Ugh yeah I over engineered that. 0. All I need are those start states.
>>
>>107341217
The conditionals on plant thickness exceeding the incoming amount will make it hard for ILP.
>>
>>107341341
Actually I take it back, the start states are only enough because his input isn't pathological. There could be cases where something isn't picked up in the start state, but could stilly yield an improvement.... the example for instance.
>>
>>107341392
can't that be formulated as a linear constraint?
>>
>>107341455
I'll see what I can do...
>>
>Tomorrow's puzzle drops mid-afternoon Thanksgiving
Oh, I'm going to miss the drop. Bummer.
>>
https://adventofcode.com/
It's open
>>
>hard-coded max input case just from looking at my part 3 input
>it worked

lel. also fuck any puzzle that adds extra parsing rules after part 1. not that it was a big deal today, but the sheer principle of it annoys me
>>
File: 18.png (912 KB, 2932x3784)
912 KB
912 KB PNG
>part 3 input has special property that example input lacks
classic
>>
>>107342562
>only 12
ANTI-SOUL
>>
File: 1737355559087552.png (451 KB, 1582x2494)
451 KB
451 KB PNG
>>107340994
You can easily use it to encode subset sum, so the problem is np-complete:
You have three internal nodes:
A with thickness 1
B with thickness 2
C = A - B with thickness 1
For each element x of your input set S, make a leaf node that you connect to both A and B with thickness x.
C can only be turned on if there is a subset of S that adds up to exactly 1.

I saw that the input had some quirk, but didn't want to bother figuring it out so I just imported solution.
>>
>>107342095
Why? I’m not an american so my view of Thanksgiving may be a bit skewed, but I thought you celebrated it by brawling in the middle of a turkey dinner and spending the rest of the afternoon in separate rooms. Just say
>whatabout that Trumpdani meeting
five minutes before the drop and it will naturally solve itself.
I thought you’d have bigger problems making it to the drop on Black Friday
>>
File: ec2025-18.png (303 KB, 595x2292)
303 KB
303 KB PNG
One of those days where I came up with a solution as soon as I went to bed.
But then it didn't work and it turned out the actual solution was even simpler.
>>
File: AoC Intro.png (7 KB, 754x578)
7 KB
7 KB PNG
>>107342562
What are we thinking? That's supposed to be the North pole with an igloo or tent of some kind?
>>
>>107316573
i hecking love part 3s with hardcoded inputs
>>
>>107345238
filtered
>>
File: EC-18-Stats.png (17 KB, 968x463)
17 KB
17 KB PNG
Absolutely brutal. Clearly people can't handle navigating a simple set of nodes.
>>
>>107346250
I could have done it if I wanted to, I just got bored.
>>
>>107316573
I don't code, never will code, so no not everyone codes, this site is dumb. Dumb cunts.
>>
Honestly I woke up. Read the question. Didn't understand it at all. Had some coffee. Read it again. I have no idea what its asking. Sorry boys I'm out.
>>
>>107347748
Let me guess, webdev? Typescript? React?
>>
reminder that if you miss today's problem due to thanksgiving, you are filtered
>>
>tfw pulling the team average down

Sorry krautbro...
>>
>>107350098
There's no time limit, if you solve the problem a decade after it released you're not filtered. But if there's a single AoC or EC problem you haven't solved? Filtered
>>
Happy Thanksgiving. Also what the fuck is today’s question asking? I get that it’s an adjacency list tree thing. But what’s going on with sometimes you add and sometimes you multiply and sometimes you use the node value and sometimes you use the edge weight. I can’t make heads or tails of that chart and table.
>>
>>107348239
>>107350637
give all free branches an "energy" of 1
for every node on the tree, get all of its chilldrens' energies multiplied by their thickness, then add together
Plant 4 with thickness 17:
- branch to Plant 1 with thickness 15
- branch to Plant 2 with thickness 3

>Plant 1 has an energy of 1 and a thickness of 15
>1 * 15 = 15
>Plant 2 has an energy of 1 and a thickness of 3
>1 * 3 = 3
>15 + 3 = 18
>Plant 4 has an energy of 18
then when plant 7 has plant 4 as one of its children, you now know that plant 4 has an energy of 18
>>
Oh cool thanks I think I mostly follow but why is the energy of node 6 in the example zero? Shouldn’t it be 14 x 34?
>>
File: 1742973083996560.png (173 KB, 350x446)
173 KB
173 KB PNG
/Plant (\d+) with thickness (-?\d+)/
>>
>>107351084
>If the total incoming energy is less than the thickness of the plant, it will not glow and will not emit any energy to the next plants.

ahh fuck okay got it now thanks
>>
>>107342095
AmerifatsBTFO. Enjoy your holiday.
>>
>>107343635
>z3.IF(...)
Damn, that's convenient.
>>
>>107347748
>I don't code, never will code
Imagine being so badly filtered you come to a coding thread to announce you don't code.
>>
Is my logic crazy? I should be able to deque from free branch ( node[0] ) and power up all the connected nodes from there and get the right answer? It works on the example.
thicks = [0] * 100
energy = [0] * 100
adj = defaultdict(set)
curr = 0
for line in data.strip().splitlines():
if not line.startswith("-"):
k,v = [int(x) for x in line[:-1].split(" ") if x.isnumeric()]
thicks[k] = v
curr_node = k
else:
line = line.replace("free branch", "0")
nei, thickness = [int(x) for x in line.split(" ") if x.isnumeric()]
adj[nei].add((curr_node, thickness))
q = deque()
q.append((1, 0))
while q:
power, node = q.popleft()
for nei, thickness in adj[node]:
energy[nei] += power * thickness
if energy[nei] >= thicks[nei]:
q.append((energy[nei], nei))
print(max(energy))

#>>> thicks
#[0, 1, 1, 1, 17, 24, 15, 10, 0, 0]
#>>> energy
#[0, 1, 1, 1, 18, 24, 14, 774, 0, 0]
>>
>>107351735
oh I think its like a topo sort because you can only go through once. my bad. good luck today
>>
Code fails on his example data for p1 and p2... but passes my inputs, just great. p3... ugh I guess it's all about the coast.
>>
File: carbon.png (334 KB, 1768x2382)
334 KB
334 KB PNG
Feels good my part 2 code just works for part 3.
Happy thanksgiving everyone.
>>
Someone post code, I swear my part 3 is correct
>>
>>107352619
nvm I got it
>>
File: ec2025-19.png (334 KB, 673x2556)
334 KB
334 KB PNG
Unwashed
For some reason I had an off-by-one when testing on my first two inputs, just adding 1 to my part 3 answer gave me the correct number. It's too late to care about such things
>>
>>107352684
I had similar and the problem was [spoiler]I assumed the cone was continuous, but irl it's a checkerboard pattern where you can only visit every other square[/spoiler]
>>
Linear optimization for the win! I couldn't convince myself that there was anything wrong with ignoring all the higher openings (when you have multiple per column), and that seemed to work.
>>
File: EC-19.png (107 KB, 1016x961)
107 KB
107 KB PNG
Ended up being quite a small amount of code for the penultimate day, but holy fuck was there a lot of wrangling off-by-one errors to get here.
>>
File: ec_day19.rs.png (483 KB, 850x1831)
483 KB
483 KB PNG
Hacky fix for step, but it werked
>>
File: carbon.png (830 KB, 938x4908)
830 KB
830 KB PNG
Unwashed
I tried washing my code so it actually uses Dijkstra's properly instead of this unholy mess of stopping and resuming Dijkstra states constantly (that I lifted directly from my quest 17 code) and somehow the washed code takes ~1.5x as long for some fucking reason.
I need to analyze this further but I can't really be bothered. It takes ~66 seconds.
>>
File: d19.png (1.49 MB, 801x1382)
1.49 MB
1.49 MB PNG
Happy Thanksgiving! I got filtered on past ones, but this one was fun. Did the hole size actually matter? It didn't seem to for my input at least.
>>
File: d19lolwut.png (2.19 MB, 1024x1536)
2.19 MB
2.19 MB PNG
Oh dang you all are calculating flaps eh? Well damn.
>>
File: quest19.png (111 KB, 1790x804)
111 KB
111 KB PNG
>>
>off by one hell
do i bother figuring out the issue or just trying adding/subtracting one from my answer over and over
>>
File: 1751016628983119.png (297 KB, 1666x1574)
297 KB
297 KB PNG
I was expecting edge cases where some walls would only just be passable depending on parity or something, and I was not dealing with that myself.
>>
>>107354627
try adding and subtracting. then go back and debug if you get nothing. it definitely helps knowing if it’s an overall off by one or a off by one that’s occurring every loop or whatever
>>
>you can just ignore everything in the input except the last two walls
holy kek
>>
>>107352850
Ya this input data seemed weird. I wonder how much is actually tested with the input data. The height of the hole didn’t matter for me either.
>>
>>107355141
>TIL: holes are like gears
I’ll have to test on my girlfriend [male].unwrap()
>>
>>107355119
reworked my shit and my part 2 was spot on but part 3 was one too low. oh well, not fixing it
>>
>>107355180
it's only true because of how restricted the movement is (y+/-1 for each x) but still kinda funny

guess there's no real need to make a big boy for today since even if you made the walls really far apart, it's still trivial to solve even just manually
>>
>>107355166
It's because he spaced the walls so far apart, it always makes sense just to stick with the lower one.
>>
Back home from Thanksgiving dinner.
Solved the puzzle in a dumb brute force way. Really didn't feel like doing the math on this one, or figuring out the rules to simplify the problem.
Reading the thread afterwards, it looks like there were several tricks to make it easier. I might've been overthinking the complexity.
My biggest optimization was looking ahead for the next wall and never dipping below its lowest hole's floor.
>>
>>107355206
That's just a quirk of the official input.
There's lots of ways to make dead ends, or windows that can only be reached at very few specific heights.
>>
File: 19.png (740 KB, 2906x3720)
740 KB
740 KB PNG
>>
File: ec2025-19a.png (186 KB, 654x1387)
186 KB
186 KB PNG
Washed
>>107352767
Yeah that was it
>>
File: 19.png (148 KB, 2636x712)
148 KB
148 KB PNG
>this works
bruh
>>
File: carbon.png (339 KB, 873x2002)
339 KB
339 KB PNG
>>107353070
Fixed this travesty. New algo is roughly linear complexity and finishes in a few ms.

Gonna move merge_ranges() and intersect_ranges() into my puzzle lib, because they're generally useful and I'm pretty sure I've had to use a version of these for AoC more than once.

I genuinely don't know why what I'm doing on line 92 works. I was planning on trying something else, and accidentally found that that works for some reason.
>>
Dead thread.
>>
File: ebcq2b.webm (1.24 MB, 598x518)
1.24 MB
1.24 MB WEBM
At least after calculating all the point locations, rendering it to the screen is fast.
Next have to make it so I can move the window around. This is just a 586x392 section.
>>
>>107316573
Is there a name for that mascot? I want to look it up on e6.
>>
>>107355141
What's the trick? Work backwards until you've filtered final gap positions down to one?
>>
>>107359060
see >>107356181
>>
>>107359093
jfc, is this deliberate "you're supposed to look at the input" or did not-Eric just give up by the end?
>>
>>107356181
how do you know you do this even if you look at the input?
>>
>>107359259
>you do this
you can* do this
>>
>>107359271
I don’t even see the input data anymore. All I see now is blonde, brunette, redhead.
>>
>only one puzzle left

Will day 18 be toppled or is it peak EC?
>>
>>107361074
It will be toppled. Next puzzle will make quest 18 look like Day 1 part 1 of AoC.
>>
>>107361074
Day 18 is just figuring out the trick by looking at the input.
15 and 17 are more interesting.
>>
Why is this thing called everybody codes when only 200 people in the entire fucking world can code them?
>>
File: lastday.png (3.16 MB, 1024x1536)
3.16 MB
3.16 MB PNG
Last day! Good luck!
>>
>>107361483
I don't need luck. I need Ducks! Three of them.
>>
>idiomatically solves the problem as stated in 50µs in your path

type Triple = (isize, isize, isize);

fn make_gap(line: &str) -> Triple {
let mut it = line.split(',').map(|s| s.parse::<isize>().unwrap());
(it.next().unwrap(), it.next().unwrap(), it.next().unwrap())
}

fn cast(cone: Triple, gap: Triple) -> Option<Triple> {
let dx = gap.0 - cone.0;
let xp = gap.0 & 1;
let raw_ymin = (cone.1 - dx).max(gap.1);
let raw_ymax = (cone.2 + dx).min(gap.1 + gap.2 - 1);
let new_ymin = raw_ymin + (raw_ymin & 1 != xp) as isize;
let new_ymax = raw_ymax - (raw_ymax & 1 != xp) as isize;
(new_ymin <= new_ymax).then_some((gap.0, new_ymin, new_ymax))
}

fn solve(filename: &str) {
let gaps: Vec<Triple> = std::fs::read_to_string(filename)
.unwrap()
.trim()
.lines()
.map(make_gap)
.collect();
let cones = gaps
.chunk_by(|a, b| a.0 == b.0)
.fold(vec![(0, 0, 0)], |acc, wall| wall.iter()
.flat_map(|&gap| acc.iter().filter_map(move |&cone| cast(cone, gap)))
.collect()
);
let x = cones[0].0;
let ymin = cones.into_iter().map(|cone| cone.1).min().unwrap();
let ans = (x + ymin) / 2;
println!("{ans}");
}
>>
>>107361074
Fridays have been noticeable filters and it's the last puzzle of the month. I'm expecting something brutal.
>>
Are you boys ready to spend the next 6 hours on an unnecessarily complicated puzzle that you accidentally solve with the wrong algorithm?
I know I am!
>>
>>107362847
Surely they wouldn't make the final day unnecessarily difficult.
No one does that.
>>
HERE WE GO
>>
>cheesed parts 1 and 2 without proper isometric coordinates

gridsisters........
>>
>>107364225
Same.
I got second place on the global leaderboard in part 1, even, but I don't wanna figure out hex coords...
>>
File: ec2025-20.png (313 KB, 622x2707)
313 KB
313 KB PNG
Unwashed
I half trial-and-errored my translation function, adding terms and constants until the output grid started looking correct
>>
click "check your progress" where the answer input usually is for the final story paragraph
>>
>>107364243
hyperneutrino?! show feet!
>>
File: EC-20.png (210 KB, 941x2125)
210 KB
210 KB PNG
Honesty kind of fun. I was expecting to be working at the last day for hours.
>>
ahh I'm miss counting even on part 1. shouldn't it be something like if x - 1 == "T": total += 1 and then for vertical neighbors isn't it just like evens columns have a neighbor below them and odd columns have above? my actual count seems much lower than the total. the real answer is 100 something and the result I'm getting is like 90. I was just doing a cols rows loop but maybe next I'll try some weird iso flood fill or something if I can figure that out
>>
Wow haha can't wait for tomorrow's
>>
>mess around with exotic coordinate systems for part 3
>give up and go to bed
>realise exactly how to solve it

Many such cases
>>
>>107365554
It's usually bed or toilet that make the solution become obvious.
>>
wtf I wasted more than an hour because I didn't realize you can stay in the same spot for part 3
>>
File: carbon.png (310 KB, 1262x2718)
310 KB
310 KB PNG
The rotation was so annoying to code I had to take a break and play a gacha game.
>>
File: carbon.png (344 KB, 704x2095)
344 KB
344 KB PNG
>>107364756
That's some tranny or whatever from another day.

What's funny is my code doesn't even work, it just coincidentally produced the correct answer because the false positives and false negatives exactly balanced out.
Also this was me >>107363725 which was oddly prophetic

I have AoC 2017 days 23, 24, and 25 to finish over the weekend to finally get up to 500 stars before this year starts.
See you lads on Monday!
>>
File: Day20.png (2.77 MB, 1024x1536)
2.77 MB
2.77 MB PNG
Thanks for a fun few threads boys! See you all in AOC!
>>
File: 20.png (876 KB, 2932x3336)
876 KB
876 KB PNG
>#TeamWater: +$1
I love niggers
>>
File: 1754536206218483.png (790 KB, 1054x2174)
790 KB
790 KB PNG
Probably my favorite puzzle this year. Took me longer than any other one, mostly because I was hell-bent on getting barycentric coordinates to work and fixing off-by-one errors was infuriating. At least the final result is quite nice.

Have fun with that $1, Africa.
>>
File: quest20.png (207 KB, 1891x1722)
207 KB
207 KB PNG
That was tricky. P1, P2 were easy enough to solve without any fancy coordinate mapping, but had to put P3 off until later. I have no idea how I came up with the idea of using a coordinate system that let me rotate 120 degrees by just rotating the list, so I'll credit whatever entity put that thought in my head. I guess it's scaled barycentric, I'll have to see if it's named. Hardest part was translating the input into the coordinates, some of you guys are very fast. See you all at AoC.

Those Africans had better say thank you.
>>
File: ebcq2bug.webm (858 KB, 600x518)
858 KB
858 KB WEBM
For some reason, particular window coordinates end up with portions blacked out.
I don't fucking know.
>>
>>107368699
Nice. Anything that would result in a divide by zero?
>>
File: ec2025-20a.png (261 KB, 580x2121)
261 KB
261 KB PNG
Washed
Pretty fun event
See you dragon duck space cowboys (in like 2 days for AoC)
>>
>>107369059
The number of points generated is correct, 60242 is the solution.
There's no division going on when working out whether to render a point within the window area. As far as I can tell, all the correct points are being selected and sent to the GS, but for some reason certain areas get blacked out.
>>
Fuck, just learned about this thing.
Next year, I guess...
>>
File: code.png (3.7 MB, 3675x4457)
3.7 MB
3.7 MB PNG
>>107368699
This shit is doing my head in. I don't get it.
>>
File: ebcq2c.webm (3.97 MB, 598x518)
3.97 MB
3.97 MB WEBM
I solved the problem.
Essentially I can only send about 0xFFFF quad words in one DMA request, so when there were too many points on the screen it would overflow and only send the overflow value.
So I made it send every 5000 pixels and that seems to be enough.
>>
File: rust supremacy.png (113 KB, 3760x800)
113 KB
113 KB PNG
gg no re
>>
>almost 24 hours spent coding my "clever workaround" to using cube coordinates
>doesn't work
>might conceptually not work at all
>>
yes sir
>>
>>107370152
>tags associated with you: Rust, unemployed
>>
File: giga_duck.png (302 KB, 604x606)
302 KB
302 KB PNG
>no cork screw dick
lame
>>
Do you guys use auto complete? For these things I just use VIM and turn it off, but I don't actually care about time score and its more fun. For actual work I tab complete every fucking word though.
>>
an Advent of Code thread has hit the catalog, sirs
>>107371611
>>
File: CPP wins again.png (16 KB, 498x208)
16 KB
16 KB PNG
>>107370152
I was out of town, but came back just in time to take the throne.
GG no re, CPP chads win again
>b-but you're third
Divide teams by number of people in the team.
>>
>>107375109
>no re

It's over gramps
>>
File: EC-Final.png (22 KB, 603x612)
22 KB
22 KB PNG
>24 hours since final puzzle dropped
Everyone else is now officially filtered.
>>
>>107375109
You may want to check that leaderboard again.
>>
>this part 3
I knew hardcoding it would come back to bite me.
>>
Is there any reason you can't solve part 3 by keeping the board stationary and rotating the player? My code isn't working, it hits a dead end on the example, but I can't tell if it's a bug or I'm missing something conceptually.
>>
>>107376363
IT'S FUCKING WORKING ONLY A DAY LATE LETSFUCKINGGOOOOOO
>>
>>107377044
Ah nice, congratulations. FILTERED.
>>107369979
Underrated, but that's to be expected on nu/g/.
>>
>>107377235
it's related to a puzzle from like two weeks ago posted with no context several threads after everyone posted their visualizations
>>
>>107375493
>Fucking Durgasoft wins again
JAAAAVVAAAAAAAAAAAAAAAAAAAAA!!!!!!!!!!!!
>>
>>107374534
/aocg/ proper has started. See you anons there.
>>107379367



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