[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: manhattan_distance.png (6 KB, 252x252)
6 KB
6 KB PNG
manhattan distance 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: >>103583342
>>
File: solve.png (776 KB, 5654x3062)
776 KB
776 KB PNG
idiomatic Rust solution
>>
I call it taxi cab distance
>>
I call it manehattan distance
>>
File: Cheat.jpg (98 KB, 1080x1828)
98 KB
98 KB JPG
>>103588803
That’s Manhattan distance, and here’s the “Man with a hat on” cheat distance.
>>
from itertools import combinations
from collections import defaultdict
data = open("Day 20 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": start = (x,y)
if char == "E": end = (x,y)

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

path = []
queue = [(end, 0, None)]
visited = set()

while len(queue):
pos, dist, prev = queue.pop()
if pos in visited: continue
visited.add(pos)
path.append((pos, dist, prev))
for dx, dy in dirs:
newpos = (pos[0]+dx,pos[1]+dy)
if grid[newpos] != "#":
queue.append((newpos, dist+1, pos))

cheats = 0
savings = defaultdict(int)
for i, j in combinations(path, 2):
dist = abs(i[0][0]-j[0][0])+abs(i[0][1]-j[0][1])
if dist <= 20 and abs(i[1]-j[1])-dist >= 100:
savings[abs(i[1]-j[1])-dist] += 1
cheats += 1

#for i in sorted(savings.keys()): print savings[i], "cheats saving", i
print cheats

>spend a long time working on a robust approach
>can't get it to work
>try super lazy approach
>works on the first try
go figure
>>
>stop overthinking
>solve part1
>see part2
oh boy
>>
>>103588803
Why are people doing BFS with a queue? Are they retarded
>>
thought i'd check in with the problems after anons suggested i come back later. this is definitely more interesting than previous problems, but what is it with programming exercises and absurd big Os? is part 1 even formulatable without O((v+e)^2)?
>>
>>103589024
copy-paste is faster than having to type.
>>
>>103589045
oh nevermind i didn't read close enough, there's only one fucking path. i guess that's better?
>>
i'm trans btw idk if that matters
see >>103588817
>>
>>103588817
horrific
>>
>>103589024
>BFS with a queue
What else would you use
>>
>>103589070
O(nodesInPath * maxJumps)
>>
>>103588817
an anoyingly large resolution and an obnoxiously large font size wtf
>>
>>103589110
You can only take 1 path, just update the current x and y location as you traverse. Whats the point of having a queue? To much LLM? No independent thought left?
>>
>>103588803
Any complaints on reddit about this problem?
>>
>>103589024
muscle memory or wanting to make a more general solution
>>
>>103589133
poorfag can't buy a good monitor lol
>>
>>103589171
>>
File: 1733120606156553.png (18 KB, 1084x129)
18 KB
18 KB PNG
>>103589194
oh daggerdragon, what would we do without you
>>
File: untitled.png (746 KB, 935x775)
746 KB
746 KB PNG
>>103589171
>>
so how many of you are actually employed
how many of you have made any money at all from coding?
>>
>>103589239
been employed programming for over 10 years. i like AOC because it's nothing like programming on the job
>>
>>103589239
I have spent last 20 days coding AOC at work, so has many of my collegues
>>
>>103589194
>>103589217
>>103589222
Ok don't fucking bring rabbit here.
Whoever wants to see it they know how to reach it.
>>
haha they have imposter syndrome; don't you also hate it when you're reminded you're incompetent?
>>
>>103589024
Why do I get the feeling that you learned about BFS and DFS only yesterday?
>>
>>103589239
advent of code taught me pathfinding skills I used to ship a game get fucked
>>
>>103589289
What I meant is why do people use BFS at all when there is a single path so your breadth is always 1. Yes, obviously for BFS you need to store neighbours but this is not a fit for BFS
>>
>>103588817
I wish you a miserable Christmas and a horrible New Year.
>>
>>103589340
It's probably because they didn't look at the main input file, and made an assumption that there'd be multiple paths.
>>
>>103589191
what? what does your monitor have to do with your font size being set so high? even at 16k that's >30% of your screen's height for 23 lines of code. are you fucking retarded or just blind?
>>
>>103589024
What is wrong with using a queue? It will literally process the grid the same way as not using one. Are you retarded?
>>
>>103589415
It is as retarded as using Djikstra in this problem. It technically works but using it is inefficient, as is allocating data for a queue and positions that you have to append to the queue
>>
>>103589024
How about BFS and a hashmap?
>>
>>103589045
the problem is the same even if there are multiple paths
>calculate distance from start to each point
>calculate difference from end to each point
time of any cheat is d1(start) + d2(end) + cheat-length
>>
>>103589558

Nothing wrong with using a queue, it's wrong to use BFS here and if you use BFS for this your not thinking
>>103589340
>>
File: im-1734729022252.png (36 KB, 542x704)
36 KB
36 KB PNG
>pytoddler
slightly washed to avoid doing pairwise over all points to only checking those that could possibly be within range.
>>
>>103589588
How is it wrong if I got the right answer and two shiny stars?
>>
File: tgf.png (942 KB, 2039x2117)
942 KB
942 KB PNG
>>
>>103589621
Your right, keep it up buddy, make sure to use Cursor and ChatGPT as well
>>
i just launched vs for the first time for c++ and got through day 1 2 and 3 but i dont like this shit how do i send the console that pops up every run to the output window how do i quickly make input files to paste in what is this guy using https://www.youtube.com/watch?v=751mAUBkCtg I JUST WANT FAST TERMINAL TO THROW SHIT IN
>>
>>103589639
these are the worst AIs will ever be and you will be replaced one day :)
>>
>>103589024
what do you propose, then? a list? the queue I use for bfs is a circular buffer, enqueue is O(N) and dequeue is O(1), if you're worried about allocation then just don't be a retard about it? reuse the queue and clear it for every invocation
>>
can't i just get all passable # by check right left or top down and broot?
phoneposting still haven't solved the puzzy
>>
>>103589733
##.#
##..
..##
#.##
>>
>>103589749
eric's input doesn't have those, but you should still pay him 150,000 for misrepresenting that as something he made
>>
>>103589733
Yeah, I did exactly that, but then deleted it because p2 solves p1 too.
>>
>>103589749
so check for corners too? seems simple enough
>>
someone want to explain to me how I (mentally) process what the time command gives me
>real
this is the actual time that's elapsed, right?
>user
???
>sys
???
>>
>>103589928
copy the your exact post and ask gpt, anon... are u retarded?
>>
>>103589928
consider I/O: every time you write to a file, socket, the terminal, your program asks the kernel to do that, and your kernel then spends some time doing that. There's work that your program does, and work that is done on behalf of your program by the kernel, and time passes in both cases.
>>
>>103589952
but if I post here I'll get chatgpt responses anyway?
>>
>>103589576
by multiple paths i'm talking about also having dead ends, cycles, etc. a graph requiring actual pathfinding. that's O(v+e) before you get to the cheats.
>>
>>103588817
Based idiomatic Rust solver, causing previously unheard of seethe
>>
my naive approach for part2 gives me bullshit results
gotta rethink the approach
>>
>>103590004
true, but I think the efficient way of solving p2 demands that you flood fill the map anyway, so it's always going to be O(number of floors) at a minimum
or alternatively, if you find the fastest route first, you can terminate your flood fill exactly 100 distance before the fastest route, so it's just the time complexity of finding the fastest route again
>>
>>103588817
This guy hates Rust so much that he wakes up every day excited to do the puzzle in his least favorite language, then rework his code to be intentionally as ugly as possible, and snidely say "idiomatic Rust solution" as a jab. I genuinely think he might be a self-repressed tranny.
>>
>>103590061
>Pathological need to constantly be as obnoxious as possible when interacting with others.
I think it's a given that he's a tranny.
>>
>>103589928
modern computers are capable of essentially creating a temporary time pocket for a brief moment to calculate very primitive operations
"sys" time is the amount of time your computer froze time to do very base level calculations
"user" time is the amount of time you, as the user, physically experienced while waiting for the program to finish
"real" time is just both added up
>>
>>103590135
thanks anon, that clears things up
>>
>>103590135
?
>>
>>103589576
You don't actually need the distance from the start, just the distance from the end.

A >100 cheat is any two tiles a and b where distance(b, end) + taxicab_distance(a, b) + 100 < distance(a, end)
>>
>>103589640
write a script to watch when your source file changes, then runs the compiler and the program
>>
>>103590246
d(a,end) - d(b,end) = d(a,b)
>>
>There are 32 cheats that save 50 picoseconds.
my code spits out 11. not good
basically I try any shortcut up to 20 cells in length, then check it if ends on the old path and that's it
>>
File: last_screenshot.png (95 KB, 931x752)
95 KB
95 KB PNG
>>103590368
No, I don't think so. By "distance" I mean the distance within the maze, not the taxicab distance.

(washed Rust solution)
>>
>>103590391
>basically I try any shortcut up to 20 cells in length, then check it if ends on the old path and that's it
Yeah, there's a better way.
>>
>>103590391
wait a second. I should probably check if I'm crossing the path twice.
and the shortcut doesn't actually have to be the shortest possible path.
back to the drawing board
>>
>>103590391
Shortcuts do not have to end on the same path that they started on.
>>
why is rust so ugly?
>>
>>103590705
- :: (instead of . like in most other languages) to access namespace members is ugly. The reason for it is just autism.
- .unwrap(), .into(), .iter(), .collect() have to be everywhere because lack of implicit behavior is a goal of the language. What would just be
my_list.map(f)
in another language has to become
my_list.iter().map(f).collect()
in Rust because otherwise there would be implicit casting from a list to an iterator to a list.
>>
Another day, another grid
>>
What a terrible puzzle, over 75% of my time spent on it was trying to understand the horrendous wording. If it just said that they can teleport up to 20 tiles of manhattan distance away, everyone would've immediately understood what was going on. But instead its some retarded bullshit where you can cheat twice but only walk through 1 wall and the cheat is shown at as starting inside of the wall instead of at the tile you activated the cheat at but for part 2 you need to treat it as at the tile you activated it at.
>>
File: 1712235727083984.png (416 KB, 1324x1282)
416 KB
416 KB PNG
bros it's over
openai just released a new more gooder model
>>
>>103590705
>why is rust so ugly?
std::unique_ptr<Person> p1 = std::make_unique<Person>("Anon");

how about modern c++
>>
>>103590973
Cool. Now go back to whatever faggot catalog thread you came from
>>
File: 1717933899693945.png (54 KB, 838x284)
54 KB
54 KB PNG
>>103590996
>>
>>103590838
yes, Rust and Zig have it in common that there's no perceived cost in a reader having to read all this shit to follow the code. There's so much that's explicit that it becomes a burden on the reader and obscures business logic, opening the door to more serious logical errors that get missed simply because auditors can't follow it.
These are people who let AI write most of their code already, and think code completion means that there's problem with fitting an entire paragraph in the name of a function.
The future they're creating is one where AI is also needed to read the code.
>>
>>103590477
>No, I don't think so.
Go back to school.
>>
>>103590988
C++ is understandable, as it's had decades of additions awkwardly shoved into it. Rust has been designed to be garbage from the outset.
>>
>>103591006
what the fuck guys? chatgpt can bfs a single path AND count cells within a distance of 20 steps? we are doomed.
>>
Point::matrix(height, width)
.into_iter()
.filter(|loc| steps_at[loc.y][loc.x] > 0)
.map(|loc| loc.taxicab_range(r, height, width)
.into_iter()
.filter(|j| steps_at[j.y][j.x] >= steps_at[loc.y][loc.x] + loc.taxicab(*j) + 100)
.count())
.sum()


I love Rust so much bros
>>
>>103591009
>t. filtered pytoddler
>>
File: day20.png (756 KB, 2560x2866)
756 KB
756 KB PNG
Broot wins again. Need to think about how to do this a smart way.
>>
>>103591009
I don't think it's hard to read, it's just ugly. A lot of the people hating on it don't understand the reasoning behind the decisions, and if you did understand why it's that way you wouldn't be able to think of anything better (except with regards to the :: thing, which was genuinely just a dumb decision).

People usually say Gleam looks great, and Gleam's syntax is inspired by Rust's in a lot of spots, it just has an advantage on prettiness because it's a high-level language so a lot of the things that you need to specify in a low-level language can be omitted.
>>
>>103590973
>openai just updated their benchmarks to more closely fit what their newest model is doing
Spooky
>>
File: 1734584435081678.jpg (362 KB, 720x1280)
362 KB
362 KB JPG
absolute unwashed AWK ass

BEGIN {
FS = ""
dy[0]=1;dy[1]=0;dy[2]=-1;dy[3]=0
dx[0]=0;dx[1]=1;dx[2]=0;dx[3]=-1
}

{
for(i=1;i<=NF;i++) {
g[NR,i] = $i
if($i ~ /S/) { sr = NR; sc = i }
}
}

END {
while(g[sr,sc] !~ /E/) {
for(i=0;i<4;i++) {
if(g[sr+dy[i],sc+dx[i]] ~ /[.E]/ && !l[sr+dy[i],sc+dx[i]]) {
l[sr+dy[i],sc+dx[i]] = l[sr,sc] + 1
sr += dy[i]; sc += dx[i]
break
}
}
}
for(i in l) {
split(i,c,SUBSEP)
for(j=-20;j<=20;j++) {
for(k=-20;k<=20;k++) {
if(abs(j) + abs(k) > r) continue
y = c[1]+j; x = c[2]+k
if(y < 1 || y > NR || x < 1 || x > NF) continue
if(g[y,x] !~ /[.E]/) continue
if(l[y,x] - l[i] >= 104) {
if(abs(j) <= 2 && abs(k) <= 2) p1++; p2++
}
}
}
}
print "Part 1: " p1 "\nPart 2: " p2
}

function abs(a) { return a < 0 ? -a : a }


still not filtered
>>
>>103590288
what setup does the guy in the video use, ide and all
>>
>>103591194
absolutely unreadable

unless yiu're going for code golf
>>
>>103589640
Type Ctrl+` to open up the terminal in VS code
You can also look into launch options
>>

for tile in maze{best_path[tile] = breadth_first_search(maze,tile,goal)}


for i1:walls{
for i2:walls:
for i3:walls{
.
.
.
for i20:walls{
if distance(i1,i2) > 20
or distance(i1,i3) > 20
.
.
.
or distance(i1,i20) > 20
or distance(i2,i3) > 20
.
.
.
or distance(i19,i20) > 20{
continue
}}}...}
newMaze = maze.removeWall(i1).removeWall(i2)....removeWall(i20)
for tile in new_maze{
if length(breadth_first_search(new_maze,tile,goal)) > length(best_path[tile]) continue
if all_paths_ever_taken.contains(breadth_first_search(new_maze,tile,goal)) continue
all_paths_ever_taken.append(breadth_first_search(new_maze,tile,goal)
total++
return total


>>
>>103588817
Imagine hundreds of thousands of lines of code, all as unreadable and unmaintainable. Imagine how many backdoors and undocumented "features" can be hidden there.
>>
File: 1734001793092751.png (1.33 MB, 2084x1584)
1.33 MB
1.33 MB PNG
>>103591252
Hey, I said it was unwashed! It's already annoying enough doing this shit in awk.
>>
>>103591294
Sorry, I think it's part of your choice of language
It is somewhat impressive in AWK, but I'm speaking as a lead somewhere
>>
>>103591294
>doing this shit in awk
You did this to yourself.
>>
>>103591274
oops i just realized it wouldn't work because some duplicate paths are valid but oh well close enough
>>
Tonight we get a tesseract geometry problem, right?
>>
>>103591333
Automata do u even aoc++?
>>
>>103590988
Don't be a retard and use auto.
>>
P1: Fold these 6 grids into a cube, calculate the the shortest path from start to finish if the obstacles away from each other in a distance according to their number, in a direction opposite it’s nearest obstacle. (If obstacles overlap they merge numbers).

P2: Yikes!!! The machine-elves say it’s not a cube, but it’s a hypercube! Solve the same problem, but this time instead of one cube, you have to fold 8 of your cubes into a hypercube. To create the cubes, multiply each cube after the first by the increasing prime factors of the sum of the first cube. The order in which you assemble your cubes isn’t specified. Find the shortest possible path.
>>
>>103591401
*finish. The obstacles move away…
>>
>>103591387
no, fuck auto, i understand less and lose iq points when i use auto
>>
>>103591401
We're on the last week and we'd had zero (0) difficult problems. Eric's got nothing in the tank, he's throwing reject problems at us and hoping the nostalgia baiting makes up for it.
>>
>>103591419
anon... day 12 was hard
>>
File: pjt.png (150 KB, 557x438)
150 KB
150 KB PNG
>>103591414
Good morning Saar, you have a great future in Pajeetsoft, Saar.
>>
>>103591387
I haven’t used C++ in a while, but doesn’t auto make it difficult to work out what sort of arguments a function accepts, or which describe a variable? Type inference is cool, but I see it over used so much in “modern” C++ that it impedes a human from understanding things at a glance. Do Modern C++ programmers resort to naming variables after their types like duck-type languages?
>>
>>103591447
are you saying that not using is auto is pajeetware, lmao@(you)
>>
>>103591447
>>103591414
If I can't write out the type of the variable when I initialize the variable, someone has created a monstrosity of a type that has no right to exist.
>>
>>103591419
It’s the weekend, this is his opportunity to drop an extremely difficult puzzle.
>>
>>103591434
Forgot that one. Still would've been medium on other years.
>>
File: file.png (38 KB, 1200x1200)
38 KB
38 KB PNG
Ultrashortcut abusing elf. Really need to check out 2017 that still has a neat theme
>>
>>103591532
Nice
>>
>>103591346
There was a 4D cellular automata one year
>>
>>
File: 1459724863297.jpg (27 KB, 457x480)
27 KB
27 KB JPG
>>103591646
Ohhh yeah I remember that one damn I’ll have to see if I can find my solve when I get home (phonepostin rn) should be able to grep for x, y, z, w and find her
>>
>>103591346
Yesterday was grid so it won't be grid today
Cellular automata is tomorrow
Tonight is find the number of corners of the 3D shape defined by these thousands of linear equations or something like that
>>
>>103591869
Nah he's phoned it in. Tonight is "The elves need your helping solving a leetcode easy!"
>>
>>103589388
you don't even need to check the input, the problem mentions that there's a single path
>>
>>103591456
If it's difficult to work out types that's just abuse of auto
But something like auto [a,b]=f(x) or auto f=[&](int x, int y)... for a lambda is a lot cleaner than the full type
>>
>>103591532
I hope you have another idea for a picture of an elf running. Because it's maze 4 tonight.
>>
im tired of 2d grids
>>
File: 1583853007041.jpg (39 KB, 1000x1000)
39 KB
39 KB JPG
>>103591869
we’re due for some real hard bois I think it’s gotta revert to the mean and we have a lot of reverting to do based on this years easiness
>>
4 days to save AoC
>>
ok maybe some of you really do have jobs but how many of you have girlfriends
>>
>>103592068
I tell my girlfriend about all the puzzles. She doesn't understand them but she likes the plot, and she hates the idiomatic rust guy with me
>>
File: ComfyUI_00403_.png (1.39 MB, 1024x1024)
1.39 MB
1.39 MB PNG
>>103592068
of course anon, she's right here
>>
>>103592068
Women are parasites. Why would I want to associate myself with a parasite?
>>
>>103592068
I have a job and a wife.
>>
File: p9kg4ewvz0i81.jpg (649 KB, 3000x2000)
649 KB
649 KB JPG
>>103592068
>>103592109
lol I had just finished the towel one and my wife was like “did you get your stars today?”
Yeah you want me to tell you about the puzzle?
“Ahhh that’s ok, I’m just glad you enjoy it”
My oldest boy is curious about it. I made the sokoban one animate in the terminal and we had a good laff about that silly busy bot
>>
>>103592149
"Spending resources on a hot girl? Ha, loser! I'll be saving my precious time and energy for these increasingly easy computer programming puzzles that I found online."
>>
>>103592109
In fact most Rust programmers are women, so please don't refer to us as "guys".
>>
File: day20_procs.png (358 KB, 1588x2470)
358 KB
358 KB PNG
>>103584475
$ mix run -e 'AOC.main()' -- 2024 20 b input/real
1521
1013106

Ran in 1162.34ms


Fixed some dumb mistakes and separated cheat-checking into its own process separate from the map traversal.
>>
broot still running...
>>
>>103592318
Most Rust programmers will never be women, actually
>>
>>103592068
I have a job, a son, and a pregnant wife.
>>
>>103592006
Same. Enough is enough eric. I’ll even take another graph problem just don’t make it a 2D grid for God’s sake.
>>
AOC was so disappointing it killed the threads this year. Very few people bothered to make visuals and even the big boy creators don’t always bother.
>>
>>103592420
source
>>
>>103592294
>hot girl
Anon, we do programming puzzles to celebrate Christmas; we're not getting hot dates at all.

>>103592349
Fuck, we're getting old, aren't we?

>>103592349
How many women are here? I know we have that dumb woman who is somehow plowing through it in AWK and avatarfags as Marcille, so that's at least one.
>>
>>103592428
>AWK
>biological woman
Nice try.
>>
>>103592420
>Very few people bothered to make visuals
there were visualizations every time a puzzle was suited to it
>big boy creators don’t always bother
has always been the case, no real point for some types of puzzles
>>
>>103592456
I do not believe an XY would bang his head against the wall all month using a fucking shell language. He'd redoing it in ASM or Rust or C or something.
>>
Im not a woman nor pretending to be one but AWK is awesome, please respect it
It has a very different feel from anything else. It's terse, weird and hacky but still has the clarity of C instead of "there's more than one way to do it" schizophrenia of Perl
>>
>fast on example
>impossible on input
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
>>
>>103592584
Gotta get a little more clever than that anon.
>>
anybody use fortran
>>
>>103592068
How will a girlfriend help me get stars and save Christmas?
>>
>>103592613
My mother does. She says it's still valid, especially now with containers and Copilot.
>>
>>103592663
is your mom the fortranny poster who got filtered (haven't seen her in recent threads)
>>
are we still hype for aoc?
>>
Did no one make a bigboy yet?
https://files.catbox.moe/bkp48i.7z
10001x10001
Silver: 11988920
Gold: 6566982809
>>
>>103592729
Tonight is erics last chance for me. I still wont be filtered this year. But if this puzzle takes me less than 3 hours...
>>
>>103592729
tonight I break #1000 inshallah
>>
File: 1734582908665963.jpg (1018 KB, 1280x720)
1018 KB
1018 KB JPG
Ready for another maze baka-anon?
>>
>>103592854
I swear I'm gonna pin her down and flood fill her.
>>
today will be another grid where the leaderboard fills up in 50 seconds
>>
>>103592772
My times peaked on day one. Feels bad.
>>
>>103592866
That's what she wants
>>
>>103592772
I got 1300 last night. That’s def gonna be my best time
>>
My best was 1035 on day 12, I don't think I will best it.
>>
>come back on 4chan to follow aocg
>now have aocg and 7 /d/ tabs open
>>
>>103592988
never visited /d/ once in my life. feels good to not be a degen
>>
yesterday was my best rank so far (583) because I was able to just copy my previous code.

I should say my best rank so far until today, maze #4, where I can reuse my code again.
>>
>>103592854
what if her.. you know.. is shaped like a maze
>>
>>103592739
And a mediumboy if that's too big
https://files.catbox.moe/ftl2uk.txt
1001x1001
Silver: 118083
Gold: 64348915
>>
Can't wait for this shit to be over. What a boring year.
>>
>>103593051
eric saved the best for last. Trust the plan
TWO
MORE
DAYS
>>
>See Copilot icon in VSCode after an update
>Sure, let's check it out, why not, it's free after all
>Got bored after playing with it for a few minutes
>Forget about it
>AOC time, start writing code
>Sudden autocomplete writes djikstra for me using my data structures and helper functions (with a few mistakes, but still)
What the fuck, I almost got auto-filtered by the Jewpilot. Good thing that we had djikstra for like 5 days in a row now and I memorized how to write it myself.
>>
>>103593081
>my ide almost helped me
sorry to hear that anon
>>
Languages I haven’t seen (at least regularly)
>Julia
>Matlab
>Maple
>Ruby
>Racket or any other scheme (Some lisp fags)
>The guy who wrote his own language
>Ada (I saw someone saying “unwashed Ada” but there was no code)
>PHP
>OCaml
>Visual Basic
>Scala
>Prolog (I did see it once though)
>Rust (No, not even once).
>>
>>103593081
> xe needs to memorize dijkstra, as it is not self-evident for xim
I use copilot but it never wrote anything I didn't know how to write in advance. With an exception of some shell scripts because I can't be bothered to learn shell syntax.
>>
>>103593140
I remember Julia-anon from a few years ago. Where did all our old /aocg/ friends go? Maybe it’s time I move on as well.
>>
>>103593140
I could have sworn someone is using racket this year.
>>103593151
Its over. Eric has given up. anons have given up. The only ones left are those of us who have nothing else (see you next year)
>>
>>103593151
Slim chance this affected the Julia-anon particularly, but I blame the Russia-Ukraine war for wiping out a lot of good programmers. There was covid too, but since no one on 4chan took the vax and the demographic tends to be young it probably didn’t perma-filter anyone.
>>
>>103593160
It's an honor to do this with you all every year.
>>
>>103593081
>>103593146
Copilot is great
>write
int up = std::max(0, i - limit),

>it fills in
down = std::min(num_lines, i + limit + 1),
left = std::max(0, j - limit),
right = std::min(line_length, j + limit + 1);

Exactly what I was going to type anyway except now I don't have to
>>
>>103593180
Yeah, this is basically what I use it for.
>>
Start writing code to handle 3D blocks, and make sure you’re comfortable with how they’ll stack atop one another.
>>
>>103593140
>Julia
It's cool but useless because Python exists, so no one is using it anymore
>Matlab
Saw at least two people doing this year in Matlab
>Maple
Who
>Ruby
Useless because Python exists, so no one is using it anymore
>Racket or any other scheme (Some lisp fags)
There is one guy ITT
>The guy who wrote his own language
Saw him like a week before?
>Ada (I saw someone saying “unwashed Ada” but there was no code)
Same
>PHP
A shame
>OCaml
F# is better, but F# is useless because C# exists, so no one is using it anymore
>Visual Basic
Is useless because C# exists, so no one is using it anymore
>Scala
Too hard for the warriors of Durgasoft
>Prolog (I did see it once though)
Same
>Rust (No, not even once).
Same, I wonder where all the Rustfolks are
>>
>>103593180
I'm thrilled to know I share this thread with cheaters.
>>
File: carbon.png (739 KB, 2048x4164)
739 KB
739 KB PNG
>>103593140
here's my day 5 pt1 solution with ocaml.
i'm taking it slow, because i'm learning ocaml in the process
>>
>>103593224
I am pretty comfortable with stacking my penis atop your mom.
>>
>>103593140
I'm the unwashed ada guy but I'm not going to dox myself posting code. It's not that interesting anyways since basic solutions are 100-200 lines.
>>
>>103593318
>I'm not going to dox myself posting code.
Are all ada users this schizo?
>>
Day 25: What is the largest determinant of a n-dimensional matrix with elements equal to 1 or -1.
>>
File: goose strangle.jpg (141 KB, 768x1024)
141 KB
141 KB JPG
30 MINUTES
>>103593329
I HATE MATH
I HATE MATH
I HATE MATH
>>
>>103593329
in english,, einstein?
>>
>>103593318
Oh, you must be sharing your code with your real name for the AdaCore competition?
>>
>>103593140
I did the first week or two in Nim last year, and I wasn't the only one. But I haven't seen a single Nimchad post this year.
>>
>>103593341
I could pose the question in its original French, but I still don’t think that would help you, or anyone get close.
>>
if eric gives me another dogshit puzzle im sharing his input
>>
>>103593232
>Same, I wonder where all the Rustfolks are
I've seen a bunch of rust solutions this year?
>Prolog
Prolog isn't that hard.
>F# is better
F# has some of the worst tooling of any language i've ever fucking used. Yes, even worse than Ocaml. It's worse than python for fucks sake.
Without Rider, it's also next to unusable. Really a trash ass language.
If you want a better type system, use Idris. F# is legitimately such an overshilled piece of shit.
>>
Rustanons, how is your aoc directory structured? I am currently using js and I just have my package.json in my aoc/ directory with my utilities file and when I need to run something I just run node solution.js indisde of aoc/year/day/. But looks like rust wants me to run only main function, so do you create a Cargo.toml for every day? Or do you run solutions as test functions with a placeholder main.rs, since cargo can do that?
>>
File: Tism.jpg (372 KB, 2000x1125)
372 KB
372 KB JPG
>>103593362
>I've seen a bunch of rust solutions this year?
You have the ‘tism.
>>
>>103593361
ANON DON'T IT'S NOT WORTH $150,000
>>
>>103593378
I'm drunk and high and solving ascii sudoku at 11:30 on a friday, give me a break
>>
>>103593379
Oh yeah, I forgot about that 100 page contract I signed with Eric!
>>
>>103593389
>>103593389
>drunk
Degenerate
>high
Criminally degenerate
>>
>>103593361
>Taking food directly from Eric's family's mouths
You monster.....
>>
>>103593405
Degenerate your mouth on my asshole bitch
>>
Don't visualizations show the input by proxy? Reddit jannies have some work to do.
>>
Don’t do drugs kids. Don’t be like >>103593415
>>
T minus 20 minutes
rev up those grid parsers
>>
>>103593416
YES. Scrub any visualization you have ever made PROTO. Do not put that anywhere near the internet or any computer which may become connected to a public network.
>>
Going to bed. Good luck anons
>>
Reminder that every input is invisibly watermarked to your github account, so taht if you share it they know where to send the lawyers
>>
>>103593425
I WILL NOT DO ANYMORE GRID QUESTIONS
I WILL NOT DO ANYMORE GRID QUESTIONS
I WILL NOT DO ANYMORE GRID QUESTIONS
I WILL NOT DO ANYMORE GRID QUESTIONS
I WILL NOT DO ANYMORE GRID QUESTIONS
I WILL NOT DO ANYMORE GRID QUESTIONS
>>
i will filter myself if i see another grid
>>
File: 1731407207128805.png (26 KB, 474x190)
26 KB
26 KB PNG
>>103593434
found the solution, anon
>>
>>103593425
It’s 3D tonight. Going to involve assembling some sort of molecule. The elements are falling, and you have to count the number of times they turn into one of the molecules in your puzzle input. In part2 you’re asked how many molecules would be created if the simulation ran for 3000000000000000000 pico seconds.
>>
>>103593446
didn't we have that before?
>>
File: kek2.jpg (55 KB, 563x503)
55 KB
55 KB JPG
>>103593444
kek & checked
>>
>>103593140
I miss slouch anon
>>
I have just received a premonition. Today's puzzle will involve aiming something, so that it hits something else. I cannot elaborate further
>>
>>103593451
Probably, Eric is out of ideas.
>>
>>103593460
Yes, you’re on a spinning 3D structure (the moon) trying to aim missiles at another object which is orbiting Mars. Part2 asks you to fire at an object in another galaxy. You should be able to solve this.
>>
>>103593446
>3000000000000000000
uhmmmm sweaty that's larger than javascript's maximum safe integer, try again
>>
>>103593460
I have received a premonition.
Today you will earn $160.25 sucking dick.
>>
File: file.png (6 KB, 801x31)
6 KB
6 KB PNG
AOC++ HINT JUST DROPPED
DUST OFF YOUR ASSEMBLY SIMULATORS NOW
>>
dijkstra today
>>
>>103593492
requiring you to use previous days solutions is discriminatory to peoples who couldnt solve it sweaty
>>
>>103591532
CUTE!
>>
>>103593498
>today's puzzle is on advent of code
thanks
>>
AoC++ Leak:
Today's puzzle will be day 21, and the event will last until day 25.
>>
File: 1732355357215649.jpg (190 KB, 1280x720)
190 KB
190 KB JPG
Tonight's the night!
>>
>>103593516
there is no wall only people trickling off from eric's dogshit grid barrage
>>
File: loli-sunglasses.png (813 KB, 899x899)
813 KB
813 KB PNG
3d game simulation today
>>
>>103593525
Aka the wall.
>>
I hope today is pathfinding through a maze again
>>
>>103593527
3D maze today
>>
Today's problem will also be a grid but to mix it up this time the path will only have one direction, no turns. Find out how many points exist on this straight line
>>
>>103593538
thats still a grid and i will still rape eric
>>
4 MINUTES
>>
>>103593536
what about mazefinding through a path
>>
File: showtime.jpg (46 KB, 640x480)
46 KB
46 KB JPG
https://www.youtube.com/watch?v=hjGZLnja1o8
>>
>>103593548
cancer music
>>
>>103593548
kino music
>>
>>103593548
SHOWTIME
>>
File: 1733201676061642.png (453 KB, 1858x1829)
453 KB
453 KB PNG
>>
>>103593555
>mokou anon isn't here
aoc is dead
>>
>>103593555
trips confirm!
>>
File: 1719758154343931.jpg (130 KB, 440x518)
130 KB
130 KB JPG
>>
>>103593562
impatient
>>
>>103593555
showtime checked!
>>
TODAY WILL BE EASY
>>
https://www.youtube.com/watch?v=Z1Pf32SnUm0
>>
>>103593565
I NEVER DOUBTED YOU
>>
dijkstra already copied. I'm ready.
>>
AoC++ here, just got my headstart. Today's really hard, you have two lists and you need to subtract the smaller number from the bigger number, then add up the totals. Not sure how I'm gonna solve it.
>>
>>103593575
begone wench
>>
>>103593582
lol
>>
File: yui-stronk.jpg (74 KB, 1047x1005)
74 KB
74 KB JPG
let's do this /g/irls!
>>
FUCK
>>
FUCK
>>
advent of parsing
>>
FUCK
>>
FUCK
>>
??? what am I reading
>>
>wall of text
eric you fucking nigger
>>
1273A
>>
FUCK
>>
My brain is having difficulty parsing this. Im stunlocked.
>>
fucking tl;dr
>>
I am too retarded to understand this robotception bullshit
>>
I think I'm filtered
>>
Time to scroll up and down the page for 30 minutes instead of just reading it
>>
too long can't read
>>
>control this robot controlling this robot controlling this robot and make it the shortest path possible
theres your summary
>>
wtf is going on
>>
THIS IS JUST MORE PATHFINDING IN DISGUISE
>>
>>103593644
tables on tables on tables
>>
yeah I think I'm just not gonna do today
>>
FUCK THE BLANK SPOT IN THE BOTTOM LEFT KEYPAD FUCK YOU YOU STUPID NIGGER SPOT
>>
guess for part 2: woops actually you need a chain of six thousand robots
>>
>25 byte input
>>
File: img.png (24 KB, 714x237)
24 KB
24 KB PNG
>LLMs can't solve this one
>>
>>103593702
i didnt even write any code yet lmao
what the fuck
>>
>>103593709
same
>>
>transplier day
jesus
>>
It would be so easy if I could just figure out how do avoid the death corners. Closing thread. See you on the other side
>>
>>103593709
trying to work out how to approach it without writing 300 lines of lookup tables
>>
>p2
>going over any specific tile costs that much time, i.e. 7 costs 7, 6 costs 6, now figure out the shortest path
>>
>>103593723
bro just djikstra it
>>
If this were the only pathfinding puzzle in the last week it would have been novel at least
>>
pain
>>
Yeah this one will wait until tonight. Advent of no fun.
>>
>works on sample
>doesn't work on real input
AAAAAAA
>>
File: suffering.png (54 KB, 412x354)
54 KB
54 KB PNG
pain and suffering
>>
File: kuroko-headbang.gif (1.8 MB, 852x456)
1.8 MB
1.8 MB GIF
AAAAAAAAAAAAAAAAA TOO MUCH NESTEDNESS IS MESSING MY BRAINS
>>
lmao you guys were so confident and bragging about how repetitive and shit the puzzles are and how eric lost his touch... welcome to the filter club, retards
>>
>get 165 length, not 68
... fuck
>>
>works for example
>incorrect for input
what the fuck?
>>
>>103593886
nvm I got it
>>
>robot can't point at blank space
does this even matter? For part 1 you should get the same answer even if you allow it, manhattan distance is manhattan distance....
>>
>Realize my edge case
>Im fucked and have to start over
FUUUUUUUUUUUUUUUUUUU
>>
>>103593908
same kek, it wasn't as simple as I thought
>>
>works for all example codes except 456A

What the fuck
>>
>>103593920
I know how to fix it. It just sucks that I did it the wrong way on a coin flip.
>>
>>103593923
Debugging the same dogshit right now
>>
Does the example seem wrong to anyone else? I'm walking through it manually and it maps going from A to > as "^A" even though it should be "vA"
>>
>>103593954
wrong
>>
>>103593907
>manhattan distance is manhattan distance
The specific sequence of directions you take matters, since they can further expand to sequences of different lengths.
>>
Fuck, I'm gonna try doing it the stupid way and broot. I'm out of ideas at this point.
>>
>>103593861
Is your boot sucking a compensation for your inability to do the puzzles yourself? If you were able to you'd know this is still the same shit
>>
I just noticed I can't just BFS every button combination because not every direction has the same cost.
>>
dunno how to get my pathfinding to ignore the empty space so I'm just going to replace inefficient instructions after translation
>>
All the examples work except 379A for which I get a length of 68. Edgecase bros?
>>
>>103593958
Yeah you're right
>>
>>103594020
That's not an edge case, you just did it wrong
>>
>>103594020
I am having the same problem.

I wrote debug functions to reverse the process, and my 68 length string compiles back to 379A, so I guess I'm not actually getting the shortest path somewhere?
>>
>In total, there are three shortest possible sequences of button presses on this directional keypad that would cause the robot to type 029A
certainly, picking any of these three sequences isn't going to have any effects down the line, right??
>>
>>103594009
huh?
>>
>>103594053
>>103593973
>>
>correct on example not input
FUCK
>>
>>103594064
we know
>>
There's no chance this strategy works right
>>
>>103593857
PLS 1 RAPE
>>
>example works
>test input doesn't
FUCK YOU ERIC
>>
>>103594071
It doesn't work for me at least. I built my map by BFS'ing every button with every other button. Then I noticed it's more efficient to press the same button twice or chose a button that is closer to the last one you pushed so I changed my directions to depend on the last button I pushed but it still doesn't work.
I think this might be much more complex.
>>
File: 2.jpg (396 KB, 1280x720)
396 KB
396 KB JPG
>>
>>103594087
Good to know. I'll just abandon this path then and try to come up with something better.
>>
>>103594075
she's 10
>>
>>103594087
I thought about doing this but the map is so small seemed like overkill. I just insert as many direction as are required by the difference in grid location. Then just make sure you start with either x direction or y direction based on start position
>>
>>103594096
out of 13?
>>
>>103594089
>There is already a duplicate image
When has this stopped anyone
>>
>edge cases to check for closest distance
hate it here
>>
>>103593664
F I L T E R E D
I
L
T
E
R
E
D
>>
i should have just brooted why am i trying to be efficient..... brootbros.... I failed....
>>
This fucking SUCKS
>>
>>103594121
You niggers realize saying filtered does nothing but shit up the thread
>>
>>103594130
filtered
>>
>>103594130
filtered
>>
>counting up doesn't work
I'm going to try counting down
>>
>>103594132
>>103594133
You are why this thread is dog shit
>>
>>103594135
you're supposed to count from the left
>>
>>103594136
Okay that's it. Trying every possible path between keys every time and recursively expanding them to see which ends up shorter. Fuck you Eric you've reduced me to this.
>>
Wow how handy it looks like I have a skip a day and not be filtered free card by paying for AOC++ here I'll go ahead and cash it in now
>>
>>103594156
Do you have cards for every day after this too?
>>
>part2
I am fucking finished... My broot solution can't possibly do this.
>>
>>103594174
just cache it
>>
anyone find out any edge cases for p1 yet, im out of ideas
>>
>opens question
>can't comprehend shit
>leaves
See you guys next year
>>
>>103594178
yeah there's an edge case where some paths aren't as short as others. don't choose those.
>>
>>103594178
Create a new source file and start over
>>
>part 1
>example doesn't work
It might be actually over
>>
>>103594136
filtered
>>
>>103594182
SAAAARRRR you need to sign up for english courses saar
>>
>replaced my code with my answer on accident
>saves
>cosmic ray causes BSOD
Today is not meant for me I'll sit this one out
>>
>>103594185
>>103594183
alright im filtered then
>>
THE WALL
>>
>>103594207
get godfiltered
>>
I'm going to work on this all night if I have to.
>>
>use bfs to optimize movement across keypads
>very simple and fast code
>realize I need the path as well
>a dfs would've trivially gotten the path
AoC is anti-BFS hate speech
>>
>>103594207
was your answer at least right
>>
>>103594235
Yes but it was the example answer
>>
>>103594232
what are you optimizing, you either move all x then y, or you move all y then all x
>>
>>103594250
I did this and it did not work on real input
>>
>>103594250
part 2: oops half your keys are broken and here's a formula to let you press 0 twice instead of a broken 1, etc.

the real answer is just that I like BFS that much, OK?
>>
>>103594250
the examples don't even do that, and you can't because of the blank space
>>
I keep getting 68 for
379A: <v<A>>^AvA^A<vA<AA>>^AAvA<^A>AAvA^A<vA>^AA<A>A<v<A>A>^AAAvA<^A>A
and it is driving me up the wall.
>>
>>103594250
>you either move all x then y, or you move all y then all x
hahaha
>>
>>103594276
try doing it right
>>
>>103594290
uh oh the troon is getting uppity!
>>
fuck you eirc include edge cases in the examples next time

780A
846A
965A
386A
638A

take this cunt
>>
>>103594318
Stop calling your retarded bugs "edge cases"
>>
File: wtdd.gif (784 KB, 240x261)
784 KB
784 KB GIF
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
21 01:21:58 811 0 01:42:48 436 0

I FUCKING DID IT, I DID NOT LOOK AT THE THREAD, I AM NOT FILTERED
>>
>>103594276
imagine on the keypad that you need to some combination of UP and LEFT, and then finish with A.

if you're naive, you'd maybe do something like ^<A, but then your next-in-line robot would need to backtrack: Av<A>^A>A (8 presses)

if you're smarter, you'd just <^A (swapping order of the direction presses). then, your next-in-line would only need A>^A>A (6 presses)

(im stuck here too and dont want to code it)
>>
>part 1 done
>my smart way didnt catch some sort of edge case
>had to broot
>cant broot part 2
Time to find the edge case...
>>
>>103594330
>I DID NOT LOOK AT THE THREAD
Wouldn't have helped anyway
>>
File: optimistic-elf-noises.jpg (380 KB, 1280x720)
380 KB
380 KB JPG
>>
>>103594279
well my way actually does work for the example input. I realize now there are times where I need to swap which direction is first, x or y,
>>
trying to optimise forwards doesn't fucking work ugh
don't want to rewrite but don't want to be filtered this close to the end
>>
File: UNWASHED ASS.png (551 KB, 824x4189)
551 KB
551 KB PNG
Let he who is UNWASHED post the first ASS.
>>
>>103594345
>well my way actually does work for the example input
On accident, sure.
>>
>>103594361
no because eric purposely crafts examples to not test all cases faggot
>>
>>103594377
>reee I need my exact input to be an example so I just can just copy the example answer and not have to code anything!
>>
semi-broot running for part 2. would be shocked if it works.
>>
>>103594387
i look like that and say that
>>
>>103594387
lmao have sex
>>
>>103594401
I can have sex with example women just fine but it never works on the real ones
>>
>>103594410
yeah we know
>>
>>103594401
sodomy doesn't count sweetie
>>
>>103594410
kek
>>
Legitimately fun and hard problem to solve today, comparable to the Loch Ness monster problem. Sasuga Eric-dono.
>>
>>103594429
tomorrow will be grid with pathfinding
>>
>>103594433
TODAY is a grid with pathfinding.
>>
Fuck, I might be filtered
>>
YES i finally got a rank below 1000
>wrote out two gigantic hashtables by hand, prioritizing '<' and '^' when possible
>it worked
>>
>This is how you know you are truly lost
I was hoping random pruning might get me there. But it turns out the states are simply too long after 25 iterations. memo time
>>
>>103594437
no it's two grids with pathfinding
>>
>>103594454
>prioritizing '<' and '^' when possible
I did this and it didnt work.....
>>
>>103594454
God damn it are you serious?
>>103594087
You fucking lied to me
>>
File: frieren-hang.jpg (197 KB, 2048x1866)
197 KB
197 KB JPG
it's so fucking over...

<A^A^^>AvvvA  (mine)
<A^A>^^AvvvA (correct)
v<<A>^>A<A>A<AAv>A^Av<AAA^>A (mine)
v<<A>>^A<A>AvA<^AA>A<vAAA>^A (correct)
v<A<AA>^>AvA^<Av>A^Av<<A>^>AvA^Av<<A>^>AAv<A>A^A<A>Av<A<A>^>AAA<Av>A^A (mine)
<vA<AA>>^AvAA<^A>A<v<A>>^AvA^A<vA>^A<v<A>^A>AAvA^A<v<A>A>^AAAvA<^A>A (correct)
>>
>>103594457
Wait does part 2 expand it from 2 robots to 25 robots?
>>
>>103594475
Ive said too much...
>>
>>103594471
So none of your shit works?
>>
>456A
fuck this crap
>>
>>103594511
the length is correct up to 2 layers (the text says there may be multiple ways, only length matters as far i see).
>>
Actually I give up. 21 isn't a bad day to be filtered. Further along than some previous years.
I think I have a working path forward but implementing it will take me hours of struggling and I'm just not strong enough.
>>
>>103594433
kill yourself
>>
>>103594467
lol
>>
>>103594524
>the length is correct up to 2 layers
The final length is what matters, and the intermediate layers having different sequences with the same length will result in different length'd final layers.
You're picking bad paths in your intermediate layers that expand to too long of paths in the final layer.
>>
HOW THE FUCK DO I DO PART 2
I think I coded it but my search states are too large
>>
>379A
how is this 64? my program returns 68. this is monumentally annoying to debug because I will have to just rebuild the sequence in reverse to see. bleh
>>
File: img-2024-12-21-08-31-50.png (1.23 MB, 2798x5896)
1.23 MB
1.23 MB PNG
unidiomatic Rust solution
>>
File: day21.png (278 KB, 871x2813)
278 KB
278 KB PNG
Day       Time   Rank  Score       Time   Rank  Score
21 02:07:59 1777 0 02:27:04 893 0

wasted so much time on part1 due to premature optimization. didn't want to "bruteforce" each letter. turns out that's not possible (I think).
wrote a recursive solver trying all possibilities, for part2 i used the good old memoization. (after struggling to get the rust cached crate to work)
takes about 1ms
>>
There's some trick for part 2 to prevent brooting, but I'm so close to getting a broote that doesn't fuck up V8 memory limitations.
>node actually crashed emacs via the shell somehow
FUCK
>>
>have to check if I'm ever on the fucking empty space
terrilbe fucking case
>>
Reminder: If your solution makes you end up on the blank space you're NGMI.
>>
https://pastebin.com/y1v8gN4x
>>
>>103594665
https://pastebin.com/5cPYgzN5
>>
>>103594634
i think today is an other no bigboy day... so sad that this year there were so few .....
>>
>>103594611
>reorder the way directions are processed
>379Agoes down
>but so do 179A and 456A even though they were correct
uhhh
>>
>>103594665
>>103594684
I remember someone posting something like this back in like 2019 for some annoying puzzle but deliberately inserting a couple of bad entries
>>
>>103594689
There is an objectively correct way to do order the directions to minimize cost. Look at the keypad again and you can figure it out. Imagine you actually had to use it; how would you press a group of X buttons (and then a final A) in the most efficient way?
>>
>>103594687
at least the problem was interesting.
Let's hope for a for a christmas miracle of a day that is interesting and allows for bigboys.
>>
>>103594706
the problem is my code apparently found something MORE efficient than the example so I have to go through it in reverse... I might just redo my solution since this one is kinda bad
>>
>>103594717
did you avoid the blank space on the pads?
if not your robots exploded :(
>>
>>103594717
>the problem is my code apparently found something MORE efficient than the example
because you're doing something not allowed. re-read the problem statement and you'll find the gotcha
>>
>>103594725
oh, damn. still gotta redo it but that's helpful
>>
Was anyone able to broote part 2 by just going from 2 to 25 iterations? If so, what language did you use?
>>
>>103594749
just add a cache
>>
I am going to eat and then return to doing it. I think I finally understood how to do part 1. I am scared of existence of part 2.
>>
>>103594750
What exactly are you caching? If you're just expanding the string during each iteration, aren't you ending up with a fuckhuge string?
>>
File: 1709281687283373.png (698 KB, 1476x6960)
698 KB
698 KB PNG
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
21 00:42:58 133 0 02:45:02 1061 0

This took way too long to get right despite knowing the strategy was sound
>>
>>103594020
>>103594049
>>103594276
>>103594611
What you should be getting for 379A:
A,A -> 3,A :  11
Press A : 1
3,A -> 2,< : 10
2,< -> 1,< : 1
1,< -> 4,^ : 7
4,^ -> 7,A : 4
Press A : 1
7,A -> 8,> : 6
8,> -> 9,A : 4
Press A : 1
9,A -> 6,v : 9
6,v -> 3,v : 1
3,v -> A,A : 7
Press A : 1
Total : 64
>>
>>103594750
>>103594767
Oh, I think I get it now. I can cache lengths / costs I think
>>
3 rust solutions. only a single non-rust solution...
rust superiority confirmed
>>
every time I run part 2 I feel like a north korean aerospace engineer.
>>
File: img-2024-12-21-08-59-04.png (1.8 MB, 5600x5532)
1.8 MB
1.8 MB PNG
idiomatic Rust solution
>>
The more I think about it the more annoyed I am.
Is there a reason to carefully generate shortest keypad sequences if they don't even necessarily benefit the next "layer" and all need to be tried anyway?
>>
File: 1717284093665111.png (2.82 MB, 1000x3180)
2.82 MB
2.82 MB PNG
ok, this was fun
unwashed

      --------Part 1---------   --------Part 2---------
Day Time Rank Score Time Rank Score
21 02:23:38 2049 0 02:52:14 1134 0
>>
>>103594824
I am testing a heuristic I think might actually work. My part 1 code took a minute so this might take a while...
>>
>>103594838
So is brute forcing contrived shortest sequences the actual solution? I think I may be fucking myself on this one by assuming it isn't that boring and there's a trick
>>
>>103594838
If your part 1 took a minute, your part 2 is going to take quadrillions of years
>>
>>103594863
there's a trick, you don't have to enumerate all options
>>
>>103594865
>>103594863
yeah the sequence gets long, fast. I think you are forced to memoize. Ill leave it to broot in the background
>>
>>103594835
your path between.
you either fill all </> then ^/v (or swapped)?
depending if the one axis will move to a hazard.

that gave the optimal path? I tried that and got the correct value for part1 example, but not for my input part1 and then had to change my approach.

are you just lucky?
>>
File: what the fug.png (186 KB, 600x700)
186 KB
186 KB PNG
>>103594823
>let pos = |b| [2, 1, 3, 5, 4][usize::from(b) * 71 + 6 >> 4 & 7];
>>
>>103594873
>Ill leave it to broot in the background
my shortest shortest sequence is ~75GiB long
>>
File: .png (28 KB, 604x225)
28 KB
28 KB PNG
THE NUMBERS MASON, WHAT DO THEY MEAN?
>>
>>103594886
it's a perfect hash function
>>
>>103594887
did I stutter? My ram will fail before I hit control-c. Its the brooter code.
>>
Fuck, I am too dumb to figure out math for part 2
>>
>>103594885
vertical moves first unless I'd hit the hazard zone, but if I have to move towards -x then I'll try to do the horizontal moves first, that way the second robot will be as close as possible to the A when it has to push it
>>
>>103594974
hmm. I see
>>
>have a vague idea of how to do it
>the nesting and preserving last position keeps fucking with my head
bros....
>>
File: file.png (206 KB, 1170x1224)
206 KB
206 KB PNG
idiomatic python solution
>>
>>103594994
very nice
>>
FINALLY DONE
YES
I'm glad we finally got a somewhat difficult puzzle this year
figuring out to go horizontally or vertically first took me forever
then I reused my code from stones and part2 was much easier than part1
>>
>>103594994
>solution
where is find_paths?
where is part 1?
>>
>>103594994
whats with the random *, in shortest_dir args
>>
>>103593460
I'm sorry for not believing
>>
not-so-big bigboy
https://files.catbox.moe/m1alob.txt
part 1: 4349002800
part 2: 5345626233135607200
>>
>>103595105
finishes almost immediately on my unwashed
>>
>>103595105
unwashed
Benchmark 1: ../target/release/aoc-day21 /tmp/bigboy.txt
Time (mean ± σ): 32.2 ms ± 2.8 ms [User: 30.5 ms, System: 1.3 ms]
Range (min … max): 30.1 ms … 45.5 ms 98 runs
>>
>>103595105
I get 4364509200 for part 1
>>
>>103595128
I get the same results as >>103595105
>>
>>103595149
well, I'm right and you are wrong
sry kiddo
>>
>>103595047
boolean trap
>>103595046
im too ashamed to share my hardcoded graphs for the key and directional pads
it's just bfs anyway
>>
>its been 4 hours
I shouldn't have memed so hard about advent of dijkstra. Im such a retard when it comes to memoization.
Clearing my schedule for tomorrow. I will not be filtered and I will NOT read the solutions.
>>
>>103595170
>says it's idiomatic
>is ashamed of it
pick one
>>
>>103595170
>boolean trap
interesting, hadnt seen this before
>>
>>103595047
Every arg after a bare * must be passed by keyword. Similarly, every arg before a bare / must be passed positionally
def func(only_positional, /, either, *, only_by_keyword):
>>
File: xarbon.png (47 KB, 1036x1780)
47 KB
47 KB PNG
unwashed ass, woke up 2 hours later and a rank of 1600 wtf?
How did people shart themselves of this part 2? This is the lowest effort shit ever. Literally added a dp and instantly worked. 8 minutes delta.
>>
I did it thinking form the top down: (>>103594634)
- given a target sequence of letters, the top "presser" wants to optimize the cost (len of its move sequence) to produce the sequence
- for an input of a letter L to occur the very bottom robot has to be at position L and receive an input A
- iterating this statement means the whole "upstream" stack above the bottom robot has to be at A and input A
- this means after the bottom produced a letter of its target sequence all presser positions are at A, except for the bottom one which is at L.
- so at this point all of the state is "synced up".
- this means for the top presser to optimize its move length it can optimize for each target letter individually (since the final state is the same)(Bellman optimality)
- => the cost of the whole sequence is then just the cost of each letter.
- the cost of a letter is the minimum over all possible input sequences to the bottom robot to reach that letter (and press it)
- for a given sequence the cost is the optimal cost for the _second to last robot_ to produce that exact sequence (which is fed to the last robot).
- => we can recurse the problem with 1 layer removed
- the 0 layer case is simple (input is output): the cost for each letter is just 1 => the cost for the whole sequence is it's length.
>>
>>103595149
>>103595164
ok, I was wrong
sry kiddo
>>
This is my absolute worst day so far.
>>
>>103595105
3.1ms with my idiomatic Rust solution >>103594823
>>
Where the problem with my thinking here?
Lets say we have the example of 029A. To input this, we have to move from letter to letter, there might be multiple paths to do so. After each movement we press A to input the letter itself.
This means that all movements do not depend of the movements before, as all is reset anyway when the robot moves to A right? That means can can recursively calculate the subseques of movements idependent of each other, find the minimum for each and sum them up, am I correct with this thinking? Because currently I get 96 for that example.
>>
File: 1383.png (14 KB, 235x233)
14 KB
14 KB PNG
Ok I have to sleep. You win this round Eric.
>>
>puzzle looks cool
>not feeling like doing it because I got filtered on day 19
sad!
>>
>>103595236
thats what it seems like to me but i also havent got the right answer yet
>>
>>103595236
I tried this and something is wrong with this logic but I don't know what. OR I coded it wrong which is very likely.
>>
>>103595236
>>103595248
> After each movement we press A to input the letter itself.
If you go from 2 to 9 via 2 -> 5 -> 8 -> 9, you're not actually pressing A when over 5 or 8.
>>
File: mokou-solving-aoc.png (205 KB, 461x605)
205 KB
205 KB PNG
>>103595244
don't leave me anon. we must suffer together...
>>
>>103595236
>>103595248
>>103595253
oh one thing is that if the path is < < ^
the nested one only needs to move you to < once, then it can press A twice (?)
>>
>>103595236
>>103595248
>>103595253
here's a hint. compare these two inputs after two iterations
                                                                                                                                                ^^<<A     <<^^A
>>
>>103595236
yeah that was my strategy>>103595204
>>
File: 1732626222270498.jpg (50 KB, 836x557)
50 KB
50 KB JPG
>feel like I'm really close to a solution
>just barely not there
Don't give me any hints, just venting a bit. I tried breaking the pattern up into bits of two and then just storing the resulting path ("^^>" would be "^^" and "^>" for example) in a big lookup table for every possible set of two, then each iteration just storing it in a table and incrementing a counter like the pluto pebble one. But it doesn't seem to work correctly... also I've never managed to get the sample data to work no matter what I try. I made sure to prioritize right->up->down->left when generating patterns for my keypad but that doesn't seem to work. It feels like you're not supposed to store this in one big string but if I store it in an unsorted fashion then new groups that get created would introduce other groups depending on the order....

Still wrangling with what the ideal way to store data between iterations because I got spoiled to there being a lot more iterations for p2 so I want to make something that works ground up. Not sure if I should sleep on it or not, will keep banging my head against the wall for a few more hours until an idea pops up.
>>
>>103595236
I didn't even start the puzzle, but from example I think that you can press A separately during input and you only return to A at the end to confirm
maybe you're calculating for each button press number of steps to return the index to A position?
> < to move the arm from A (its initial position) to 0.
> A to push the 0 button.
> ^A to move the arm to the 2 button and push it.
notice that the index stays the same when pressing A for the first time on "0", then only 1 directional key to change index to "2"
>>
> works for 2, like in the first part
> for 25 gives too high
Pain
>>
File: 0915.png (25 KB, 275x323)
25 KB
25 KB PNG
>>103595258
we still have 20 hours. I can't keep multiple layers of abstraction in my brain at once anymore. Which is a big problem for this puzzle. My memoization attempts have all failed. I need to look at it from a new perspective tomorrow.
>>
>go to sleep
>fail to sleep
>wake up
>graft paths onto BFS
>4/5 examples correct
>Eric: actually, it's not good enough to separately optimize the traversal of the keypad and numpad
getting annoyed
>>
Will this be the Great Filter of 2024? Or are we in for an even harder puzzle?
>>
>>103595309
this is probably it, but I finished today quick enough that I wouldn't mind an even more difficult one
>>
>>103595257
What I generate looks like this:
(<) (A) (^) (A) (^^> ^>^ >^^) (A) (vvv) (A)

Each of these subsequences then gets expanded further
>>
File: bqn.png (220 KB, 1316x1332)
220 KB
220 KB PNG
>>103595299
I'm probably filtered so please admire my tombstone, very long BQN for 4/5 examples of part1
>>
>generate permutations to test for efficiency
>finally get it all working
>test 1 pass
>test 2 pass
>test 3 pass
>test 4 pass
>test 5 68 again
FUCK ME.
>>
>>103595329
The bug was, A needs to be part of the movement group:
(<A) (^A) (^^>A ^>^A >^^A) (vvvA)

I tried this before and it didn't make a difference, but I had another bug that needed to be fixed. Now I got my silver star.
>>
>>103595368
sounds like my bug. It's not enough to test for efficiency per-keypad, because equivalent paths become non-equivalent as more indirection's added.
>>
>>103595284
Okay I think I'm figuring it out. Each grouping itself, the order is irrelevant because each group always ends with A and if you expand group by group it doesn't matter... hmmm. I think with some memoization this will work just fine. Still need to figure out why certain inputs are considered "faster" like why the examples use <v<A to go from A to < when it'd be more efficient to do v<<A.
>>
>>103595368
kek it instantly worked for me for both parts
I don't know what on earth you people are doing
>>
>>103595441
>>103594232
>>
>>103595368
the catch is that a non-optimal (or one or many optimal) permutations for the second expansion is optimal for the third expansion
>>
Work for the example but not for the actual input.
Seems there is no options other than to calculate all options and then chose the one with the lowest cost.

I don't want to write this.
>>
>>103595458
thats one way to brute force it
>>
Are the numerical keypad press sequences ever not the shortest paths?
>>
>>103594279
i have been ignoring these because theres no way it can be the shortest sequence right?? or am i wrong
>>
argh what do i memoize for part 2
>>
This is hurting my brain.
>>
how the fuck do i memoize and have branching state at the same time
>>
>>103595458
>Seems there is no options other than to calculate all options and then chose the one with the lowest cost.
I tried to find the actual string and got Out of Memory exception.
Then I implemented the actual solution that only calculates the length of this string... and the answer has 15 digits.
>>
File: 1713406180382764.png (2.57 MB, 1000x2813)
2.57 MB
2.57 MB PNG
washed

Benchmark 1: ../target/release/aoc-day21 /tmp/bigboy.txt
Time (mean ± σ): 19.6 ms ± 1.3 ms [User: 18.1 ms, System: 1.2 ms]
Range (min … max): 18.2 ms … 26.4 ms 150 runs
>>
>>103595550
>>103595585
The parameters for memoization are
codeYouNeedToInput, proxyRobotsLeft

The last input is a completely different grid, so just generate all one-proxy-deep possibilities for it and then run the memoized function on them.
>>
>The Historians are getting nervous; the ship computer doesn't remember whether the missing Historian is trapped in the area containing a giant electromagnet or molten lava. You'll need to make sure that for each of the five codes, you find the shortest sequence of button presses necessary.
>answer to part 2 is 15 digits long
Historianbros...?
>>
>>103595695
yes but then for the codes there are sometimes multiple viable paths to the next button and I don't know how to deal with that.
>>
AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
>>
File: xzibit.jpg (38 KB, 500x500)
38 KB
38 KB JPG
yo, I hear you like keypad
so I gave your keypad a keypad to a keypad
>>
>>103595704
I am sure that my descendants will carry on the tradition of pressing the buttons according to the shortest solution I worked out today.
It will turn into a religion and this tradition will survive for centuries.
>>
>>103595721
WIN
>>
>>103595713
>for the codes there are sometimes multiple viable paths to the next button
You need to choose the path that will have the shortest length after going through remaining (proxyRobotsLeft - 1) robots.
>>
>>103595721
kek
>>
Part 1 took 38 seconds to run.
>>
File: pressthebutton.png (555 KB, 500x747)
555 KB
555 KB PNG
> you will press the button
> you will like it
>>
>>103595852
idk. This is an idea but I think it can be better executed
>>
>>103595852
go back
>>
>>103595852
>reddit & morty
kys
>>
>>103595887
>>103595894
so that is a firm or soft 'no' to that idea?
>>
Page ten emergency bump!
>>
>>103595941
Anon...
>>
>i was using the test input instead of the real input for the past hour
I am going to scream.
>>
>>103595909
firm
>>
File: 1733773653277203.jpg (19 KB, 366x380)
19 KB
19 KB JPG
>>103595299
>BFS
>>
>>103595299
Have you modified your BFS implementation (by effectively turning it into dijkstra)? Did you miss that you there are multiple shortest paths?
>>
File: day21_lut.png (242 KB, 538x2848)
242 KB
242 KB PNG
I solved all possible numpad moves using my recursive solver and recorded all optimal choices along the way. turns out some anons were correct with their heuristic, there is a _depth indepentent_ choice of moves.
there is also always exactly one such move.
this makes teh solution even faster
>>
>>103596037
probably should have split the lut between the two keypad types...
>>
File: cirno-damaged.jpg (3.17 MB, 2756x4040)
3.17 MB
3.17 MB JPG
i'm trying to do something but i ended up with a 5 layer nested tree. i don't know what to do with this...
>>
>>103596078
too many layers for part 1, too few for part 2
>>
I don't even know how to improve this shit.



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