[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: 1733987750302482.jpg (3.35 MB, 4000x3000)
3.35 MB
3.35 MB JPG
pen and paper 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: >>103487465
>>
File: 1733994781419554.png (10 KB, 980x980)
10 KB
10 KB PNG
>>
>>103491900
i'm gonna kys, i wasted too much time on part 2, despite being so simple
>>
File: 2024_12_zig_faster.png (24 KB, 682x979)
24 KB
24 KB PNG
Subjective Zig solution.
>>
>>103491905
we all did bro
>>
Here's an illustration of one of the examples of part 2
https://0x0.st/XFsC.txt
>>
File: A SHRUBBERY.jpg (112 KB, 670x518)
112 KB
112 KB JPG
>>
File: solve.png (889 KB, 5546x4232)
889 KB
889 KB PNG
idiomatic Rust solution
>>
apparently my code is twice as fast using poothon3 than pypy
>>
>>103491933
sleepy rustling. you were slow today.
>>
>>103491946
>sleepy
I'm at work
>>
>>103491954
sleepy at work.
>>
>v1,v2=1,0
>for i in range(8):
>dx,dy=(v1>0)-(v1<0),(v2>0)-(v2<0)
>v1,v2=2**(-1/2)*(v1-v2),2**(-1/2)*(v1+v2)
do mathfags really?
>>
>>103491985
>2**(-1/2)
>>
WHY DOES IT WORK FOR EXAMPLES BUT NOT FOR THE INPUT ERIC YOU NIGGER AAAAH
>>
>>103491985
what am i looking at?
>>
>>103491926
kek
>>
>>103491991
so it's a unit vector
>>
>>103491998
I remember some guy that was bitching about how others were using modulos instead of rotation matrices a few days ago, I imagined he must have written something like that today.
>>
>>103491985
is it just indexing the 8 sides of a square?
>>
Who's eric
>>
>>103492025
AoC creator
>>
>>103492034
whats aoc
>>
>>103492037
AoC creator's creation
>>
>>103492045
thank you anon
>>
>>103492024
Yes, it's a joke.
I was expecting a seething reply from him, but I guess he's already filtered kek
>>
File: bnbnbnvvv.png (40 KB, 797x461)
40 KB
40 KB PNG
are these solve times slow? post solve times
>>
>>103492062
>7 times over 1 hour
filtered
>>
File: zig.png (1.95 MB, 2286x7378)
1.95 MB
1.95 MB PNG
long zig. super dumb flood for part1 and then >>103491832 for part 2.
>>
File: pt.png (24 KB, 481x286)
24 KB
24 KB PNG
>>103492062
Day 9 I had work in the morning that I could not skip :^)
>>
first time this year i got stumped, good puzzle
>>
>>103492072
I like "survey" as a verb, good job zigbro, cool that you are using @Vector(2, isize), I should consider this also.
>>
>>103492062
Sorry you are filtered
Do not log onto AOC again
>>
File: tmp.png (60 KB, 609x347)
60 KB
60 KB PNG
>>103492062
>>
>Every sample is correct for part 2
>Input is too hight
IM NGMI, I have no idea what is wrong
>>
>>103492085
kek what the fuck happened today man, you are crushing me every other day
>>
File: 24_D12_C#.png (1.22 MB, 2372x6666)
1.22 MB
1.22 MB PNG
C#
I'm Kind of surprised this is somehow my fifth highest ranking Part 2
>>
>>103492092
I don't know either. Lots of debugging
I though for a long time the side count is in the first column
Used accidently same variable name twice (very strange bugs)
And didn't want to inflate the grid for a long time because that's ghey, but ended up doing so
I know I'm filtered.
>>
File: Times.png (45 KB, 714x406)
45 KB
45 KB PNG
>>103492062
>>
>>103492112
p2 was hell to debug I just restarted like 20 times
>>
>>103492062
2024    [24/50] stars        48.0%        08:29h         509 minutes, ~21 minutes per star
>>
>>103491966
gottem
>>103491926
lmao
>>103492112
>Used accidently same variable name twice (very strange bugs)
This is why I use zig even though it slows me down I fucking hate that shit. My goal is top 1000 part 2 so your overall doing great.
>>
my P2 is bugged there's no way this isn't the right answer
>>
File: aoc_12.png (264 KB, 2000x1000)
264 KB
264 KB PNG
The great filter
>>
>>103492151
A filter, but not the great one.
>>
File: unifilter.png (4 KB, 204x526)
4 KB
4 KB PNG
competitive programming club got mega filtered today
>>
>>103492172
isn't competitive programming supposed to be competitive?
>>
>>103492172
time to find smarter friends
>>
>>103492177
i don't think most people are necessarily competing, i think they treat them like leetcode dailies
>>
File: day12-mathematica.png (114 KB, 1398x1386)
114 KB
114 KB PNG
Day12 washed.
>Purchase solution
>>
File: d12.png (845 KB, 1506x5586)
845 KB
845 KB PNG
I will not wash my ass and you cannot make me.
>>
>>103492061
I am to stupid to see how this helps you?
Does

XXX
XAX
XXX

become

X_X_X
_____
X_A_X
_____
X_X_X

?
>>
>>103492204
It's interesting to visualise the input data and guess how eric might've generated it. Looks like there are two types of plant groups, one "splotchy" kind placed on top of each other, and another "blocky" kind placed on top of that. A few squares are also sprinkled on top to add random holes.
>>
on the days where i fell asleep and missed the puzzle release i didn't really bother trying to get good time so my average is pretty bad rn
>>
>debugging my program
>trying to figure out how to calculate fences
>the Cs in the first example aren't perfectly rectangular like all the other letters, so I want to focus on them
>want to step through how my program flood fills the C region
>first I step through each location on the map until it gets to a C
>the first line is just "A A A A"
>look at second line, BBCD
>"okay, B... B... C!"
>realization.jpeg
Eric?
>>
>>103492283
I was going to say not to worry because the leaderboard doesn’t matter… but then I saw >24h. Oof, filtered!
>>
>>103492238
more like
>XXXX..
>XXXX..
>XXAA..
>XXAA…
his method for part 2 is: instead of counting SIDES, count CORNERS. the number should be the same

idk what edge cases he encountered, but one consequence of stretching this way is that each square is part of at most one corner
>>
>Part 2 first place is 6 minutes

i thought top competitors would have solutions ready at hand? counting sides of a 2d grid shape doesn't seem like a new problem
>>
filtered by part2, still figuring out the algorithm
>>
File: day12.png (65 KB, 850x561)
65 KB
65 KB PNG
BQN day 12

I think I'm going to try redoing part 2 to not use windows.
>>
File: pepehands.png (397 KB, 985x751)
397 KB
397 KB PNG
>>103491900
>>103487465
>there are anons posting on /g/ who weren't born weren brute force was released
>>
>>103492287
What does the British Broadcasting Company have to do with anything?
>>
>>103492313
count the edges.
>>
>>103492320
>born weren
meant born when
>>
>>103492318
0 0
>>
>>103492267
Speaking of generation, did we get a big boy?
>>
>>103492306
so instead of just checking for a corner where your current plant is different/same than the adjacent squares, you double the size of everything, then do the check anyway, but slightly different?
I feel like I am missing something with the double-the-grid approach.

if you have a corner check for
XXXXX
XAAA
XAAA

(the 1,1 A). You will anyway need the same check if you inflate the grid?
>>
AoC is shit since it allows different languages which have wildly different capabilities.
>>
>>103492334
filtered
>>
>>103492334
just use a language that has good capabilities doe
>>
>>103492329
not yet
>>103492334
skill issue
>>
>>103492143
>he hasn't boughtereded AoC+++ insurance and same-day input replacement
>>
>>103492309
Sure just lemme linear search through my 200000 solutions and double check the code line by line to make sure it's what I'm looking for
>>
File: day12.webm (1.16 MB, 484x484)
1.16 MB
1.16 MB WEBM
day 12 animated
>>
>>103492332
cont.
>but one consequence of stretching this way is that each square is part of at most one corner
If feels like A LOT of work doubling the grid just because you only count a square as 'part of' one corner. that sounds very... not smart.
>>
>>103492143
someone posted their input and answers in the prev thread, you can use that to test.
>>
>>103492334
>Py
>Py
>Py
>Js
>Py
>Py
>Js
>Py
>1 rust fag
>Py
>Py
>Py
>>
>>103492334
Sounds like a skill problem for you.
If I can do problems in assembly, you can do them in whatever language you want.
>>
>>103492352
cool!
>>
File: claude_d12.png (363 KB, 936x1954)
363 KB
363 KB PNG
what do you think of Claude-kun's answer
>>
>>103492334
You’re only competing against yourself, I doubt the asm-chads are aiming for a #1 spot.
>>
>>103492363
>1 rust fag
There are actually at least 3 of us
>>
>>103492373
fags or people using rust?
>>
>>103492332
well this way the condition for being a corner is
>exactly two neighbours are different (or out of bounds)
I guess it’s a bit quicker/cleaner to type this than to check all four different kinds of corner. Just one of those optional little tricks
>>
>>103492383
synonymous expressions retard
>>
File: file.png (18 KB, 620x126)
18 KB
18 KB PNG
>>103492332
if you double the grid cases like

XXX
XAX
AAA

can be treated the same way as

XXX
AAX
AAX

entirely possible that this approach is only needed when your edge counting algo is retarded, but it cut my code down from an abominable 50 loc if else chain to just pic related (nb = horizontal/vertical neighbours, nbd = all neighbours)
>>
>>103492352
Slick.
>>
>>103492406
>exactly two neighbours are different (or out of bounds)
Thats what I did without expanding the grid?
You will also need a "two neighbours are the same and diagonal is different" to find an 'inside' corner.


>>103492419
Hmm ok. I think I see what you are getting at.
Thanks.
Interesting approach.
>>
>>103492334
AoC is great because you can approach it however the fuck you most enjoy
>>
File: carbon(12).png (1.36 MB, 2048x2174)
1.36 MB
1.36 MB PNG
Haskell solution.
Not my best, at least it works.
>>
>>103492419
regarding the expansion.
Does each original square become a 9x9 square in the upscaled map?
>>
bigboy #12
url: https://0x0.st/XFz5.7z
grid: 4096
silver: 1051734590
gold: 653966888
>>
>>103492486
4x4

X
->
XX
XX
>>
>>103492486
or I guess 2x2 can also work
>>
>>103492488
can one of the 3 people who made colour plots, plot the bigboy?
>>
>>103492514
it will not be to cool to see because i used a stupid noise function so you will see patterns reapiting
>>
i fucking brooted it
took like 15 minutes to run
i don't care anymore
Eric finally tongued my anus
>>
>>103492488
Windows defender doesn't like this!
>>
>>103492543
how?
>>
>>103492488
>
https://0x0.st/XFz5.7z

im getting 1085297214,653983272
>>
>>103492553
i blew up the graph 3x, made a copy of it and traced my borders onto it, then iterated over everything again 620 times (my number of plots) counting the number of turns
>>
>>103492570
based
>>
>>103492488
Not sure what you're doing there, but my dfs runs out of RAM.
>>
>>103492494
Um anon-sama what you posted isn't exactly 4x4
>>
Post solution line counts
echo -e "Lines\tFilename"; for f in *; do wc -l $f | sed "s/ /\t/g"; done | sort -h

Mine:
Lines   Filename
13 3.js
16 1.js
33 11.js
39 2.js
40 10.js
41 5.js
50 7.js
53 4.js
62 9.js
70 12.js
72 6.js
74 8.js
>>
File: marisa_crying.png (1.43 MB, 2084x1584)
1.43 MB
1.43 MB PNG
>back home
>try doing aoc
>part 1 done
>read part 2
>mfw
>>
>>103492488
>>103492565
Same.
My runtime is about 10 seconds.
>>
File: give-up.jpg (24 KB, 480x360)
24 KB
24 KB JPG
>>103492599
you can do it anon i believe in you
>>
>>103492587
you are going too deep
>>
>>103492452
>Thats what I did without expanding the grid?
Well, you probably did it 4 times, once for each kind of corner (top-left,bottom-right,etc). But it doesn’t matter much, I did it your way too
>You will also need a "two neighbours are the same and diagonal is different" to find an 'inside' corner.
I’m not sure what this means, distinguishing between the outside and inside corners is a different question that I didn’t solve in my solution
>>
>>103492590
it is indeed not
>>
>>103492595
unwashed solutions
Lines   Filename
56 ./03/main.go
79 ./01/main.go
82 ./02/main.go
90 ./11/main.go
113 ./06/main.go
114 ./05/main.go
119 ./07/main.go
121 ./08/main.go
150 ./10/main.go
167 ./04/main.go
191 ./09/main.go
281 ./12/main.go
>>
>>103492599
It's ok anon it only took me 3 hours
>>
>>103492599
i saw part 2, gave up, shaved using my new sea kelp shaving foam, showered, applied my daily face wash, showered, brushed my teeth, put the kettle on, then solved part 2 listening to classical music
i suggest you do the same, faggot
>>
>>103492363
i use beef
>>
File: 12.jpg (107 KB, 859x732)
107 KB
107 KB JPG
>>103492488
You left a space at the end of every line
>>
File: garden-bigboy.png (2.09 MB, 2048x2048)
2.09 MB
2.09 MB PNG
>>103492514
Here's the top left quadrant. I run into the 4chan size limit for the entire thing, and jpeg will ruin it. 1:1 pixel mapping.
>>
File: IMG_4001.jpg (36 KB, 650x370)
36 KB
36 KB JPG
>>103492628
I prefer Huey Lewis And The News
>>
>>103492636
PS C:\Redacted> Measure-Command { cat .\input.txt | python .\aoc.py | Out-Default }
830516


Days : 0
Hours : 0
Minutes : 12
Seconds : 32
Milliseconds : 852
Ticks : 7528522031
TotalDays : 0.00871356716550926
TotalHours : 0.209125611972222
TotalMinutes : 12.5475367183333
TotalSeconds : 752.8522031
TotalMilliseconds : 752852.2031
>>
>>103492615
>once for each kind of corner (top-left,bottom-right,etc).
correct

>I’m not sure what this means

I just mean for each kind of corner I check two cases
either
XA
AA
right/bot is different than X, so corner, OR
XX
XA
right/bot is same, diagonal right-bot is different, so corner.
I did that for the 4 corner cases, for each square in my plot.
>>
>>103492638
oh neat. ty for the plot
>>
>>103492638
>>103492651
make an autostereogram of a penis please
>>
>>103492636
https://en.wikipedia.org/wiki/Unix2dos
>>
>>103492628
Gay larp
>>
>>103492636
f**k me ahhaha i will clean it for when i put it in the repo
>>
XYXYXYX
YXYXYXY
XYXYXYX
YWNBAW
what did eric mean by this?
>>
>>103492681
That's so odd I never saw this until I tried to solve using rust
>>
for part 2 anyone else expected to reorganize the grid to minimize the cost?
>>
>>103492645
oh I see. you can ignore the diagonal one if you want to, that’s why I was confused
>>
>finally recording day 7 on GBA hardware
>I've broken gold again somehow
What even happened.
>>
>another ez grid problem
>sees part 2
:(
>>
>>103492714
I used my corner test on each square in the plot, not only on 'boundary' squares. But I see If I only check 'boundary' squares then the diag test is not needed.
But I see what you mean now.
>>
>>103492726
floodfill bros we got too cocky
>>
>>103492726
see you next year :)
>>
File: idiomatic_calendar.png (3.13 MB, 9861x4160)
3.13 MB
3.13 MB PNG
>>103492488
559ms using my idiomatic Rust solution >>103491933
>>
File: 1436992421459.jpg (173 KB, 1920x1080)
173 KB
173 KB JPG
>>103492739
Joke's on you, I used my floodfill results to finish part 2.

fn flood_fill(map: &Map<char>, initial: (i32, i32)) -> Region {
let target = map.get(&initial);
let mut area = HashSet::from([initial]);
let mut perimeter = HashSet::new();
let mut work = DIRECTIONS.iter().map(|dt| ((initial.0 + dt.0, initial.1 + dt.1), initial)).collect::<Vec<_>>();

while let Some((pos, from)) = work.pop() {
if map.get(&pos) == target {
if area.insert(pos) {
work.extend(DIRECTIONS.iter().map(|dt| ((pos.0 + dt.0, pos.1 + dt.1), pos)));
}
} else {
perimeter.insert((pos, from));
}
}

Region { label: *target.unwrap(), area, perimeter }
}

fn count_sides(perimeter: &Perimeter) -> usize {
let mut sides = 0;
let mut visited: Perimeter = HashSet::new();

for (pos, from) in perimeter {
if visited.insert((*pos, *from)) {
sides += 1;
let dt = (pos.0 - from.0, pos.1 - from.1);
let walk_dt = (dt.1, dt.0); // flip it around
let mut walk_pos = *pos;
let mut walk_from_pos = *from;
loop {
walk_pos = (walk_pos.0 + walk_dt.0, walk_pos.1 + walk_dt.1);
walk_from_pos = (walk_from_pos.0 + walk_dt.0, walk_from_pos.1 + walk_dt.1);
if perimeter.contains(&(walk_pos, walk_from_pos)) {
visited.insert((walk_pos, walk_from_pos));
} else {
break;
}
}
let walk_dt = (-walk_dt.0, -walk_dt.1); // walk the other direction
let mut walk_pos = *pos;
let mut walk_from_pos = *from;
// same loop copypasted, doesn't fit in message limit
}
}

sides
}
>>
The number of gold seems quite high for this. I suspect many people just give up and cheat from reddit.
>>
>>103492726
>>103492739
just count the corners stupid
>>
>>103492770
you're probably right
it took me hours but i have the horrendous code to prove i didn't copy
>>
>>103492770
that's not fun though
>>
File: bleachglug.gif (57 KB, 240x240)
57 KB
57 KB GIF
>try to rewrite/simplify my code
>it gets longer
oh well i think its better now anyway
>>
File: IMG_2602.jpg (182 KB, 819x1024)
182 KB
182 KB JPG
>>103492771
I just scanned through every possible horizontal line and vertical line and counted how many of them were sides. I did this for each of the k regions, so it only took O(n^2k) time, less than a minute on my raspberry pi 4
>>
>>103492595
dont run this command, it makes mustard gas
>>
give me a smart math solution for part 2

what I did was:
>store positions of fences(x,y,d = direction from which it was recorded) for part 1 as perimeter
>sort these positions by d
>for each direction count the edges based on the distance between them (x or y depending on if its horizontal or vertical)
>>
>>103492775
Of course not, and autists wouldn’t do it, but I suspect as the difficulty ramps up, the willingness to cheat actually increases severely for normies.
>I wasn’t going to solve in myself anyways, so why waste time struggling
>>
>>103492796
see >>103492762
>>
>>103492801
that's your idiotic calendar, it's unreadable for individual parts
either explain or gtfo
>>
>>103492809
>spoonfeed me the solution
filtered
>>
File: 2024-12-12_11-38.png (142 KB, 1288x951)
142 KB
142 KB PNG
corejavabros, I suck at graphs...
almost filtered but eventually found a way; code ugly as shit though, so only get to see the main

>>103492488
dfs->bfs fixed the initial stack overflow, but it's still definitely not finishing without eating up all my RAM (and taking ages), unfortunately

>>103492352
pretty, thanks anon
>>
>>103492352
this is actually an ethnic map of an average balkan state
>>
>>103492739
Floodfill works for part 2, it's hardly any different from the regions. See >>103490542
In the initial floodfill, add any plots just outside the region to a set/list, including the rotation they were found through.
Then in the border set, floodfill anything with a matching rotation to get unique edges.
>>
File: fuck.jpg (153 KB, 990x670)
153 KB
153 KB JPG
>>103492543
>>103492642
are all the other brooters fucking dead after yesterday? am i the last one? that makes me sad
>>
File: file.png (211 KB, 1600x900)
211 KB
211 KB PNG
What an annoying problem. Bigboy took more than a minute and still didn't finish so I gave up on it.
>>
File: Day12.png (204 KB, 1229x1902)
204 KB
204 KB PNG
C#, using a basic edge following algorithm.
>>
>>103492901
unreadable
>>
>>103492919
he has autism
>>
>>103492771
how do you count the corners on holes inside the shapes
>>
>>103492953
well.. if there is a hole, then surely there are corners to check around the hole?
>>
>>103492719
I think I found my problem.
Looks like I failed to remove a store to memory when I was stripping out the frame counter to replace it with a better method of only updating the results when the results change to give more CPU time to the solution, and it was storing whatever happened to be in a register to a memory address that happened to be in another register. Fun.
I'll record the GBA solution running again tomorrow.
>>
>>103492963
I guess its just being able to count a concave corner versus a convex one, that'd probably resolve it
>>
>>103492971
well. you will also encounter concave corners on the 'outside' perimeter. like that E example.
>>
File: literally me.jpg (298 KB, 1600x1100)
298 KB
298 KB JPG
>be me
>trying to figure out how I can count the sides smartly
>make a small example plot and stare at it really hard
>come up with this:

>when considering NORTH sides, I want the leftmost A to count it.
>so if there is no A above you, and no A to the left of you, add 1 to the side count...
>but if there is no A above you, there IS an A to the left of you, BUT there is also an A to the top-left of you, add 1 to the side count.

>extend it for the other three sides
>program it
>mfw it actually works
I feel like an actual genius.

>but anon this is just the shnarklark conjecture, he invented it in 1293, you're over 700 years late to the party
>also there's been fifty posts in the thread about it already
Don't care. I figured it out on my own. I am a god.
>>
File: file.png (79 KB, 1321x724)
79 KB
79 KB PNG
>>103492953
i did it a different way, when you hit one side of the shape (e.g. left), check all other possible positions of that side up and down and store them in a set so you dont count the side multiple times
seemed easier to figure out to me
>>
>>103492488
8.5s meh
>>
>make my shitty solution and get the stars
>read anons in the thread talking about easier ones
>urge to go rewrite my code
maybe tomorrow
>>
File: 1733929002105680.png (162 KB, 552x736)
162 KB
162 KB PNG
why are you not gaming the system.
he already deleted a comment of someone calling him out.
>>
>>103492979
nice. well done.
>>
>>103493023
what do you get for cheating your way onto the leaderboard? anyone knowledgeable enough to be impressed that youre on the leaderboard would know you cheating because its obvious
>>
>>103493019
worse is I think you can solve both p1 and p2 in a single loop over the data by just storing values as you flood fill and now I want to write it but its 4am waaaaah
>>
>>103493032
yes, you can solve it in one pass
>>
File: 1662158225586798.png (49 KB, 280x270)
49 KB
49 KB PNG
>>103493029
>what do you get for cheating your way onto the leaderboard?
you get to brag about it on linkedin obviously, some people in the comments are already congratulating him.
>>
>>103492352
anon did you just post your input?? expect a call from eric's lawyers
>>
>>103493049
its not the lawyers who will bug you. Its a reddit mod who does it for free.
kek.
>>
>>103492979
I read like this
>there is an apple, which is one
>there is an apple, another ONE
>add THIS apple BUT also the another ONE
>two (2)
>mfw it actually works
>I feel like a genius
Good for you I guess
>>
>>103493049
http://0x0.st/XF-z.txt
http://0x0.st/XF-z.txt
http://0x0.st/XF-z.txt
>>
>>103493049
They talk about that $150,000 fine bullshit, but those are not fixed numbers and when they get to talking about damages from posting inputs you'll get to a big fat fucking $0.
There is no monetary damage from posting inputs. If you were to set up a competing competition using those inputs, especially if you get advertising or payments, there would be damages, but not otherwise.
Taking a random using posting their input online to court would only pay lawyers. It would be a waste of everyone's time.
>>
>>103493114
If I post my 0 length input, how big of a fine would that equate to?
>>
File: aoc24_12.png (371 KB, 818x2447)
371 KB
371 KB PNG
idiotic Odin solution
>>
File: code.png (531 KB, 2378x2948)
531 KB
531 KB PNG
Python
>>
>finally a tricky day for LLMs
>check p2 leaderboard
>no bikatr
>no caporalcoder
>no [insert suspected LLM faggot]
as everyone expected
>>
>>103493138
Glad to see you are still with us, Odin-kun
>>
>>103493160
i took ages for part 2 and now everyones gonna think im a cheating poojeet
its over
>>
File: day12.png (51 KB, 934x568)
51 KB
51 KB PNG
Today was comfy.
>>
>>103493181
won't jeets just give up?
>>
>>103493181
dont worry, he was looking at the top100 leader board, so you are still fine.
>>
File: day12.png (50 KB, 834x507)
50 KB
50 KB PNG
>>103492318
Still haven't figured out a better way to do part 2 but I did manage to simplify things a bit.
>>
File: whydowhenyoucandont.jpg (320 KB, 2048x1535)
320 KB
320 KB JPG
>>103493198
Jeets, Chinks and Russians will always cheat when given the opportunity even if they could theoretically do it without.
LLM just flushed a huge number of them into this event, those will be gone, but a few of the remaining cheaters probably can do it if they have to.
In other words, 99.9% of them will give up. One or two will remain.
>>
>>103493246
cute
>>
File: image.png (544 KB, 1191x650)
544 KB
544 KB PNG
my humble BQN solution for day 12. wasted an hour or so debugging my (correct) algo when the actual bug was in my (previously hardcoded) matrix rotations.

kinda slow, takes 4 seconds to complete both parts...
>>
>>103493281
>implying jeets will not copy a solution from reddit when their LLM fails
>>
>>103493435
Just saying there is whole lot of jeets and chinks. Statistically there must be one or two who actually do this out of proper interest.
But other than that, you've got a point.
>>
>>103492488
1min29sec
>>103492565
this
>>
>>103493537
>>103492636
>>
>>103493549
Thanks, looks like that shave 1.5secs off my code.
>>
>>103492488
Optimized my flood fill and got the time down to 17s from 40s. Now most of the time is going to side counting. Maybe I'll try the corner counting method next.
>>
>>103492334
I just skip the puzzles that aren't suited to my lang
>>
>>103493632
nice.
>>
File: Capture.png (80 KB, 1067x316)
80 KB
80 KB PNG
Today seems to be the day.
I get part 2 is tedious as fuck but why only barely 50% have managed part1?
>>
>>103493684
lol wtf how easy was 11 that there are more people?
>>
>>103493684
anon... read it again
>>
>>103493699
11 was basically a slightly harder version of lanternfish, so if you recognize the problem class and get part 1 part 2 is literally instantaneous
>>
>>103493710
you read it. Only 23784 anons have managed to do part1. Of those 13252 did also part2. That is almost half of those who got gold from yesterday.
>>
>>103493682
based knower
>>
>>103493738
more people were filtered yesterday than is shown
after getting frustrated with the problem they copied a solution from reddit
many of which got demotivated and didn't play today
i.e. a filter is lagged by a day or two in which cheaters get bored
>>
>>103493682
what is your lang?
>>
File: day12.png (186 KB, 844x977)
186 KB
186 KB PNG
Figured out the corner strategy while I was taking a shit break.
I need to start using the more idiomatic features of Lisp. I could have used a function variable for get-price-region, for example, instead of just defining two functions.
>>
>>103493684
Probably just the first day where LLMs don't just spit out a largely working solution.
>>
>>103493764
C
>>
>>103493809
If the linux kernel is suited for C I think an AoC puzzle is too.
>>
File: IMG_1688.jpg (53 KB, 720x597)
53 KB
53 KB JPG
>>103493809
>union-find isn’t suited to C
>>
File: aoc2.jpg (157 KB, 898x1200)
157 KB
157 KB JPG
today was quite comfy. not posting code.
>>
>>103493924
you talking about todays puzzle? today was well suited, the ones I skip are map puzzles because I don't feel like reimplementing one for the umpteenth time. also some dynamic container puzzles are too much of a pain in the ass, but I only skip them if the container is more of a requirement rather than part of the solution
>>
>>103493924
How do you solve today with dsu
>>
>>103493984
nta but i assume if you trace the boundary you can "eat" cells by connecting them to the set of eaten cells
>>
>>
>>103494123
woah
the wall
>>
File: codeimage-snippet_12(1).png (412 KB, 872x2356)
412 KB
412 KB PNG
3ms, avoided the broot once again
>>
>>103494233
bigboy?
>>
>>103494233
>editing the input
You didn't beat the aoc.
>>
part 1 jeeted in 14 seconds. it seems part 2 was LLM-resistant.
>>
>>103493809
So are Cniles officially filtered then?
C++ and Rust chuds won.
>>
File: carbon.png (995 KB, 1458x4618)
995 KB
995 KB PNG
>>103492488
Bigboy/day 12 bigboy    time:   [846.43 ms 847.06 ms 847.72 ms]
day 12 time: [652.48 µs 653.61 µs 654.77 µs]

I'm counting the sides by removing entire segments of perimeter - facing outward and removing runs of successive tiles to the left and right.
>>
>>103494287
>7z

txt or gtfo
>>
>>103494233
>>103494410
not idiomatic enough
>>
>>103494300
>you're only allowed to return the input unaltered

```
fn read() -> Matrix {
let mut middle: Matrix = std::fs::read_to_string("input12.txt")
.unwrap()
.lines()
.map(|line| format!(".{line}."))
.map(|line| line.chars().collect())
.collect();
let width: usize = middle[0].len();
let mut top: Vec<Vec<char>> = vec![(0..width).map(|_| '.').collect()];
let mut bottom = top.clone();
top.append(&mut middle);
top.append(&mut bottom);
top
}
```

Cut it because it's irrelevant to the logic of the program, beyond what the comment tells you.
>>
>>103494436
You may pass.
>>
LLMs stopped giving right answers, huh?
>>
>>103494427
nobody cares idioticfag
>>
>>103493938
Based. We're you able to get this neighbour counting idea to work? I tried it for like 45 minutes but had to pivot to something else.
>>
>>103494300
https://paste.ofcode.org/eQeVP8tueJtx6JRGbsEdLy

If anyone's surrendered their computer to the botnet in exchange for bigboy times and wants to try it
>>
File: im-1734018850661.png (78 KB, 534x809)
78 KB
78 KB PNG
fml i spent too much time trying to figure out part 2.
this winter (garden) of my discontent.
>>
>>103493984
union-find lets you figure out which square is in which blob

with this information, you can solve gold and silver in O(n^2) time no problem, and probably still beat the python babby’s
>>
>>103494426
sir, this is a technology board
>>
>>103494541
>he doesn't know about the 7z vulnerability
>>
File: prices.png (37 KB, 949x123)
37 KB
37 KB PNG
what did Eric mean by this?
>>
>>103494541
He's right thoughbeit.
Why the fuck are you using an archive format for a singular textual file? Do you also just blindly unpack archives too?

zstd, xz, lzip, bzip2 and gzip all exist and don't store filesystem like data.
>>
File: im-f50236c22a.png (852 KB, 1024x576)
852 KB
852 KB PNG
>>103494554
something about rejecting modernity. rumor has it that day 25p1 will require you to go out into the woods, kill a wild animal, and bring back proof.
>>
>>103494561
shouldn't be a problem on loonix
>>
>>103494561
> don't store filesystem like data.
wrong
dumb retard
>>
>>103494442
Big if true.
>>
File: aoc2024_g_calendar_12.png (3.91 MB, 3970x2481)
3.91 MB
3.91 MB PNG
redditbob is a placeholder until someone makes something good
find the pokemon added as requested
missing day 10
>>
>>103492595
Slightly washed solutions
Lines   Filename
34 day/10/main.go
48 day/03/main.go
50 day/08/main.go
64 day/01/main.go
64 day/11/main.go
77 day/02/main.go
85 day/04/main.go
95 day/05/main.go
96 day/12/main.go
97 day/06/main.go
127 day/07/main.go
131 day/09/main.go
>>
>>103494593
here is something good >>103492762
>>
>>103494541
You wanna roll the dice on whether one of the various 7z vulnerabilities applies to you? It's a text file, there's no need to compress it. A "big" input is tiny next to watching a 720p video.
>>
>>103494593
Add >>103494554
>>
>>103494596
wtf are u doing in your day 9
>>
>>103494577
The first few times some retard like (You) blatantly stated something wrong I assumed you were legitimately retarded, but now I just assume you're stirring shit like a literal troll.

Either way, kys.
>>
File: aoc-2024-day-12.png (51 KB, 858x1966)
51 KB
51 KB PNG
>>103494455
yes, eventually I figured it out. it's possible to get edge count by combining diagonal and orthogonal neighbors of each plot in a given region.
>>
>>103494593
thank you for keeping it rolling, halfway there
>>
>>103494639
>diagonal neighbours
Fuck I didn't think that would matter. I'll have to redraw it out and figure out why
>>
File: grug_brained_day12.png (537 KB, 1800x2964)
537 KB
537 KB PNG
Was too tired to finish last night. Had to do part two this morning.

My solution is absolutely retarded but it works. I can do better.
>>
File: carbon (2).png (882 KB, 1716x3292)
882 KB
882 KB PNG
> works on every example
> fails on input
life is not daijobu, see you next year anons
>>
>>103494671
you can see how they matter as soon as you start considering L-shaped regions
AA
A.
>>
>>103494603
pass
>>
>>103494603
put your dick away
>>
>tomorrow will be another easy day
Sad
>>
any good answer for part2?
I just store every point along an X or Y intercept based on approached direction and then sort -> check ascending join/split, count.
>>
>>103492488
>>103492565
Same. I'm guessing that bigboy creator is doing something retarded again because it sure as hell ain't me.
0.65 s.
>>
>>103494700
It is hard to see what you are doing but does it work with the EX example?
>>
>>103494700
Without reading your code, try:

ABB
BAA
BAB
>>
>>103494700
>complex()
>real
>imaginary
I am not reading this. why are you using any complex numbers?
>>
>>103494700
for fence in grid[pos]['fences']:
if pos - fence in [1, -1]:
ways['1j'] += [fence]
else:
ways['1'] += [fence]

It seems like it won't work properly for concave corners, i.e. points which will have both vertical and horizontal fence.
>>
File: IMG_4020.jpg (34 KB, 282x120)
34 KB
34 KB JPG
>>103494123
I don’t know what the axes mean, but based Eric
>>
>>103494824
not that anon, but:
Shape: area:1, perimeter:4, sides:4
Shape: area:2, perimeter:6, sides:4
Shape: area:3, perimeter:8, sides:6
Shape: area:2, perimeter:6, sides:4
Shape: area:1, perimeter:4, sides:4


right?
>>
File: day9.png (236 KB, 1920x1075)
236 KB
236 KB PNG
>>103494619
I lost the ability to read that code the second I got the gold star.
Maybe you can figure it out
>>
>>103494853
i had to tongue Erics anus today, but cheers
>>
>>103494857
output looks right, try this input

AAAA
AXXX
AAAA
AXXX
AAAA

this input messed me up because going downwards the two X on the right did not properly cancel the “this is a side” variable
>>
File: tgf.png (789 KB, 2039x2117)
789 KB
789 KB PNG
>>
>>103494700
debug on this:
http://0x0.st/XF-z.txt
p2 = 830516
>>
>>103494788
Btree avoids the need for sorting
>>
>>103494945
is a tree really going to help though? it's still O(n log n), no?

I thought about using a minheap, but desu Rust's heap sucks asshole since you can't just iter() on it because it will return elements in arbitrary order (fucking why?)
>>
Is there a pick/shoelace type formula for the edge count or do you have to broot it?
>>
>>103492488
>perl 12.pl /tmp/bigboy-fixed.txt 112.22s user 1.56s system 99% cpu 1:54.20 total
eh, I can live with this
>>
>>103494974
no. polygons have holes in them and can contain other polygons btfoing shoelace.
>>
File: day-12.png (2.62 MB, 2548x5632)
2.62 MB
2.62 MB PNG
got me both stars
no idea how to make it faster
>>
File: file.png (339 KB, 480x368)
339 KB
339 KB PNG
Checking the corners worked for me in part 2
>>
>>103494964
hmm. looks like BinaryHeap has into_sorted_vec()
>>
File: 1705218855345997.jpg (216 KB, 1024x1024)
216 KB
216 KB JPG
>>103494593
but I have day 10 right here
>>
damn the average person is retarded
>>
>>103494700
BAA
BBA
ABA
AAA
>>
File: day12.png (17 KB, 720x656)
17 KB
17 KB PNG
awksisters where we @
>>
>>103495016
Looks like the performance improvement vs unstable sort is basically non-existent, if it exists at all. Plus or minus like a millisecond at most.
>>
File: file.png (144 KB, 498x351)
144 KB
144 KB PNG
>>103495023
>damn the average person is retarded
>>
>>103494788
I don't know if this is a good answer or not, but what I did was when iterating over the neighbors I also iterate diagonally and get the difference between the current cell position and the neighbor's, and then use that difference to get the the two cells next to the current one that make an L shape, and check if the neighbor is different and both cells are the same, or both are different, then increment the sides counter. Did that make any sense?
>>
>>103495104
yes. I did the same
>>
>>103495104
Yeah that works, there is also a way you can do it without checking corners but my monke brain went with that one.
>>
File: 1733902422865657m.jpg (101 KB, 859x1024)
101 KB
101 KB JPG
>>103491914
KUUUU-WESCHUNS.
Font?
Theme?
Editor?
>>
>>103495104
Gonna need a diagram chief
>>
>>103494964
dumb retard, look up what a heap is.
>>
>>103495043
that's clever
I counted fences in a row instead
it worked but unwashed so won't post
>>
>replaced std::unordered_set with std::vector
>solve twice as fast
data structures are really redundant
>>
File: Capture.png (24 KB, 1007x554)
24 KB
24 KB PNG
>>103495181
Do that check for each corner:
left/top
top/right
right/bot
bot/left

for each cell (or just cells on the border) in one region. That catches all inside/outside corners.
>>
>>103495195
that's a nice solution as well
this was just the first thing that came to mind for me
>>
>>103495292
Is it possible for a small hashset to be less efficient since you have all the overhead of hashing, collision detection etc?
>>
only took 27gb of memory :)

  2024 time ty 12a.ty < bigboy.txt
1085297214
653983272
ty 12a.ty < bigboy.txt 10642.33s user 2347.07s system 90% cpu 3:59:39.17 total
>>
>>103495403
wtf did you do? you growing some oofmatoes in those plots?
>>
>>103495358
yes, in my case cache does better job than fancy big O
>>
>>103491900
I used Heap for day 7 silver to get the combination of operators and it took more than 1 hour to get the result, what tricks or algos can I use to improve my program's performance?
>>
>>103495358
Very much so. Especially if you have a lot of extremely frequent reads, the cost of manually searching for something in a small enough array (which can often be fit inside a single cache line) is small compared to the cost of hashing and the poor cache locality that most hashmap implementations have. Big O is certainly important, but for small inputs it's basically useless as constants will dominate at that level
>>
File: day13.png (92 KB, 864x374)
92 KB
92 KB PNG
>>103491900
AoC++ member here, day 13 leaked early... wtf bros this one looks pretty hard, fuck you eric
>>
>>103495441
What is the solution for this one?
>>
>>103495441
i've only told my male colleagues about my solutions so far
tomorrow i will talk to some foid about them just to spite you
>>
>>103495441
Is this bruteforcable?
>>
>>103495441
But my idiomatic Rust solutions are so beautiful. I think I'll show this cute zoomer intern at work my idiomatic calendar.
>>
>>103495489
Yes, but you will probably end up on the registry
>>
>>103495441
another misleading instruction that isn't covered by example
you'll obviously get cold if you go outside directly after taking shower
either dry yourself or wait for a bit
and don't forget clothes
>>
>>103495441
Easy, I'll just explain my sneed t-shirt to the cashier again.
>>
>>103492638
nice pattern and a good example of why you need a good rng function for serious applications
>>
>>103495522
damn, always with the uncovered edge cases
when will he learn?
>>
>>103492488
TS - 35s
>>
File: 1721391073361093.png (2.31 MB, 1190x2700)
2.31 MB
2.31 MB PNG
>>103492488
1051734590
653966888

real 0m0.554s
user 0m0.534s
sys 0m0.020s
>>
>>103495522
WOOOOW Eric with another dumbass misleading problem. Advent of Constrained Inputs more like. How am I supposed to guess any of this?
>>
>>103493682
i do the same
luckily all of the puzzles have been suited for c thus far
>>
>>103495441
I figured out a quick solution to this.
>start shower
>if shower done, pick up phone and call mom
>discuss your day as you iterate step by step until you have made it from the shower to outside
>>
>>103494551
>he doesn't know it's patched
>he doesn't know whatever he's using has vulnerabilities too
>>
File: file.png (47 KB, 1200x1200)
47 KB
47 KB PNG
All in a day's work
>>
>>103495719
cute!
>>
>>103495719
what do you use for drawing?
>>
File: 78odc9-1037733792.jpg (40 KB, 640x604)
40 KB
40 KB JPG
>>103495441
>part2 is getting a girlfriend
>>
>>103495752
uhhh... brootbros?
>>
>>103495760
just ask out 1000 girls :^)
>>
>>103495741
Krita
>>
>>103495441
Um I can't solve the problems without a test case.
>>
>>103495617
just shower outside with a hose while also on the phone
>>
>>103495781
cool
>>
>>103495183
anon...... are you retarded?
do you know how big O notation works?
heaps are still O(log n) per pop().
BTree's are still O(log n) for insert/find/remove.... so again. how is it better than collecting everything and doing sort? most all modern high performance sorts are resistant to quicksort's O(n^2).
>>
>>103495292
for this problem, ya. really depends what the problem is.
>>
>>103495441
looks impossible chief. I guess I'm filtered.
>>
>>103495691
is it? I can't really get a clear answer on this. p7zip is an old as fuck fork and I'm not a winfaggot so I don't know nor care what winfaggot 7zip does.
>>
https://github.com/p7zip-project/p7zip/issues/240
also
>still open
>no clear guidance from maintainers.
immediately uninstalled this shit after seeing this.

libarchive supports 7zip archives and it has a clear security policy defined and seems to actually be maintained, but I still question why the fuck anyone would use 7zip over tarballs or even regular ass zips. Best I can think of is random offset reads, but I don't know if 7zip has that even. Honestly I'd rather use append only FSes like squashfs or btrfs seeds, but software is always worse is better, especially when it comes to absolute cancer like filesystems.
>>
>>103495770
kek has anyone tried this? what can i expect the average time complexity to be?
>>
>>103495955
Big O(fuck)
>>
>>103495955
25 years to life
>>
>>103495955
worst case is O(N!), best case is 1, but average analysis is too complex.
>>
File: 1648513231249.jpg (76 KB, 1200x600)
76 KB
76 KB JPG
>>103495955
depends on the chosen time/space tradeoff
>>
>>103492488
>spaces at the ends of lines
>>
>>103495441
>solution works on 2d women example
>input has 3d women in it
Looks like I'm filtered
>>
>>103495996
kek
>>
>>103495996
i won't be asking any whales, but i have a 6.2 inch un-jewed penis so i can afford to be "picky"; anyone obese is automatically a 5 or below
>>
>finally get around to improving my atrocious part two
>works on the sample
>works on part 1
>doesn't work on part 2
If I have some time before midnight I try and debug I guess
>>
>>103495760
is consent a requirement?
>>
>>103495955
O(no)
>>
>>103496081 see: >>103494932

>>103496084
it's recommended in the FAQ but Eric doesn't really enforce it
>>
Reminder that 99% of bruteforcers quit before they find the answer.
>>
>>103495522
Yep another useless wall of text by Eric. This isn't a real test of skill. Leetlifers just do this every day and have memorized all of the steps without knowing what they are doing. Meanwhile I had to derive how to put on pants from first principles today. Even though it took me 3 hours my solution is still superior.
>>
>>103495719
THE aocg calender
>>
>>103495719
>he made it past the first filter
Based. Every year, everyone who makes oc seems to get filtered, and only austist are left after day 15.
>>
>>103495510
We're halfway already? damn
>>
>>103495719
why isn't she sitting on the vertical post? redraw this immediately.
>>
>>103496150
This year I'm gonna make it :)
>>
>>103496151
shit didn't mean to reply to you
>>
>>103496151
25 / 2 = 12.5 not 12 RETARD
>>
>>103496174
it's been 12 hours since the problem dropped, so we're half way, faggot
>>
>>103496174
not in integer math
>>
>>103496174
uh no.
$ cat main.go
package main

import "fmt"

func main() {
fmt.Println(25 / 2)
}
$ go run main.go
12
>>
>>103496181
Wrong. We will be halfway 10 minutes after midnight when you solve part 1 (your part 1 solves don't take longer than 10 minutes, right anon?)
>>
>>103496091
I already know what the right answer is supposed to be for my p2. The way I rewrote it, if my p1 is still correct, then I should be capturing all the fence segments, they just don't seem to be getting grouped properly into sides
>>
what could tomorrow's problem be?
>>
Bros.... It's already halfway through.
why is time so short bros?
>>
>>103496245
can you remember more than 6 problems?
>>
>>103496240
float code VM
>>
>>103496280
i already forgot todays problem
>>
>>103496240
repair eric's dragon dildo
>>
>>103496280
that's just one problem per finger on my hand
>>
>>103496280
No. Other than the elephant one because of the meme picture and yesterday's because of le heckin don't blink.
>>
File: day12_better.png (1.38 MB, 1868x6814)
1.38 MB
1.38 MB PNG
Should probably turn my union find into its own class or something. But copy/pasting it four times was easier.
>>
File: costanza.jpg (31 KB, 650x366)
31 KB
31 KB JPG
>>103496280
>he doesn't deallocate unused problems
>>
>>103496191
>The key point here is our programmers are Googlers, they’re not researchers.
>They’re typically, fairly young, fresh out of school, probably learned Java,
>maybe learned C or C++, probably learned Python. They’re not capable of
>understanding floating point numbers, but we want to use them to build good
>software. So, the language that we give them has to be easy for them to
>understand and easy to adopt.
>>
>>103496191
>what is integer division
>>
>>103496150
For what it's worth I did do all of 2023 (albeit with some big hints on part 2 of 21 and 24), I just wasn't as consistent with drawing them. I'll try to stay the course this time around
>>
>>103496350
Welcome to Node.js v20.17.0.
Type ".help" for more information.
> 25//3
25
>>
File: f# day 12 silver.png (56 KB, 937x953)
56 KB
56 KB PNG
Part 1 in F#
Going out tonight forget about doing part 2
>>
File: 1657891222940.png (20 KB, 944x227)
20 KB
20 KB PNG
>it's another works for every single example expect for the actual input episode
>>
File: 12.png (2.45 MB, 1794x6204)
2.45 MB
2.45 MB PNG
Had a really hard time figuring out how to detect sides for Part 2. I moved from looking for sides to looking for corners. I was tinkering with corner detection algorithms till I finally stumbled on one that works. It find the bounding rectangle around the region, then iterate over the region in a 2x2 square. If there is a square with either an odd number of in-region cells, or a "crisscross" match, I increment the corner count by 1 or 2, respectively. The number of sides of the shape is equal to the number of its corners. I was getting worried, though. First time I was feeling there was a chance I might get filtered this year.

Unwashed C++ ass.
>>
>answer too low
I guess it's time for some visual debugging using PPM graphics or whatever
>>
comfy cnile solution,
Iterate over every cell, keep track of two bitmaps - current shape and already visited cells.
If cell not already visited then fill shape from it (also sets the cells as visited) and do part1 and part2 on cells.
Everything is a 2d for-loop. One optimization could be to keep track of bounding box of the shape to not iterate full grid every time.
Area is simple, count set cells in shape.
Perimeter iterates over cells in shape and looks at left, right, top, bottom cell and counts how many are not in shape.
Counting sides is equivalent to counting corners. Iterate over all cells plus one additional column and row (to detect sides at edge) and scan 2x2 window. Count corners that are at the center of 2x2 box.
>>
>>103495926
It's even worse. This project is a fork, the original (used by every distro) is some forsaken unmaintaned pile of shit on sourceforge.
>>
File: unionf.png (526 KB, 1800x2346)
526 KB
526 KB PNG
>>103496319
Because AoC is more fun than working, I did it.
>>
>>103496804
Now I get it. I merge it line by line, left to right. This fails the following example:
XIX
XXX
>>
File: day11_sccs.jpg (1.76 MB, 2000x2513)
1.76 MB
1.76 MB JPG
I really liked day 11.
graph of the strongly connected components of the largest invariant set of stones (labelled by their sizes; total size of the set is 4219)
new comp of size 54 {48, 86, 12144, 96, ...
new comp of size 1709 {1305480, 254446528512, 86688, 233408, ...
new comp of size 3 {80000, 327726080000, 161920000}
new comp of size 3 {15382400000, 31133977600000, 7600000}
new comp of size 3 {34411238400000, 8400000, 17001600000}
new comp of size 3 {22940825600000, 11334400000, 5600000}
new comp of size 3 {37688499200000, 9200000, 18620800000}
new comp of size 3 {12953600000, 26218086400000, 6400000}
new comp of size 3 {14572800000, 7200000, 29495347200000}
new comp of size 3 {8000000, 32772608000000, 16192000000}
new comp of size 3 {10524800000, 21302195200000, 5200000}
new comp of size 3 {17811200000, 8800000, 36049868800000}
new comp of size 3 {24579456000000, 12144000000, 6000000}
new comp of size 3 {39327129600000, 9600000, 19430400000}
new comp of size 3 {27856716800000, 6800000, 13763200000}
>>
Haskell
import Data.Array
import qualified Data.Map as M
import qualified Data.Set as S

data Dir = L | R | U | D

solve g = unzip $ prices $ findRegions 1 g h (indices g)
where h = listArray (bounds g) (repeat 0)

prices g = [ (x * y, x * z) | (i,x) <- M.assocs xs, let y = ys M.! i, let z = zs M.! i ]
where xs = areas g
ys = perimeters isFence g
zs = perimeters isSide g

areas g = M.fromListWith (+) $ zip (elems g) (repeat 1)

perimeters f g = M.fromListWith (+) [ (x,1) | (i,x) <- assocs g, dir <- [L,R,U,D], f g i dir ]

isFence g (r,c) dir = case dir of
L -> c == c0 || x /= g ! (r,c-1)
R -> c == c1 || x /= g ! (r,c+1)
U -> r == r0 || x /= g ! (r-1,c)
D -> r == r1 || x /= g ! (r+1,c)
where x = g ! (r,c)
((r0,c0),(r1,c1)) = bounds g

isSide g (r,c) dir = isFence g (r,c) dir && case dir of
L -> r == r0 || noFence (r-1,c)
R -> r == r1 || noFence (r+1,c)
U -> c == c0 || noFence (r,c-1)
D -> c == c1 || noFence (r,c+1)
where noFence i = x /= g ! i || not (isFence g i dir)
x = g ! (r,c)
((r0,c0),(r1,c1)) = bounds g

findRegions _ _ h [] = h
findRegions i g h (x:xs)
| h ! x == 0 = findRegions (i+1) g h1 xs
| otherwise = findRegions i g h xs
where h1 = h // zip (bfs g S.empty [x]) (repeat i)

bfs _ _ [] = []
bfs g seen (x:xs)
| x `S.member` seen = bfs g seen xs
| otherwise = x : bfs g (x `S.insert` seen) (xs ++ next g x)

next g x@(r,c) = filter valid [(r-1,c),(r,c+1),(r+1,c),(r,c-1)]
where valid y = inRange (bounds g) y && g ! y == g ! x

readGrid xss = listArray ((1,1),(h,w)) $ concat xss
where h = length xss
w = length $ head xss

main = do g <- readGrid . lines <$> readFile "input"
let (xs,ys) = solve g
print $ sum xs
print $ sum ys
>>
>>103495719
100x better than all the elfslop
>>
File: day12unwashed.png (677 KB, 1860x4766)
677 KB
677 KB PNG
Modern C++ (unwashed)
was pretty busy today, so i probably won't wash it
>>
File: aoc_2024_12_b.png (1.42 MB, 2960x4836)
1.42 MB
1.42 MB PNG
It's garbage but it got me the gold start on Part B. Genuinely thought I was going to get filtered today and would have to commit sudoku.
>>
>>103497007
Pretty clean.
>>
>>103496869
this looks like my solution but worse
>>
>>103495885
>is it? I can't really get a clear answer on this.
https://www.youtube.com/watch?v=i5L9xEk_adw
It was in a single version that was available for less than a month. It has been fixed and you probably weren't ever vulnerable.
>>
>>103496869
oh interesting that you just scan corners irrespective of what plot you're on or whatever. i guess that makes sense. i implemented it by checking each perimeter cell in a given region for if it was an inside or outside corner by a similar method.
>>
>>103496960
cool, I solved it
now how do I even begin part2...
>>
>>103497194
jesus christ
>>
I've got a job interview/code test tomorrow. What algorithms do I need to brush up on? It's a mid-level dev position. Will doing AOC help?
>>
>>103494123
I'm going to be the sperm that makes it.
>>
>>103497238
Don't take the video title too seriously. The "1000s of crashes" was the vulnerable version and they were all in the vulnerable code.
>>
>>103497340
not a professional programmer, got 21 stars by now, all silvers and most golds
Pick any day if you can’t solve the first part easily you’re most likely not ready for a mid level position unless you’re pretty good at bullshitting your way through things
You’re not going to learn anything in a day but it should give you some reassurance if you can breeze through them
>>
File: aoc2412rs.png (1.43 MB, 1037x7798)
1.43 MB
1.43 MB PNG
>>103492488
C, 0.714 s
>>
>>103497366
I've got 50 stars (without cheating) every year I've participated, so I'll take that as a plus.
>>
>>103497382
Then if that’s not enough for a mid tier position I don’t know what is
>>
>>103497359
ya I know. but I'm surprised there are like a gorillian forks of this codebase and after shit like xz, I'd hope critical shitware like 7-zip would be a part of OSS-Fuzz
>>
File: 1731887884953716.png (72 KB, 889x913)
72 KB
72 KB PNG
fucking hell I finally did it
today was hell
I still have no idea how to iterate while modifying an array in this shitlang so I had to reset my visited array for EVERY NODE
this was the worst broot so far, and for something that I could easily fix in any other lang
sad! you hate to see it!
>>
File: day12clojure.png (1.51 MB, 988x989)
1.51 MB
1.51 MB PNG
washed my clojure a little.
where are the other clojure posters?
>>
>>103497357
I'm not gonna make it
>>
>>103497502
>-23%
OH NO NO NO NO NO NO
>>
>>103497502
Is this the rejects leaderboard? HiggstonRainbird is #3 here but #7 on the main one
>>
>>103497544
it's not in order IIRC
>>
File: Capture.png (92 KB, 1167x304)
92 KB
92 KB PNG
It is getting better but yes today was the great filter.
>>
>>103497468
I'm with you on the "today was hell" part. Please just give us a graph tomorrow, Eric. Have us find cycles or something. I actually know algorithms to do that.
>>
>>103497547
Oh, then what do the wavy lines mean? I thought they were everyone's place on each day
>>
>>103497227
I solved it.
I'm completely ashmed of my solution.
>>
File: bueno.jpg (13 KB, 223x226)
13 KB
13 KB JPG
>>103497570
post it, gore is my fetish
>>
>>103497570
expanding the grid ?
>>103497595
based
>>
>>103497555
can you post the bookmarklet
>>
>>103497601
1. parse input as slabs of height 1
2. collect adjacent slabs into a region
3. find min,max x,y and create a bitset
4. count set bits as area
5. count edges as faces

inefficent. basically streamlining the naive thought chain. no steps back to reconsider the approach.
>>
>>103497608
I got it from another anon and added a few things.

pastebin<Dot>com/cNFnY0S6
>>
>>103492565
there is a space at the end of every line...



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