[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 / qa] [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: file.png (719 KB, 860x430)
719 KB
719 KB PNG
sokoban edition

>Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as a speed contest, interview prep, company training, university coursework, practice problems, or to challenge each other.
https://adventofcode.com/

/g/ leaderboard join code:
796940-44255af5
anonymous-only leaderboard:
383378-dd1e2041

previous thread: >>103525934
>>
>>103533936
Did anyone solve Day 15 in a meme way, using say a video game engine?
>>
>>103533952
I don't know if this counts; but I solved it with regex.

Thought I was brilliant for part 1. Then got fucked badly by part 2. My only consolation is that my awk solution runs in <20ms.
>>
File: sad.png (64 KB, 720x901)
64 KB
64 KB PNG
>>103533979
how'd you solve part2 with regex
>>
list_of_boxes = empty set
function find all boxes and return if they are movable(x, y)
if (x,y) + direction is box add box to list if it is not their yet, return this function with new x, y AND this function with x,y for other part of the box
if (x,y) + direction is wall return false
if (x,y) + direction is empty return true

if it returned true paint empty on every box location you saved, then paint box on every box location you saved + direction
>>
Every day djikstra doesnt show up, I get more worried. I don't want to have to make a heuristic function and prune the results.... Ill be filtered.... I don't know how...
>>
File: 1734315987977057.png (91 KB, 575x1043)
91 KB
91 KB PNG
>t. pytoddler
>>
File: 1731513957812219.png (3 KB, 77x249)
3 KB
3 KB PNG
Today's the day
>>
File: bqn.png (33 KB, 818x979)
33 KB
33 KB PNG
>>103534017
just propagate force in a hypothetical that's committed if a block doesn't try to pass through a wall. Then your logic is simply a loop that propagates force while anything's still in motion.
You only need to solve for one direction because you can rotate the grid (square by the blank lines) to face that direction for the update. You don't need to check edge cases or care what anything else is doing, just atomically propagate the bot's shove. The entire logic of what's happening is visible in the grid.
>>
File: file.png (501 KB, 1486x949)
501 KB
501 KB PNG
>>103533952
>video game engine
I was tempted to boot up the map in the game engine I'm building, but it would just be another excuse to procrastinate actually working on my game...
>>
>>103534149
to be fair, if your game engine cant handle a few hundred boxes being pushed around, or if the simulation takes any real time to create, its a piece of trash. This is basically the intended use case.
>>
>>103534137
your boxes appear to be broken in pane 5 anon
>>
File: 1733887359530571.png (629 KB, 822x744)
629 KB
629 KB PNG
>>103534015
BEGIN { FS = "" }

/[#.O@]/ {
a["r",NR-1] = $0
for(i=1;i<=NF;i++) {
a["c",i-1] = a["c",i-1] $i
if($i~/@/) { x = i-1; y = NR-1 }
}
}


When dealing with a row I just did the regex substitutions on the row strings and propagated the changes to the column strings, and give versa.

It was a nightmare, but I did do it.
>>
>>103534202
the grid hasn't settled at that point, so it doesn't matter. The grid only needs to be consistent when the bot moves. The order of updates also doesn't matter: motion can flare out but the lines of movement never intersect. All you do is create movement on the other side of a box, and you know where to place it because the boxes are made of paired symbols.
the force is also paired so that it can resolve into the correct half of the box when it moves into an empty spot.
>>
>>103534226
boxes
broken
>>
just woke up
I'm sleepy
I hope this doesn't affect my ability to code
>>
File: file.png (1.58 MB, 1488x950)
1.58 MB
1.58 MB PNG
>>103534193
No doubt it could, but competitive coding is very far from the intended use of a game engine.
>>
>>103534250
you're reacting the wrong way to an opportunity for shared-memory parallelism
>>
File: panic.png (174 KB, 786x306)
174 KB
174 KB PNG
>>103533895
Okay, i made some bugs when widening the positions. it's fixed now, but the result still doesn't match the example.

yup, i'm thinking it's time to panic.
>>
>>103534265
sokabon is a game. It is a very simple game. It requires many different objects and basic collision. If your game engine can't build it, it is a poor game engine.
>>
File: file.png (47 KB, 506x582)
47 KB
47 KB PNG
>the artwork reveals the true number of genders
>(btw it's in binary)
what did Eric mean by this?
>>
WHERE IS EVERYBODY
>>
>>103534340
um, yikes? you have been banned from /r/adventofcode for this joke
>>
>>103534340
that's binary, obviously, but it's a weird thing to focus on for the tenth anniversary of AoC
>>
I just realized that there must be many people who, while not cheating outright by feeding the problem text into Claude, are still using Copilot completion
Programming really is doomed
>>
>>103534348
everyone gave up after the impossible task of finding a christmas tree
>>
>>103534356
programming's not dead it's just been exposed as a shit-tier discipline that a literal autofill bot can do
>>
>>103534348
im tired boss
>>
what the hell? it really is dead in here
>>
5 minutes left and there's only about 5 people here.
>>
File: fuckeric.png (118 KB, 804x804)
118 KB
118 KB PNG
incoming
>>
FUCKKKKKKK I HAVE TO TAKE A SHIIIIIITTTT AAAAAAAA
>>
File: showtime.jpg (46 KB, 640x480)
46 KB
46 KB JPG
https://www.youtube.com/watch?v=hjGZLnja1o8

Stop doomposting. It's Showtime.
>>
>>103534384
cancer music
>>
what happened to the other 200,000?
>>
>>103534384
kino music
>>
>>103534375
I'm here too! (the xarbon guy)
>>
>>103534384
SHOWTIME
>>
File: file.png (93 KB, 326x268)
93 KB
93 KB PNG
>>103534348
everybodys dead dave
>>
LETS FUCKING GO NIGGERS
>>
k>>103534299
>almost an hour spent trying to multiply by two
software engineering is a joke
>>103534374
i like to read the puzzle before i go to bed so i can dream the solution and thus save waking hours
>>
File: showtime-frog.png (468 KB, 1858x1829)
468 KB
468 KB PNG
>>103534384
we rollin
>>
its time for an easy puzzle
>>
Fuck I'm almost late! Didn't even eat dinner
>>
File: mokou-showtime.jpg (130 KB, 440x518)
130 KB
130 KB JPG
>>
my hands are washed, I am ready
>>
another easy day today
>>
>>103534408
just like the last fifteen days?
>>
>>103534384
aahhhhhhhhhhhhhhhh
>>
cellular automata today
>>
File: aoc_2024_15.png (259 KB, 928x3192)
259 KB
259 KB PNG
Perl. Barely made it.
>>
>>103534395
They went back to being a web "dev" or hacking together the odd "script" for their IT job.
>>
F U C K
U
C
K
>>
12 cores ready to broot
>>
I'm tired and ready
>>
advent of parsing
>>
brooters. there isnt many of us left. WE RISE TODAY
>>
FUCK
>>
FUCK
>>
FUCK
>>
back to bed
>>
advent of grids
>>
FINALLY
>>
A* slop?
>>
looks easy, but too much work for Monday morning. how's part 2?
>>
>>103534448
there isnt many of ANYONE left bro
i'm bored i'll come back on the last 3 days
>>
Can I get a QRD on the programming concepts needed to beat this so that I can look into that instead of actually doing the puzzles?
>>
rotation is annoying, you either need to double up on score grids, or maybe you can get away with moving the rotation score off to the next tile? shouldn't effect the E score
>>
>>103534589
pathfinding, djikstra, cache information about the path in the path
>>
>>103534589
B R O O T
R
O
O
T
>>
I'M BROOTING SO HARD RIGHT NOW, I'M BROOTING WITH ALL MY BEING
>>
Currently running my broot solution while implementing Djikstra, whichever finishes first I guess.
>>
File: carbon.png (540 KB, 1648x3352)
540 KB
540 KB PNG
My first ever sub 500 ranking! Can't believe I did this well this late into AoC
>>
>both examples work, real doesn’t
edgecase bros?
>>
>correct solution for input
>wrong solution for examples
wtf?
>>
>>103534669
>>103534684
An issue I had was only using (x, y) for my visited set instead of (x, y, dir)
>>
File: wtf-is-this.jpg (383 KB, 638x720)
383 KB
383 KB JPG
>works on both the examples
>try on input
>"that's not the right answer"
>>
DONE
my part 2 is pretty bad
is there a smart way to do it?
>>
>getting 8036 not 7036
fugg
>>
>>103534634
LMAO broot worked, currently brooting part 2. Brootbros, we are so back.
>>
>>103534716
same. but then I changed the "." to "#" to see where the correct path failed and I get 7036
>>
brutebros...
>>
broot started. god help us all.
>>
File: carbon.png (368 KB, 1386x1900)
368 KB
368 KB PNG
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
16 00:28:57 2009 0 00:32:35 784 0

Once again I mistyped all variables in my dijsktra... I also thought you can start in any direction and also that you can rotate and walk in the same turn.
After all that I couldn't believe how easy part 2 was, had to reread it again.
>>
>9 minutes in I'm passing both examples
>43 minutes in I'm still trying to figure out why shit doesn't work for the real input
fuck you eric
>>
>>103534712
Welcome to my life.
I then realized that it might be adventageous to turn 180 (because you start facing East) and got a lower, but still wrong, result on my input while the examples still work.
>>
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
16 00:25:39 1769 0 00:47:05 1310 0

BROOT STRONG
I couldn't even get halfway through implementing Djikstra...
>>
File: file.png (541 KB, 1664x2572)
541 KB
541 KB PNG
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
16 00:15:04 848 0 00:47:25 1321 0

finally
i had to rewrite part 2 three times because my first two algorithms were dogshit then realized theres actually a pretty simple way to do it
>>
>get 11036 instead of 7036
>>
File: UNWASHED ASS.png (429 KB, 909x3258)
429 KB
429 KB PNG
>>103534772
UNWASHED ASS, I lost at least a couple minutes on part 2 because I ran part 1 with it.
>>
Was the thread always this dead on later days
>>
File: carbon.png (69 KB, 809x723)
69 KB
69 KB PNG
Spent way too long debugging my shit code for part 2 before giving up and import solution
Should have done this from the beginning
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
16 00:18:06 1130 0 00:49:03 1381 0
>>
>>103534809
>networkx AND numpy
yeah, doesn't count, doubly
>>
>>103534805
i don't know, feels more dead than usual...
>>
>>103534777
>print out path
>path is correct
>>
>>103534841
there's less people doing it on the first hour or two I've noticed, but later on it stays as it was last year iirc
>>
can I not use a* on this one? I'm not sure if I coded it wrong or if its just not viable :/
>>
>>103534777
if you are getting more 1000s but the small unit is fine, it's probably on your rotation score calculation.
>>
>>103534777
>>103534873
>I'm standing on the spot spinning
>>
>7036
>I get 7029
>Path is correct
>Weights are correct
FUCK
>>
>>103534805
yes, starts getting kind of depressing the further the month goes. though to be fair, a lot of people are probably still doing the problem right now
>>
>>103534841
because the problems are boring?
you can solve almost all of them without any help
>>
>>103534911
dijstra does the work just fine (unless you really really want to do the extra steps for a*)
>>
>>103534921
if you're combining turn and move, make sure your score is +1001
>>
>>103534931
That was it, thank you, anon
>>
>>103534926
they seem pretty normal to me, compared with other years
>>
>>103534834
>t. slow pleb
>>
File: day16clojure.png (1.19 MB, 992x1095)
1.19 MB
1.19 MB PNG
I love clojure, even when my code looks bad
>>
my p1 has been running for quite a while now....
>>
Uhh, how do I make it work faster? It takes almost 7 seconds (search function is the first part, it works instantly).
const searchAllPaths = (map, x, y) => {
const minPathCells = new Set();
const minScore = search(map, x, y);
const minScoreTo = Array.from({ length: map.length }, () =>
Array.from({ length: map[0].length }, () =>
Array.from({ length: 4 }, () => Infinity),
),
);
let searchList = [{ x, y, score: 0, direction: 0, visited: [] }];
while (searchList.length) {
const newSearchList = [];
for (const { x, y, score, direction, visited } of searchList) {
if (minScore < score) {
continue;
}
if (minScoreTo[y][x][direction] < score) {
continue;
}
if (map[y][x] === "#") {
continue;
}
minScoreTo[y][x][direction] = score;
if (map[y][x] === "E") {
if (score === minScore) {
for (const cell of visited) {
minPathCells.add(cell);
}
}
minPathCells.add(`${x},${y}`);
continue;
}
newSearchList.push({
x: x + directions[direction].x,
y: y + directions[direction].y,
score: score + 1,
direction,
visited: visited.concat([`${x},${y}`]),
});
newSearchList.push({
x,
y,
score: score + 1000,
direction: (direction + 1) % 4,
visited,
});
newSearchList.push({
x,
y,
score: score + 1000,
direction: (direction + 3) % 4,
visited,
});
}
searchList = newSearchList;
}
return minPathCells.size;
};
>>
>tests work
>input doesnt
great.
>>
>>103534963
optimization: don’t let it visit the same (node,direction) pair twice
>>
>>103534971
I don't let it visit the same node. I don't see why direction would matter, a shortest path should never cross the same path twice
>>
File: xarbon.png (28 KB, 516x1220)
28 KB
28 KB PNG
horrible day for me sadly :(
here's the unwashed
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
16 00:19:01 1202 0 01:18:54 2310 0
>>
I brute forced it. Now I'm going to solve it properly. I think it's Dijkstra's Algorithm right? I remember a similar path/cost problem from last year...
>>
>>103534980
You may visit the same node in the same direction with a lower score than before.
>>
>>103534809
filtered
>>
>>103534980
o ya sorry, it depends on how you represent the state. in mine I counted turning 90deg as a single move rather yhan combining turns with forward moves
>>
>>103534996
not if you put em on a heap
>>
>debug code for an hour
> i had (-1,0) repeated twice in my shitty rotation function
hahahahahahHAHAHAHAHAHAAH
>>
Who is #208834?
>>
File: carbon.png (253 KB, 765x1683)
253 KB
253 KB PNG
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
16 00:20:34 1326 0 00:46:07 1264 0

This is as much as I'm washing my ass.
Probably wasted some time in part 1 stubbornly trying to use the generic Djikstra in my AoC lib unmodified instead of copy/pasting, had to write code to re-calculate the path's cost after it shit out a solution.
>>
what is the edge case in the input.
>>
>>103535045
is this a new aoc meme? haven't seen frequently last year
>>
>>103535056
It's a lot of grid problems which seem to come with edge cases. It's a bold strategy by Eric.
>>
Oh shit, I just realized that my solution is basically dijkstra.
>>
>>103534996
I didn't check for this before so I added a early terminate if the score has been lower at that spot before and its still running forever... doing something poorly I guess
>>
>>103535056
there is a edge case in the input that im not catching in any tests.
>>
>>103535060
nice meme >>>/reddit/
>>
>dijkstras
>a*
lemao @ any retard who implemented this nonsense
>>
File: chigur mtndew.jpg (180 KB, 677x678)
180 KB
180 KB JPG
>>103535074
What meme? Are you okay anon?
>>
>Task 2
>example works, input doesn't
>>
>>103535045
You can move west from the Start position, so being able to rotate 180 degrees is required.
>>
>>103535078
five lines
joken on you who cannot type five (5) lines
>>
>>103535087
i didnt need to
>>
>>103534750
holy shit I'm retarded
> facing East
I mixed up my left and right and initialized him pointing West. It passed the test inputs because in the examples you immediately have to turn North -- which takes 1 turn.

I missed out on a top 50 score for this. LOL
>>
>>103535086
No i cant, plus that is accounted for in my code
>>
>>103535083
you might not be added the start to your list of visited states
>>
>>103535098
It's too high actually.
>>
>>103535086
shit I just realized I only counted that as 1000, not 2000
>>
>>103535086
WAIT IS EAST TO THE LEFT????? ERIC YOU NIGGER
>>
>>103535107
no?
>>
>>103535093
You also don't need to be here, you can choose otherwise.
It's a programming contest.
>>
>>103535108
well I start in the bottom left corner with the option to go east or north, not west.
>>
>>103535113
using a jackhammer to hammer a nail just makes you look stupid
>>
>>103535122
are you talking about yourself fucking retard? using a 6 gorillion lines of code library to find the shortest path in a graph with positive weights?
>>
>>103535128
a simple bfs with priority queue does the job just fine
>>
>>103535129
>bfs with priority queue
so not a bfs
>>
>>103535129
that's called dijkstra kek
you also have to maintain a dist array if you want to recover the nodes in the best paths.
>>
>>103535134
Here we go again... This same convo happens every year.
>>
>broot for 15 minutes
>stack overflow
fuck, guess I'd better do it properly
>>
>>103535134
yes it is, the priority queue is only needed due to the them not being equidistance
>>
>>103535144
>Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies a given property. It starts at the tree root and explores all nodes at the present depth prior to moving on to the nodes at the next depth level.
>moving on to the nodes at the next depth level
>>
File: file.png (407 KB, 794x4028)
407 KB
407 KB PNG
C

part 2 took me a while as I 'cheated' a little with my pathfinding algo on part 1 and had to redo it in order to properly reverse it for the tile counter

      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
16 00:42:19 2901 0 01:38:58 2881 0
>>
>>103535144
anon, you don't even know what dijktra's algo is
>>
>>103535150
yes and it works exactly that way when all nodes are equidistance. due to the scoring here the next depth could be from 1 to 1000 which is why you use a priority queue, its not a simple matter of the number of nodes in the path
>>
>>103535152
and i'll never need to
>>
>>103535170
you fucking retarded nigger if you mention it you DO need to know what you're talking about
because what you described is exactly what dijktra is
>>
>>103535159
>if you don't visit the nodes in breadth first order it is a breadth first search
>>
>>103535172
its a bfs
>>103535173
they are in breadth first order where the breadth is how far away from the start it is
>>
>>103535176
I modified my DFS to use a queue instead of a stack, now my DFS visits nodes in breadth first order.
>>
>>103535176
>>>/b/
trolling is disallowed outside
I bet you're the countdown samefag
>>
LOL I was facing the wrong way.
Fuck me.
>>
>>103535185
>>103535186
you have no understanding of algorithms whatsoever
>>
>>103535186
Why is this such a big argument every year.
>>
im filtered today sorry guys no cute touhou js code
maybe after a coffee i can finish part 2
>>
>>103535191
a bfs is with queues, not heaps, if you continue the trolling next time I might report you
>>
smallboy
https://pastebin.com/raw/9eLRdDC9
>>
>>103535197
a heap is just a priority queue
im not trolling you just have no idea what youre talking about
>>
Is this a dynamic programming problem in Part 2? I currently have a backtracking with pruning approach, but at 5 seconds for the second example I think it is not going to finish for my real input.
>>
>>103535210
>if I take a BFS and modify so that it visits in a different order, it's sill a BFS
>>
File: xBI6Mvz.png (407 KB, 792x860)
407 KB
407 KB PNG
Can anyone see what I'm doing wrong here? I just don't see it.
from heapq import heappush, heappop

matrix = [list(x) for x in data.strip().splitlines()]
walls = set()
start, goal = tuple(), tuple()

# parse
for y in range(len(matrix)):
for x in range(len(matrix[0])):
if matrix[y][x] == "#":
walls.add((y,x))
elif matrix[y][x] == "S":
start = (y,x)
elif matrix[y][x] == "E":
goal = (y,x)

# distra minheap
# score, position, last direction
minheap = [(0, start, (0,1))]
visited = set()

while minheap:
score, pos, ldir = heappop(minheap)
y, x = pos

if pos == goal:
silver = score - 1
break
if pos in visited:
continue

visited.add(pos)

for dy, dx in ((0,1), (1,0), (0,-1), (-1,0)):
ny, nx = y + dy, x + dx

if (ny, nx) in walls or (ny, nx) in visited:
continue

# increase cost if turning
cost = 1 if (dy, dx) == ldir else 1001
heappush(minheap, (score + cost, (ny, nx), (dy, dx)))

print(silver)
>>
>>103535210
I know that retard
What you claimed is that anyone who implemented disktra is an idiot, yet you did implement dijktra
End of argument, period.
>>103535221
Bellman-Ford, but that's an overkill if there are no negative cycles
>>
>>103535226
Please see >>103535193
And >>103535138
>>
>>103535221
you're supposed to use your forward algo in reverse for part 2. if you did it properly then the only path that works in reverse are the ones that lead back to the start
>>
>>103535235
>please see this AI generated text
it's nonsense
>>
>>103535229
You can visit a pos with a lower score.
>>
>>103535226
its not visiting in a different order, its exactly the same as a regular bfs
with a uniform graph the bfs is already prioritized by the distance implicitly as the number of nodes equivalent to the distance
the only difference here is that the distance and number of nodes are separate so you have to store the distance separately
>>
>>103535243
Ah, you are very much clueless
>>
>>103535237
I'm just keeping a history of my paths, so wheb they get to the end the ones with the same score can be merged into the result.
>>
>>103535262
more like dijkstras is a special case BFS
>>
>>103535272
You say Tomato, I say Tomato.
>>
>>103535266
that's retarded and inefficient, wouldn't work with large graphs
>>
>>103535272
Dijkstra is the more generic and abstract one though because it works on ALL graphs, not just unweighted ones...
>>
>>103535262
try reading your own image. It says that if you use dijkstra's algrithm on an unweighted graph, or a graph where every edge has the same cost is the same as doing BFS, because if all edges have the same cost, the lowest cost path is the shortest path.
>>
>>103535281
Good thing this isn't a large graph then
>>
>>103535282
bfs works on them too if you engage your noggin and do a bit of critical thinking
>>
>>103535255
>its not visiting in a different order
so what does you priority queue do?

>>103535289
no, bfs finds the path with the fewest edges
>>
File: 1703362663896484.jpg (47 KB, 720x480)
47 KB
47 KB JPG
>>103535289
>bfs works too if you actually use dijkstra's algorithm and call it bfs
>>
>>103535266
if you do that then you have to find all paths though, much worse then just scoring all nodes and doing a traceback
>>
suck my Dickstra
>>
>>103535286
So you admit it is a BFS? Got it.
>>
>>103535294
>so what does you priority queue do?
order them by their distance, exactly the same as putting them in a queue does with a uniform graph naive bfs
>>
>>103535308
>order them by their distance
so it's not a BFS anymore
>>
>>103535322
on the contrary, thats exactly what a bfs does
>>
File: image.png (792 KB, 1389x840)
792 KB
792 KB PNG
my humble BQN solution for day 16.

not a good day. lost a bunch of time because i wrote the solution as DFS first but it was overflowing the stack on input (CBQN has a hilariously small stack size). had to rewrite everything to BFS.

also, the way i'm tracking path is very inefficient and slows down part 2 to a crawl.

>>103535296
you don't need dijkstra, just regular BFS works if you're willing to wait a bit.
>>
>>103535254
ahh cool thank you!!
>>
>>103535281
>>103535297
Blah blah, it works and gets stars.
>>
>>103535203
somebody try this and tell me your times and scores
>>
>always gives you the shortest path, guaranteed
>quick and easy to implement
>solves any graphing problem, weighted or unweighted
there is truly nothing BFS can't do
thank you, BFS
>>
>Anyone who eats red apple is retarded
>so what do you eat?
>apple
>oh and what color is that apple?
>red
unironically hang yourself
>>
>>103535369
3478
32235
44 seconds
>>
>>103535422
based, what approach are you using that it actually completes in that timeframe
>>
>>103535428
bfs
>>
>>103535428
dijkstra
>>
>maximum recursion depth exceeded
>>
Brootchads, my Part 2 doesn't feel so good.... it's been running for 20 minutes.
>>
>>103534356
I used it for a while and it just gets in the way and is so annoying and slow
>>
>>103535203
>>103535428
>>103534992
>>103535422
$ ./main < smallboy.txt 
+ ulimit -s unlimited
+ pypy main.py
+ tee /dev/fd/63
++ tail -n 1
++ xclip -sel clip
32235

real 0m5,436s
user 0m5,401s
sys 0m0,036s
>>
File: carbon(15).png (1.67 MB, 2038x2992)
1.67 MB
1.67 MB PNG
Vomit-inducing Haskell solution.
I really wanted to implement dijkstra from memory and here is the result. Ugly parsing, two almost identical copies of the algorithm, and worst of all I sort the nodes each time instead of using a proper queue.
I guess I will spend some time cleaning it up after work.
>>
File: file.png (282 KB, 757x2439)
282 KB
282 KB PNG
Washed ass. I don't know why the "alt <= dist[neighbor]" bit works but it does.
>>
>>103535428
dijkstra (not bfs)
>>
File: IMG_1463.png (292 KB, 813x850)
292 KB
292 KB PNG
>>103535086
>is required
not on my input.txt it ain’t
>>
>>103535390
Anon we have this exact same argument every year
>haha why do you retarded niggers think you need Dijkstra, a modified BFS works just fine
>>how did you modify it?
>well I just used a priority queue and... [insert the exact steps required to convert a BFS to Dijkstra]

>>103535203
using >>103535019
Measure-Command { python d16.py R:/9eLRdDC9.txt | Write-Host}
part1: 3478
part2: 32235
[...]
TotalMilliseconds : 978.1628
>>
Fellas... I might be filtered. My solution for part 2 is still running, and I don't know when it will stop.
>>
>>103535505
its not dijkstras though
>>
what is part 2 asking? i’m actually retarded. why is the example paths have multiple branches
>>
>>103535534
multiple paths can have the same cost
>>
>run dijkstra on second example in input
>returns wrong answer
???
>>
>>103535545
ahh got it thanks
>>
File: carbon(60).png (595 KB, 1724x2770)
595 KB
595 KB PNG
Half an hour for part one and two hours fighting python reference copying (fuck you python, I wasted so much time even though the algorithm basically worked).
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
16 00:27:03 1880 0 02:17:01 3700 0
>>
>>103535534
So you know how you calculated the lowest cost in part 1, right?
Turns out there are multiple paths with that same cost.
Find all of them, count the number of tiles they cover (do not recount the same tile), that's your answer.
>>
File: shoot_2024-12-16_02:38:22.png (717 KB, 1799x3923)
717 KB
717 KB PNG
>Just got part 2
>2 days in a row where I immediately knew exactly how I wanted to implement the problem, and proceed to spend 2 hours fucking up the implementation with retarded codemonkey errors that I have no excuse for making
I blame only getting 4 hours of sleep.

It took me over an hour for part one. Couldn't get the real input to work. Out of frustration I deleted my input file and redownloaded it and it worked. still not sure what I did to fuck it up.

Anyway, for part 2 I just stapled on a big list of visited positions as part of the state. Not sure if this is the correct way to do it.

I spend another hour because I accidentally did
newlist = list.append(x)
instead of
newlist = list + [x]
I keep doing this over and over and over. I spent 15 minutes on this exact bug on day 7 with the recursive operations. I will never learn.

For some reason my djikstra is unreasonably slow and takes several minutes on the input. There isn't that many states so i'm not sure why this would be the case. I must have fucked it up somewhere. I'm not going to find out what I did wrong and I'm not washing my ass.
>>
>>103535569
is reading from stdin cheating?
>>
>>103535569
>I immediately knew exactly how I wanted to implement the problem, and proceed to spend 2 hours fucking up the implementation with retarded codemonkey errors
Welcome to challenge programming, enjoy your stay
>>
>>103535576
I just realised you think *I* am that retard. I'm not him he just uses the same screenshot tool as me.
>>
>>103535584
oh my god, he's posting from the same computer! get out now anon, GET OUT NOW!
>>
>>103535591
>he is posting from stdinside the house
>>
>>103535584
oh okay sorry then
I think you should use a heapq data structure which has O(logn) push and pop and you shouldn't store the entire path in each element
>>
>>103535569
> I accidentally did
>newlist = list.append(x)
I did this today too lol. Cost me quite some time but the error message
>you can’t do list operations on a None type, retard
was at least helpful
>>
>>103535591
is reading from stdin cheating?
what's the current status?
>>
File: marty.jpg (35 KB, 500x375)
35 KB
35 KB JPG
I have two different implementations racing each other for part 2 and neither has finished yet.
It's so over.
>>
>>103535602
>I think you should use a heapq data structure which has O(logn) push and pop
noted. I always forget to use proper collection types
>and you shouldn't store the entire path in each element
I agree, but it was the simplest way I could think of to solve the problem, and I'm tired.
>>
File: chuckle.gif (3.67 MB, 500x282)
3.67 MB
3.67 MB GIF
>>103535599
>>
I solved part 2 by hand
>>
I hate how python does sorting now

I remember you used to be able to sort by a comparison function. How can I just do that?

>ummm sweaty sorting with key= lambda function is the same thing
Well even if it is, I can never get it to work how I want, and I liked the other way better, let me do it that way
>>
>>103535633
I was getting really close to doing this. the maze isn't very big It wouldn't even be that bad.
>>
>>103535646
from functools import cmp_to_key
>>
>>103535664
THANK YOU!
being able to give keys to functions seems very powerful, but I just cant get the hang of it for some reason. like today I learned you can give keys to stuff like min().
But for some reason I have trouble constructing more complex keys, when I have no problem constructing complex cmp functions.
>>
File: 1706007222206944.png (751 KB, 862x1375)
751 KB
751 KB PNG
>another grid problem
>>
>>103535655
How would you do that if you don't even know what to do?
And if you do know, why not just describe the steps and let the computer do it for you?
>>
File: drink.jpg (15 KB, 480x360)
15 KB
15 KB JPG
Okay, I got my second star, but it was really retarded. I hardcoded the answer from Part 1 into my Djikstra, and added the current path up the that state for every item in the priority queue. If I reached the end cell and my score was equal to the known best score, I added everything in the path to a set of indices.

Now time to read the thread and figure out how to get it to finish in less than 5 minutes and not need a hardcoded number to figure out.
>>
I'm getting kind of sick of all the grid problems
>>
File: IMG_4045.png (571 KB, 858x617)
571 KB
571 KB PNG
>>103535685
based and cmp pilled. python hasn’t had cmp for over 15 years.
https://bugs.python.org/issue1771
>>
>>103535697
if you’ve already solved part 1, then you know exactly how many turns and forward movements are allowed (it’s less than 1000)
>>
Lol, I had to wait an hour to submit my part 2 result because my laptop battery ran out and I still got a lower rank than I had for part 1.
How are people solving part 1 without instantly getting part 2?
>>
>>103535705
>python hasn’t had cmp for over 15 years.
I refuse to believe this. what about in python 2. I would begrudgingly believe 10 years. But I wasn't even programming 15 years ago.
>>
Thought part 2 would be as easy as tracing the Dijkstra distances backwards wherever the difference was either 1 or 1001, but obviously that doesn't work. I'm guessing it's due to the cost of the turn getting incorrectly rolled into the distance. Turning the maze into a graph of intersections (like that one problem last year) probably solves that but I've already spent too much time on this shit tonight, so I'll either deal with it tomorrow or get filtered again.
>tfw can't get away with doing AoC at work this week
>>
File: carbon (8).png (372 KB, 1818x1656)
372 KB
372 KB PNG
>>
>>103535737
don't feel bad anon. There are people who still use OpenGL 1.x
>>
File: 8zmiqb2e7muc1.png (973 KB, 1271x1280)
973 KB
973 KB PNG
>>103535824
I'm just not going to update from things that work is all.
>>
File: d16.png (625 KB, 1506x4142)
625 KB
625 KB PNG
It takes a long time to run, but stars don't care.
>>
>works for examples but doesn't work for input
It's over
>>
>>103535086
>I only added 1000 if any turn is made
>including 180 degree turns
>it still worked
>I still got a top 1000 rank
I'm a fraud
>>
File: image.png (747 KB, 1281x811)
747 KB
747 KB PNG
my humble BQN solution for day 15.

complete spaghetti. i wanted to clean it up a bit, but i myself have no clue what's going on anymore.
>>
>>103535726
my part 1 made a bunch of assumptions that we were only looking for 1 path. It tooka while to track them down and undo them. Also, modifying to keep track of the list of nodes can be tricky depending on what language you were using
>>
>>103535705
python2 is still widely used
>>
>>103535853
Are you facing the right direction?
>>
>>103533952
No but I had a grid based terminal game, so modifying it to take input commands from a string and writing a box pushing function took about 2 minutes for part 1. I'm going to look at part 2 in a bit after I've woken up properly since I didn't have time to do it yesterday.
>>
File: unpure.png (609 KB, 1600x948)
609 KB
609 KB PNG
>i had to pass the cost (the thing i'm optimising) as a function argument, instead of letting it return
>this means my function state contains redundant information
i feel unpure, not very demure
>>
>>103535926
Why can't you return it?
>>
>>103535934
because i want each instance to know the cost of the best path it is in, and not just the additional cost from the current position
normally i would do this:
minimum = min(minimum, dfs(r, c) + 1)

but it doesn't give enough information; each instance doesn't know the cost to reach itself
>>
My solution takes a full minute to run and I'm not going to optimize it.
>>
wait where's the anon who leaked that it was Dijkstra day?
>>
>>103535966
>leaked
>>
>>103535966
dijkstra's? this is today is nobrain dfs day
>>
>>103535970
no I'm sure someone said that before the problem opened
>>
>>103535965
based

>>103535966
>Dijkstra
happens every year just like cellular automata, maze solving, etc
>>
>>103535957
I gave up on dfs because I had stack overflow. Not sure if it was a bug or a real issue though.
>>
File: img-2024-12-16-09-54-00.png (1.24 MB, 5546x3842)
1.24 MB
1.24 MB PNG
idiomatic Rust solution
>>
>day 16, solved 16 puzzles
>only 7 gold stars, a tiny gold star, and a yellow colon on my calendar
ERIC!
>>
>>103535966
Anon says that it will be Dijkstra every day.
>>
>>103535997
import sys
sys.setrecursionlimit(int(1e9))

you wouldn't get it; you're not a real brooter
>>
>>103536004
I am using node and I have no idea how to set recursion limit there.
>>
>>103535965
Mine takes 5 full minutes and only words for my specific input.
>>
>>103536010
a man is only as good as his tools
>>
I'm kinda late, you guys solved all the problems?
>>
>19s to solve both parts
yeah I think the bigboy will kill me
>>
>>103536023
yes
>>
>>103536023
I have. Some of my solutions are real pieces of shit, but I have my 32 stars.
>>
>>103536026
>>103536034
I should start too, I'm retarded, wish me luck.
>>
bros, my bruteforce has been running for 2 hours now, I don't feel so good..
>>
File: AoC++.png (20 KB, 354x468)
20 KB
20 KB PNG
>>103536034
>she doesn't have all 48 stars so far
filtered
>>
>>103536049
it must be cycling; you did account for cycles, right anon?
>>
got p1 after realizing my solution was shit and was never gonna work and actually implementing djikstras. I'll do p2 in the morning
>>
>>103536052
Oh shit I forgot to buy the AoC++ bonus puzzles this year.
>>
>>103533936
i hecking love recycled problems from 2021
>>
https://files.catbox.moe/l64q3v.txt
1000x1000
Part 1: 800196
Gold: 2367
>>
>>103536112
983ms with my idiomatic Rust solution >>103535998
>>
>>103536112
Hell no. Not today. My solution is trash and I am not touching it further. I am bigboy filtered today.
>>
File: wat.jpg (63 KB, 703x469)
63 KB
63 KB JPG
>p2 answer too low
huh? already tried +1 and +2 so it's not an off by one issue. how am I missing entire sets of answers?
>>
File: file.png (90 KB, 1316x659)
90 KB
90 KB PNG
>>103536052
get on my level scrub
>>
>>103536155
>of *any* best path
>>
I can find the optimal path just fine, but finding ALL of them is killing me unless I'm missing something. I find the optimal path in less than a second, but I am currently bruteforcing the finding of other paths and I don't know how to not do it like that
>>
>>103536155
try +3
>>
>>103536166
yeah, I just did a stupid solution and stored a copy of each path then went back after and counted unique points between them all. somehow this is too low? my input had 10 best paths and I am sure that my unique check is correct
>>103536171
no unfortunately
>>
>>103536170
Recall that Dijkstra's algorithm doesn't juat find the distance between two nodes. It finds the distance between the first node and every other node.
>>
>>103536182
ok preemptive guess - I'm doing a sort of brute forcish solution that has some things in common with dijkstras but it has no queue. my assumption is that if I reach a point with a score, any other point that reaches it with a higher score cannot be the answer, but that might not be true? I'm trying to come up with an example of this in my head while I let it brute with a less efficient path length check for a few minutes
>>
so, what is the "smart" way to do part 2? do you have to find the optimal path first before you can solve it, or is there some way to do it all in one go?
>>
>>103535912
I am. I updated to start facing north instead and now I got an answer that is too low.
The other with the correct facing directing is too high. The difference between then is 1000.
>>
>>103536249
Dijkstra algorithm
>>
File: day16.png (193 KB, 934x1528)
193 KB
193 KB PNG
>>103536112
1.6 seconds.
still not optimized, but not sure if a* would even be a big speedup. anyone tried?
>>
File: carbon.png (275 KB, 1708x1358)
275 KB
275 KB PNG
Part 1 in picture.
Part 2:
import heapq
data = open("Day 16 input.txt", "r").read().strip().split("\n")

grid = {}
for y, line in enumerate(data):
for x, char in enumerate(line):
grid[(x,y)] = char
if char == "S": pos = (x,y)
if char == "E": end = (x,y)

dirs = [[1,0],[0,1],[-1,0],[0,-1]]

queue = [(0, pos, 0, set())] #score, pos, dir, route
heapq.heapify(queue)

bestscore = None
visited = {}
ideal = set()
while True:
score, pos, rot, route = heapq.heappop(queue)
route.add(pos)
if bestscore != None and score > bestscore: break
if (pos,rot) in visited and visited[(pos,rot)] < score: continue
visited[(pos,rot)] = score
if grid[pos] == "E":
print score
if bestscore == None: bestscore = score
ideal |= route
newpos = (pos[0]+dirs[rot][0], pos[1]+dirs[rot][1])
if grid[newpos] != "#": heapq.heappush(queue, (score+1, newpos, rot, route.copy()))
newpos = (pos[0]+dirs[(rot+1)%4][0], pos[1]+dirs[(rot+1)%4][1])
if grid[newpos] != "#": heapq.heappush(queue, (score+1001, newpos, (rot+1)%4, route.copy()))
newpos = (pos[0]+dirs[(rot-1)%4][0], pos[1]+dirs[(rot-1)%4][1])
if grid[newpos] != "#": heapq.heappush(queue, (score+1001, newpos, (rot-1)%4, route.copy()))

print len(ideal)

Relatively simple dijkstra. Part 1 surprisingly worked perfectly on the first try, that never seems to happen. Probably would've gotten a decent rank had I not slept in.
Part 2 runs in about 4 seconds, wouldn't be surprised if all the set copying is to blame. CBA to speed it up.
>>
>>103536241
oh, evidently my check just isn't working
>>
File: Day16.png (228 KB, 1030x1823)
228 KB
228 KB PNG
C#. I quite enjoyed today.
>>
Yearly reminder that there's barely ever a reason to call heapq.heapify(), it does nothing for a list with one element.
>>
>>103536266
>use hashbrown
>use priority_queue
>use itertools
everything you need is in the std
enjoy the malware some CIA nigger inserted in one of the 200+ transitive dependencies
>>
>>103536385
>transitive dependencies
>transitive
>trans
kek
>>
>>103536385
I'm a python dev, I live and breath dependencies. I've been compromised a long time ago already...
>>
File: rust druk.png (373 KB, 554x554)
373 KB
373 KB PNG
>>103536305
>the check I had that was determining whether to stop a chain early was returning instead of continuing to a different direction
just spent like an hour debugging this typo. kill me
>>
>>103535505
I'm happy that I'm not part of today's retarded disccussion.
Regex "chads" can't code
>>
embarrassing day today. Part1 was fine. part2 I flailed around fucking up trying to get the paths for part2.
used golang.
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
16 00:56:33 3598 0 05:31:15 6729 0
>>
>>103536515
code is 4k/2k chars.
full of shit. rather not even try and post it.

will rethink + clean it up later
>>
>>103536112
>https://files.catbox.moe/l64q3v.txt
I can't access it! Let me IN!!! I NEED THE BIG BOY'S BIG PLUMPY ASSCHEEKS!
I'M GONNA DIJKSTRA HIS ASS SOOOO HARD THAT HE'LL BE WALKING ON ALL FOURS!
>>
so you can use djirkstra to get the min score for path 1.
stupid question.
what is the best way to get part2?

I have my list of nodes I heappop off the lowest score. I added a 'path' field to the items in the heap and then just append the 'prev' node to each new item I make.
I then reach the end with an item and its path.

Is there a better way to keep track all the lowest score paths?
because currently I am make a 'huge' list of paths for each item in my remaining list of nodes.
>>
>>103536564
keep track of the parents
>>
>>103536170
Just record where you came from and you can trace your paths back from the end node.
>>
>>103536582
I tried something like that, but I think i fucked it.
>>
>>103536564
>what is the best way to get part2?
literally dfs
runs in a few seconds
>>
>>103536564
take the BFSpill
>>
>>103536564
You don't need dijkstra for part 1, just bfs. Part 2 is dijkstra, you keep track of the fastets way to get to every cell.
>>
>>103536663
>Part 2 is dijkstra
you don't need dijkstra for that either
>>
>>103536701
Well, you can avoid it, but it is easier this way.
>>
>>103536717
>it is easier this way
wrong.
>>
I'm gonna fucking solve day 9 without moving any data around and you can't stop me.
>>
another day
another win for LLMchads
chatgpt-4o-latest is just dominating this challenge
>>
File: Gei-IBHW4AA18D3.jpg (239 KB, 1065x1347)
239 KB
239 KB JPG
>>103536777
trips of truth
>>
>>103536637
>>103536663
>>103536701
>>103536717
fuk ok. I probably over thought it.
I will re-evaluate my code later.
>>
File: file.png (593 B, 233x27)
593 B
593 B PNG
thanks GPT4
>>
>>103535966
Every single thread since Day 1 has had a guy saying "Dijkstra tomorrow".
>>
File: 1733789261614354.png (5 KB, 502x58)
5 KB
5 KB PNG
Thank you based chat jippity, I would have never made it this far without you.
>>
>>103536884
>LLM
>still filtered
the absolute state
>>
timeenjoyedbros...
>>
im stuck on day 19 2015 how the fuck do i do this bros?
>>
are these threads really just the exact same people having the exact same arguments every year
>>
File: aoc24_16.png (594 KB, 818x3988)
594 KB
594 KB PNG
Odin
I didn't expect my grid struct to get this much mileage
>>
>>103537042
nobody's raged about LCM or DP yet.
>>
>>103537050
cycle problem soon
>>
>>103537042
yes, now leave us alone
>>
>>103536104
If he wanted it to be hard, it should have been something like what seats make good for spectating? A spectator seat must be off the best paths and be no more than four Manhattan distances away from a best path.
>>
>>103537056
still no
>impossible for the general case
>simplification hidden in the official input
>simplification not in the sample input
>>
>works for both examples, not for the input

I don't even know what the problem is anymore
>>
>>103536112
Damn, my solution sucks. 70 s.
>>
>>103537154
Reduced to 19 s. Still a long way to go.
>>
>>103536884
I'm catching up to you, on GBA.
>>
>>103537106
Make sure you are facing the right direction at the start.
Make sure you aren't pruning lower score paths just because they visit a location after another path.
>>
>>103537106
also make sure you’re not relying on facing north at the goal
>>
>8 hours in
>less than 10k solved part 2
best day so far
>>
>need to find all best paths
>let algo revisit as many nodes as it takes for my answer to stop increasing
I have become laziness
>>
File: not dijsktras.png (908 KB, 1085x1831)
908 KB
908 KB PNG
>>
>>103537252
it's not even a hard part 2 though
>>
>>103537195
I should clarify that this is for part 2, part 1 I solved relatively quickly. I'm using dijkstra but I don't think I'm pruning lower score paths, since I'm keeping track of all the possible previous nodes for each one, and going back from the end to the beginning.
>>
>>103537298
Calendar image right here
>>
File: img-2024-12-16-13-53-17.png (2.85 MB, 9024x3090)
2.85 MB
2.85 MB PNG
>it's another medium day
yawn...
>>
File: not dijsktras w.png (1.33 MB, 2168x1207)
1.33 MB
1.33 MB PNG
>>103537334
here wide one for calendarbro
>>
>>103537368
Does this mean anything in post LLM world?
>>
>>103537368
tfw day 23 filtered me in 2021
>>
>>103537368
it seems that corpos started getting access to llms in 2020.
>>
>>103537252
my program has been solving it for like 6 hours now kek
no end in sight
>>
so what is the high iq techniques for part1/2?
>>
>>103537424
edge contraction -> dijkstra -> follow parent links
>>
NOT DIJKSTRA'S RUNS IN 3 SECONDS
import math
import sys

sys.setrecursionlimit(int(1e9))

g = list(map(list, open(0).read().split('\n'))); g.pop()
rows, cols = len(g), len(g[0])
cache = [[math.inf] * cols for _ in range(rows)]

m = {}
def dfs(pos, d, cost):
if pos == (1, cols - 2):
return cost
(r, c) = pos
cache[r][c] = min(cache[r][c], cost)
dx = ((-1, 0), (0, +1), (+1, 0), (0, -1))
minimum = math.inf

# continue
(dr, dc) = dx[d]
(rr, cc) = (r + dr, c + dc)
if g[rr][cc] in '.E' and cache[rr][cc] > cost - 1e3:
minimum = min(minimum, dfs((rr, cc), d, cost + 1))

# turn left and continue
(dr, dc) = dx[tmp := d-1 & 3]
(rr, cc) = (r + dr, c + dc)
if g[rr][cc] in '.E' and cache[rr][cc] > cost:
minimum = min(minimum, dfs((rr, cc), tmp, cost + 1001))

# turn right and continue
(dr, dc) = dx[tmp := d+1 & 3]
(rr, cc) = (r + dr, c + dc)
if g[rr][cc] in '.E' and cache[rr][cc] > cost:
minimum = min(minimum, dfs((rr, cc), tmp, cost + 1001))

if minimum not in m:
m[minimum] = set()
m[minimum].add((r, c))
return minimum

p2 = len(m[p1 := dfs((rows - 2, 1), 1, 0)]) + 1
print(p1, p2)

NOT DIJKSTRA'S RUNS IN 3 SECONDS
>>
>>103537422
I ctrl-c'd after an hour and rewrote
finished in 5min and got my stars
>>
>>103537444
but anon, dijkstra is just DFS with a cache
>>
>>103537470
wrong. dijkstra's makes guarantees like e.g. when you visit a node, its distance is final. my code doesn't make such guarantees. the cache only exists here to prevent cycles.
>>
>>103537433
hmm ty
>>
>>103537489
hmm, you're right. I reread your code and the dijkstra wikipedia page. It seems dijkstra is just bfs with a priority queue.
>>
>>103537501
nice try
>>
>>103537501
if everyone has been shitting on dfs and calling their dfs "dijkstra's" it would make my day
>>
BFS? DFS? Dijkstra? I don't know what I am doing, but I am getting stars.
>>
can someone post their input and the results?
I can't find what paths I am missing in p2 and it's driving me nuts
>>
>>103537532
same
>>
>>103537535
see >>103536112
>>
>>103537535
https://0x0.st/XFlU.txt
p1 90440
p2 479
>>
>>103537252
normalfags just can’t do this for 25 days straight
>>
>>103537579
>you need ass burgers to save Christmas
>>
>>103536112
>"""bigboy"""
>get the right answers despite counting path lengths via modulo 1000

14s with my ultra-unwashed babby's first rust code
>>
>>103537843
I don't see any code
>>
>>103537547
aaaaaaaaaaaaaaaaaaaa eric you fucking nigger
i get the correct result for part 1 on your input but mine it says "too high" fuck you eric suck my too high cock. btw the answer that i get for part 1 for my input is 111488 which is really funny
>>
File: warning.png (21 KB, 763x201)
21 KB
21 KB PNG
>>103537923
it's not Erics fault you can't solve a Christmas puzzle
>>
15 part 2 is the LLM filter, in no fucking way is a bucket of matrix multiplications spitting out anything usable for that
>>
>>103538002
i challenge you to tell the difference between LLM and a shitskin in programming ability. go.
>>
>>103538013
llm actually writes code
>>
>Still below 10000 gold
You have the gold star, right? You aren't just sitting with a piss poor silver star, right?
>>
NEW THREAD
>>103538057
>>103538057
>>103538057
>>
>>103538049
>silver star
stop it already, there are only gold stars
>>
>>103538013
sure! LLM:
public class Program 
{
public static void Main()
{
std::vector<int> a;

auto r = "ReverseMe".Reverse();

Console.WriteLine(r);
}
}


shitskin:
import string_reverser
//Thanks to youtube.com/ravejaneshu for simple string reverse tutorial good morning sir to you sir
string_reverser.print("ReverseMe")
>>
>>103538088
rustchad:
let mut chars = "ReverseMe".chars().rev().collect::<Vec<char>>();
chars.reverse();
let r = chars.iter().copied().rev().collect::<String>();
println!("{r}");
>>
File: im-1734360717280.png (36 KB, 482x752)
36 KB
36 KB PNG
>pytoddler solve
haven't checked other solves yet, but i'm using dijkstra for part 1 and for part 2 I do a BFS using part 1 to ensure that I'm still on a lowest-scoring path. curious if there was a better way.
real    0m21.346s
user 0m21.341s
sys 0m0.004s
>>
for part 2 how do you optimize the search? we have optimal path cost, but the search takes forever even if you limit the total cost to the silver answer no?
>>
>>103538404
just cache your shortest time to a cell and kill the branch if another branch got there more than 1000 steps before (accounting for differences in direction): >>103538070
>>
>>103538419
woah thanks for the tip!
>>
>>103538419
just keep track of the parents, then walk backwards >>103535998
>>
File: 1690189092881849.jpg (91 KB, 530x960)
91 KB
91 KB JPG
>>103538210
ahhh shit lol I was way overthinking it as usual. Just need to collect multiple paths in part 1 and once you've found the first path you have your exit-early condition. Requires tracking path of visited nodes for each route and recording visits by heading as well.
>>
File: im-1734363854697.png (70 KB, 884x1028)
70 KB
70 KB PNG
thread's dead post gore
>>
File: file.png (40 KB, 1572x381)
40 KB
40 KB PNG
>>
>>103538603
Anon... Did you just post your input?
I'm sorry, but, that'll be $150K.
>>
>>103538714
yes https://0x0.st/XFlU.txt
>>
>>103538672
>the shortest 1 never reach the limit 3
So it never return. Based graph DB.



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