[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: 1707473407124735.png (83 KB, 1200x1200)
83 KB
83 KB PNG
>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: >>103491900
>>
File: idiomatictrash.jpg (280 KB, 800x1137)
280 KB
280 KB JPG
>>
File: day12clojure.png (1.51 MB, 988x989)
1.51 MB
1.51 MB PNG
Still waiting for the other 3 Clojure posters. I'm not willing to believe you've all been filtered yet.
>>
> 30 minutes without a thread
The aoc... is dead.
>>
File: 1714463998514980.jpg (113 KB, 1080x1024)
113 KB
113 KB JPG
>It's another "test input works but real input doesn't" day
can someone supply me with inputs to compare?
>>
File: tgf.png (796 KB, 2039x2117)
796 KB
796 KB PNG
>>
File: day12_parallel.png (210 KB, 825x1919)
210 KB
210 KB PNG
>>103492488
bigboy parallelized. 200ms
 time ../target/release/aoc_2024 <bb_good.txt
day12 result:(1051734590, 653966888)
../target/release/aoc_2024 < bb_good.txt 1.75s user 0.03s system 830% cpu 0.215 total
>>
>>103497985
The EX and AB grids in the example are enough.
>>
import sys
sys.setrecursionlimit(10**6)

t-the ends justify the means...
>>
>>103497999
>Half the herd culled halfway through
Is this the normal dropout rate?
>>
>>103498049
What are you recursing? The flood algorithm?
>>
>>103498075
A function to figure out if a neighbor is inside or outside the garden. Its terrible and very fragile but somehow works.
>>
>>103498057
more or less
>>
>>103498096
You can use a flood fill algorithm (queue based instead of recursion) for that.
>>
>>103498039
Would have been filtered if the AB grid wasn't provided. A rare case where Eric actually gave out the edge case for free.
>>
So today filtered the LLMs? wtf is going on in the leaderboard?
>>
>>103498143
Nice, maybe I'll rewrite later today to have a clean implementation.
>>
>>103498096
>>103498143
+ you don't even have to change your current algorithm. Where you currently recurse, stick the arguments in a queue. Put the whole thing in a loop that runs until the queue is empty. Bing bada boom
>>
>>103498184
And to avoid the stack overflow on the 1000 x 1000 grid!
>>
File: day12.png (24 KB, 424x345)
24 KB
24 KB PNG
>mfw LLMs got filtered
>>
File: 1734045315915.jpg (326 KB, 3192x468)
326 KB
326 KB JPG
This guy is actually pretty based if he makes it to day25 with all silvers. I don't remember anyone ever doing that before.
>>
>>103498174
Separating the men (and women with dicks if you use Rust) from the boys.
>>
>tfw you're a rustanon and would 100% become a woman if it was possible

Can you stop with this meme it's hitting too close to home
>>
>>103497960
Found sauce and her ass is tragic, actually hotter like this
>>
>>103498096
You don't need to know that at all. Every side is between two corners, and every corner has two sides. Just count corners, there are always as many corners as there are sides.
>>
File: 1712923225404741.png (39 KB, 628x1892)
39 KB
39 KB PNG
>>103498039
Thanks, anon. I didn't realize those were gonna be that big a problem.
>>
anyone got the solution for part 2 of 2015 day 12
>>
File: 1713969074405188.png (502 KB, 1000x534)
502 KB
502 KB PNG
>>103498284
same ive been wishing i was a woman every day for the past decade but alas nothing
wish i hadnt spent my youth doing coding challenges and just took estrogen.. maybe if i had started at 10...
>>
File: twelve.png (1.18 MB, 1262x6702)
1.18 MB
1.18 MB PNG
[input12] Part 1 1483212         24.847ms
[input12] Part 2 897062 25.221ms

Corners almost had me filtered.
>>
>>103498479
why do you feel the need to "become" a women, you can be a guy and act very feminine and be gay, i think wanting to become a women is an attention whore thing
>>
>>103498513
Truth nuke
>>
File: aoc2024-10.png (622 KB, 899x613)
622 KB
622 KB PNG
>>103494593
Here's day 10
>>
>>103498513
why do trannies occupy your mind like this
>>
File: 1704373375130509.png (478 KB, 850x654)
478 KB
478 KB PNG
>>103498513
>>103498561
i am a faggy feminine gay guy
its awful
trying to be feminine as a man is an uphill battle where the reward for winning is just people thinking youre immature and weird
more than that i just feel like my whole upbringing got thrown in the trash for being a faggy kid and i really just wish it had been different, ive always hated not being straight
>>
>>103498683
go back in time and tell your dad not to molest you
>>
I’m calling Eric to see if he’d be OK releasing the next one a bit early to keep the thread within topic
>>
>>103498479
That's the most boring and shittiest anime ever created
Started watching the first episide late in the night and unironically fell asleep during
Couldn't get me to start E2, anyone who finished it is mentally retarded
>>
Hmm. Tried counting corners and it doesn't seem to work. On some simple shapes I draw on my whiteboard, it seems to work. I'm just sticking with my line segments method.
>>
File: aoc15-12.png (258 KB, 1920x1039)
258 KB
258 KB PNG
>>103498466
I have but it's written in Forth and it just uses a json library
>>
>>103498729
I did a line segments thing and it worked on the first try so clearly the superior approach
>>
File: 1721481109293145.png (1.15 MB, 869x1258)
1.15 MB
1.15 MB PNG
>>103498727
i havent actually watched it (though i did read a bit of the manga)
im more of a boku girl/wandering son tranny myself
god i remember crying so hard at these comics as a kid
>>
>>103498788
I don't get this and will never get this but whatever. This might be the result of childhood traumas.
Men are the dominating sex and are superior, couldn't pay me to become a woman.
>>
>>103492488
I switched my dfs to a bfs, but I still had to kill it when 32Gb of RAM + 16Gb of swap was used up at the 18.83 mins mark.
>>
>>103499162
You don't say you fucking retard. Flood fill bfs uses much much more memory.
>>
>>103499182
I switched because my dfs also ran out of RAM and/or hit the recursion limit. It can't be helped.
>>
>>
>>103499190
ulimit -s unlimited
or do it manually with stacks wihch are reserved in the heap
>>
>>103492488
".\bin\Release\day12.exe" "bigboy.txt"
1085297214
652287968
58032.2ms

Produces the correct answers for my real input though
>>
File: file.png (52 KB, 1239x342)
52 KB
52 KB PNG
>top guy on the leaderboard, who is obviously blatantly using LLMs, posts on other peoples github asking them not to use LLM
lmao how shameless can you get
>>
>>103499223
>some of us
well he didn't say he specifically
he should be banned from life
this is a nigger who bleached his skin
>>
>>103499223
>Is nowhere on day 12 leaderboard.
Kek. Ya he was LLMing.
>>
File: aoc-2024-day-12-fast.png (47 KB, 844x1791)
47 KB
47 KB PNG
combined both parts into one
single thread, can't be bothered with mmap
$ time ./day12 < input.txt
Silver: 1494342
Gold: 893676

real 0m0.014s
user 0m0.000s
sys 0m0.000s

$ time ./day12 < bigboy.txt
Silver: 1085297214
Gold: 653983272

real 0m0.625s
user 0m0.000s
sys 0m0.000s
>>
I'm doing year 2019. is there a list of intcode only days? Also how do I organize my intcode? It is pretty harrowing it is some self modifying code shit.
>>
>>103499273
Nevermind.
https://esolangs.org/wiki/Intcode
>on days 2, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23 and 25.
>>
>>103499273
2 5 7 9 11 13 15 15 17 19 21 23 25
>>
>>103496995
That’s neat. Playing around with Day11 a bit myself to see if I notice anything interesting.
>>
File: aoc12.png (285 KB, 1280x2669)
285 KB
285 KB PNG
n-nope
part 2 has me filtered today
I cant figure this out before bed and new showtime
>>
>>103499413
kek
filtered
>>
>>103499413
Fortran is down… sad. We need a filter list of all the languages being used.
>>
My backup plan for Part 2 was going to be spending my work day manually outlining and counting each side by hand. Luckily such a thing was not necessary, but it would be preferable to getting filtered.
>>
unless...
>>
>>103499413
Anon, it pains me to say this but, you were filtered.
Now get the fuck out.
>>
>people giving up when theres still a solid 3 hours to not get filtered
baka
>>
File: carbon.png (1.24 MB, 1932x9640)
1.24 MB
1.24 MB PNG
>>103492488
This one was fun
Used a lookup table to map the surrounding 8 points to the number of corners that each point contributes to its region
Parallelized by having each thread count regions which have a maximum row in its chunk
Ran into some interesting behavior where padding the grid so that every adjacent cell is valid memory improved performance, because even though there's already bounds checking to avoid computing unnecessary perimeters and corners, speculative memory access means its faster to have valid memory there even though those branches can never be taken
Time (mean ± σ):      49.0 ms ±   1.3 ms    [User: 707.4 ms, System: 89.1 ms]
Range (min … max): 47.1 ms … 54.0 ms 63 runs
>>
I have stuff to do tomorrow otherwise I would
>>
>>103499569
>speculative memory access means its faster to have valid memory there even though those branches can never be taken
woah, that's actually pretty neat
>>
>>103499574
Would do what anon? She's literally 10.
>>
>>103499599
Out of 10!
>>
I mean I have some vague idea about how I would go forth trying to solve part 2 but it would take at least an hour and I bet I would struggle with handling holes inside plots for another hour
so I take the filter to preserve my healthy sleep
>>
I implemented like 3 different approaches that work on every test case except the actual input. Fuck this part 2.
>>
File: xarbon.png (17 KB, 716x756)
17 KB
17 KB PNG
retarded code, don't care
It's still O(n*m) and at least short
>>
>>103499771
ugly
>>
>>103499771
>compact python
>>
>>103499836
Thank you!
>>103499851
Yeah I know it's a bit long. Do you have a shorter one?
>>
File: yza8p5b4ig661.jpg (19 KB, 480x316)
19 KB
19 KB JPG
>>103499206
>took so long implementing a simple flood fill for part 1 that I solved part 2 in, like, 5 minutes
>>
>>103499771
>terminus font
>pure c image generator
I kneel
>>
File: carbon-16.png (572 KB, 1364x3162)
572 KB
572 KB PNG
Part 2 almost got me. This edge case was particularly demoralizing:
AAAAAA
AAABBA
AAABBA
ABBAAA
ABBAAA
AAAAAA
>>
File: aocp.png (2.66 MB, 9781x3115)
2.66 MB
2.66 MB PNG
aktualisierter Kalender
(ich weiß dass er allem egal ist)
>>
>>103499975
Cost me an hour
>>
>>103499223
Bring back ginger hate.
>>
>>103499437
Kek I wish you didn't solve it because that would be very funny to see.
>>
File: 1716152530017531.png (1.04 MB, 867x1053)
1.04 MB
1.04 MB PNG
>>103497970
Not filtered, just busy.

Not planning to do any more puzzles this year, though.
Today is when it started to feel like a drudgery for me.

If I write any more AoC-related code this year, it'll just be some visualizations in my Flutter app.
>>
>>103498258
maybe he's just in it for the story
>>
>>103499223
>physinognomy isn't re-
>>
LLMnigger holocaust when? Today was a start but not nearly harsh enough.
>>
File: aoc_2024_12.png (152 KB, 1024x1684)
152 KB
152 KB PNG
Perl. I sure could get rid of bfs with some clever remapping of sections encountered during sequential scan, and do everything as I read the array, but catching all corner cases will take another 40 minutes probably. I'll try to get back to it later though.
>>
the trannytalkfagretard shit doesnt wanma make me to participate anymore
>>
>>103500282
A new cope just dropped. You could always just fuckoff to reddit and be happy.
>>
>>103500282
Good morning sir
>>
Filtered.
>>
>>103499413
>>103499574
>>103499644
>>103499735
>>103500135
>>103500282
Filtered.
>>
>>103500135
I'll see you tomorrow, anon.
>>
>>103500282
cute. filtered.
>>
>>103500282
this is a new one
>>
>>103500315
Jokes on you. Found and fixed the missing edge case. Still not filtered.
>>
>>103500373
Good for you.
>>
>>103500373
Bullying strengthens us all anon, glad you beat the filter.
>>
dumb frogposter
>>
>>103500373
Unfiltered.
>>
Phew! Made it!
>>
>>103498174
People massively overcomplicating perimeter calculations
>>
>>103500428
>massively over complicating (ie. they didn't cheat by looking in this thread beforehand like I did)
>>
How is this the filter? Its just 2d grid traversal.
>>
>>103500513
Part 1 is indeed trivial
>>
File: 1705324238389180.png (57 KB, 564x542)
57 KB
57 KB PNG
>Edge count is the sum of the absolute values of the convolution with [[-1,1],[1,-1]]
>Perimeter is the sum of the absolute values of the convolutions with [-1,1] and [[-1,1]]
>>
>>103500513
95% of "programmers" could not develop a flood fill with a gun to their head.
>>
>>103500513
Because most people are not competitive programmers but webshitter software "engineer" wagecucks
>>
>>103500530
Part 2 isn't trivial, I'm just surprised this is it. I struggled more with the DP yesterday.
>>
>>103500535
>>103500536
I'm a webshitter wagecuck and I dont know what a flowfill is, I just iterated left/right or up/down on every edge and put the coords in a set
>>
>>103500568
kek this has to be bait
>>
>>103500535
can confirm, "programmer" and it took me so long to do part 1 that part 2 was trivial
>>
THE BIGGER FILTER IS COMING
>>
>>103500584
when it rains it pours babyyyyyyyyyy
>>
File: Screenshot.png (212 KB, 945x1422)
212 KB
212 KB PNG
>>103492488
late to the party
~400ms in C
>>
>>103500573
its not
>>
File: file.png (3 KB, 517x41)
3 KB
3 KB PNG
>>103492488
well ive never seen that error
>>
File: loli-sunglasses.png (813 KB, 899x899)
813 KB
813 KB PNG
game simulation today
>>
File: carbon.png (624 KB, 2022x2624)
624 KB
624 KB PNG
Managed to do it sequentially. Doesn't work on the bigboy though. Fuck I wish edge cases didn't exist
>>
>>103500600
flood fill is just graph component traversal algorithm but for gridgraphs
>>
good morning /aocg/
>>
>>103500584
I need to shit.
>>
>>103497999
What does the graph mean?
>>
FUUUCKKK I REALLY NEED TO SLEEEPP AAAAAAA
>>
>>103500645
This is the last day that can possibly filter me as I am on vacation after tomorrow. I hope its an easy one
>>
I pray that eric fucks that bikarscum is the ass today as well
>>
>only 12:73 left before puzzle drops
>>
10 MINUTES
>>
>>103498466
aah ahaha I remember that piece of shit question. in python, you can do
>import sys
>import json
>foo = json.loads(sys.stdin.readline())
and now you have a suitable data structure, all ready to go
>>
resource management game today.
>>
>>103500631
fuck you
>>
come on eric gimme an easy one today please
>>
>>103500631
Good morning, Good evening Saar
>>
I'm gonna level up today.
>>
With each day the idea of using my company's cluster during off-work hours to BROOOT AOC sounds more and more tempting. They don't check the dashboards anyways, unless it dies, and it has a lot of cores and RAM.
>>
>>103498466
const inputObj = JSON.parse(input);

const sumWithoutRed = (obj) => {
if (typeof obj === "number") return obj;
if (typeof obj === "string") return 0;
if (Array.isArray(obj)) return obj.reduce((a, b) => a + sumWithoutRed(b), 0);
if (typeof obj === "object") {
if (Object.values(obj).includes("red")) return 0;
return Object.values(obj).reduce((a, b) => a + sumWithoutRed(b), 0);
}
};

console.log(sumWithoutRed(inputObj));
>>
>>103500712
it wouldn't matter. probably from now own, any bruteforce will take until the heatdeath of the universe ( or like a year )
>>
>>103500712
>I was stress testing an optimization setting.
>I was exploring a new computation model
>>
Please no more grid problems. Give us something math related, Eric.
>>
>>103500712
Or you could just write a better algorithm?
>>
>>103500721
>I was watching pornography
>>
File: showtime.jpg (46 KB, 640x480)
46 KB
46 KB JPG
https://www.youtube.com/watch?v=hjGZLnja1o8
>>
>>103500729
cancer music
>>
File: FUCK.png (634 KB, 550x742)
634 KB
634 KB PNG
Alt theme
https://www.youtube.com/watch?v=BrUuKehpGuQ
>>
>>103500723
mathnerds lost
programming is for mathlets
>>
File: science.png (170 KB, 974x998)
170 KB
170 KB PNG
>>103500720
>heatdeath of the universe
>>
>>103500729
great music
>>
File: Untitled.png (219 KB, 1758x745)
219 KB
219 KB PNG
>7 minutes before puzzle release
>decides to google him and click on all the links (picrel)
>status: online
I have a theory as to why he's skipping days
>>
>>103500723
yesterday WAS math bro
>>
>5 minutes left
>I want to shit
>Food is going to be delivered in 8 minutes
AAAAAAA
>>
File: showtime-frog.png (468 KB, 1858x1829)
468 KB
468 KB PNG
>>103500729
we rollin
>>
>>103500712
broot the stones, you will be a legend
>>
>>103500723
Don't tell us you jinxed it and now we get an "Advent of Math" problem where you either know the formula or you can fuck off
>>
>>103500729
SHOWTIME
>>
>>103500729
its showtime
>>
>>103500746
>or you can fuck off
or you can derive it
>>
Tonight's probably the last night I do them on release instead of waiting for the morning after. My sleep schedule is completely trashed at this point. Not healthy. Recommend others join me. Fuck the leaderboard.
>>
>>103500739
> I have a theory
> walk away and do not elaborate
>>
I've been putting on https://www.youtube.com/watch?v=wFmOwP0UW6E to synchronize with the last 5 minutes lately.
>>
>>103500723
And by math related, please be an easy solved problem so that we can look "smart" by solving it quickly while laughing at those who simply just haven't seen it before.
>>
File: mokou-showtime.jpg (130 KB, 440x518)
130 KB
130 KB JPG
>>
friday the 13th
were having the greatest filter of all time today, calling it
>>
>>103500756
I agree. Everyone in the top 20 should really think about their health and get some sleep
>>
> hands status: washed

I am ready
>>
File: mokou-rope.jpg (49 KB, 462x516)
49 KB
49 KB JPG
>>103500760
THANK YOU MOKOU
>>
>>103500769
>tea status: brewed

I am ready
>>
>>103500763
I'm the first and I usually sleep from 17 pm to midnight local time
>>
another easy problem today
>>
>>103500769
>ass status: unwashed
I am ready
>>
>>103497970
who were the other clojure posters?
>>
less than one minute
>>
>>103500774
>17 pm to midnight local time

Get some sleep bud
>>
FUCK
>>
FUCK
>>
FUCK
>>
FUCK
>>
I prefer the company of men
>>
FUCK
>>
advent of parsing
>>
Nope, see you in 8 hours
>>
>>103500799
Seems there are no -XX and the order is always the same. Only parsing you need to do is extracting the digits.
>>
intercepts huh
>>
>You estimate that each button would need to be pressed no more than 100 times to win a prize. How else would someone be expected to play?

advent of handholding
>>
matrix multiplication but fuckme if I know how to do that in python
>>
>it's a korean modulo hypothesis day
GG mathchuds
>>
uhhh brootbros???
>>
OH GOD I'M GONNA BROOT
>>
>probably 30 minutes from solving day 12 but have a minor bug throwing off my vertex map
>look at today's problem
>looks annoying
>since I'm filtered I'm under no obligation to do it tonight
I feel so free suddenly
>>
>Bikatr7 nowhere to be seen
as expected
>>
BROOTCHADS WE ARE SO BACK
>>
File: 1562883822172.jpg (25 KB, 483x500)
25 KB
25 KB JPG
>part 2
another one of these days
>>
fucking math
>>
>part 1 right for example but wrong for input
>won't even tell me if it's too high or too low
>>
>>103500852
BROOTING IS BACK ON THE MENU BOYS
time to make some kawfee
>>
FUCK I DIDN"T READ THAT NOT EVERY GAME IS POSSIBLE
>>
>>103500910
no you aint lmao read part 2
>>
My broot never finishes even for a single machine on part 1
>>
>the example answer for part 2 isn't given
FFS
>>
fuck floating point
>>
File: day13-mathematica.png (47 KB, 1426x634)
47 KB
47 KB PNG
Best of luck lads.
>>
MATHBROS
WE WON
>>
File: 1731603152598587.png (106 KB, 926x1188)
106 KB
106 KB PNG
>>
>>103500967
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
13 00:26:15 2817 0 00:27:17 899 0
>>
File: 1734067799509.jpg (3.55 MB, 4000x3000)
3.55 MB
3.55 MB JPG
Easy day. Advent of math. Why even bother posting code today
>>
I have more lines of code to parse the input than to actually solve the problem
>>
Can anyone compute the sample's result for today?
>>
File: shoot_2024-12-13_00:31:46.png (313 KB, 1425x1713)
313 KB
313 KB PNG
>>103500987
here it is though. also
>mathletsbtfo got bronze today
living up to your name gz.
>>
>>103500994
875318608908
>>
>>103501008
Cheers anon.
>>
Is there an edge case? My input doesn't work, this seemed pretty straight forward, too.
>>
Mathchads won, laughing at brootfags
>>
I hate vectors
>>
>only 14 solves so far
I am actually disappointed in you /aocg/
>>
>>103501042
I don't wanna do gay math questions
>>
File: carbon-2.png (67 KB, 1524x456)
67 KB
67 KB PNG
LOOKS LIKE SLOUCH IS BACK ON THE MENU BOYS
>>
>>103501049
Its 2 equations 2 unknowns you do this shit in elementary school
>>
File: img-2024-12-13-06-39-49.png (144 KB, 1544x936)
144 KB
144 KB PNG
idiomatic Rust solution
>>
File: xarbon.png (21 KB, 540x948)
21 KB
21 KB PNG
today was boring
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
13 00:13:47 1082 0 00:37:18 1449 0
>>
>>103501055
there's nothing fun or interesting about it
>>
I tried to do a clever trick but it does give me a wrong answer, and bruteforce will probably be killed in part 2. I'm going to have to implement cramer's rule aren't I?
>>
>>103501066
Thats because its trivial. You are an actual 80 iq retard if you cant solve it in 5 minutes and you should feel bad about it.
>>
File: evil-crying-on-floor.jpg (863 KB, 2000x2000)
863 KB
863 KB JPG
>fumble around parsing bug and manage to get part 1 done
>read part 2
it's so fucking over bros...
>>
>oh, optimization problem, cool
>it has unique solution
come on Eric
>>
>>103501068
extremely midwit coded post
>>
File: 1721414851970584.png (3.04 MB, 1378x3112)
3.04 MB
3.04 MB PNG
unwashed, solved it on paper
>>
>>103501095
nobody wants to do gay ass math problems
>>
I DONT KNOW MATH
>>
File: 1722346526843189.png (3.04 MB, 1378x3112)
3.04 MB
3.04 MB PNG
>>103501115
actually I just realized that I forgot to check for negative solutions but it didn't matter for the input cases
>>
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
13 00:09:46 577 0 00:53:01 2378 0

Brutebros... it's over.
>>
>You don't need a computer science background to participate - just a little programming knowledge and some problem solving skills will get you pretty far.
How does a brainlet like me get past part 2 today?
>>
File: sbv-z3.png (27 KB, 622x576)
27 KB
27 KB PNG
I'm filtered by yesterday's part 2 so today I import solution.
>>
>Wanted first top 1000 time
>Solved a test case by hand for no reason to test my math instead of just programming it
FUCK
>>
File: carbon (1).png (274 KB, 1550x1208)
274 KB
274 KB PNG
I tried to be funny with scipy.minimize but ran into scaling issues on part2 and spent too long trying to fix them. It's a pretty simple problem though. Ideally you would do the same thing with sympy to get exact integers without tolerance problems
>>
>>103501123
>>103501118
>>103501049
>>103501035
>>103500987
This retards are still doing math in the year of the lord 2024 when you can just throw everything into a SAT solver and cross your fingers.
>>
>>103501154
doesnt count
>>
>>103500952
bruh it says explicitly “no more than 100 presses per button”
>>
>>103501128
I am SHOCKED there wasn't a floating point error edge case. I was fully prepared for my math to not work
>>
>>103501144
it's literally high school math
>>
>>103501154
If you don't post your math itt, youve just been filtered. here' s mine >>103500987
>>
File: file.png (15 KB, 452x217)
15 KB
15 KB PNG
where am I going wrong???
>>
>>103501115
whats tgat, the Euclidean algorithm?
>>
>>103501100
>it has unique solution
That should have been immediately obvious. You're finding the intersection of two straight lines.
>>
So how exactly do you derive the formula for this?
>>
Part 2 filters me... It's over...
>>
>>103501182
yes but when you first start reading the problem it sounds like it's going to be more difficult
>>
>>103501167
This is not math, rather kindergarten algebra shitting but here >>103501062
>>103501182
>intersecting
No, they can be parallel, that's why it says to ignore when there's no solution.
It doesn't say anywhere these lines cannot be the same.
Also they are not even lines because you can press these buttons only integer times. It's not continous.
>>
File: carbon(57).png (381 KB, 1302x1914)
381 KB
381 KB PNG
Spent some time not knowing I have to use matmul.
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
13 00:25:28 2710 0 01:00:49 2852 0
>>
>>103501194
>No, they can be parallel
Fuck off, I know
>>
Miss me with that smelly math nerd shit.
>>
>>103501186
Make equation for the prize x and prize y based on a presses and b presses. You now have 2 equations and 2 unknowns. Solve for a and b.
>>
>>103500987
Your denominator could have been zero. For example A moves 7,7, B moves 2,2 and the goal is 51,51.
>>
I spent 40 minutes thinking there could be multiple combinations and you have to find the cheapest one before I realized there's 2 equations and 2 unknowns so there's only 1 solution and you can just calculate it directly
I got outplayed by erics problem description
>>
>>103501216
nigger of course they will be probably two linearly independent vectors
what the fuck did you thougt
>>
>>103501208
>You now have 2 equations and 2 unknowns
And then what? I haven't solved a system of equations in decades. How do you go from those two equations to something like >>103500971's B=(py*ax/ay-px)/(by*ax/ay-bx) and A=(px-bx*B)/ax?
>>
>>103501210
Yep I was fully expecting having to simplify my equation and add edge cases and shit. But every time I try to optimize for edge cases this year I am punished, and Brooters win. So this time I did the least amount of optimization possible, wasn't punished, and won.

Blame Eric for not including good edge cases this year. (Yes i am still mad about 0 length files, how could you tell?)
>>
File: file.png (216 KB, 767x899)
216 KB
216 KB PNG
BHARAT SUPERPOWER BY 2024 SAAR
>>
File: file.png (141 KB, 641x622)
141 KB
141 KB PNG
>>103501231
>>
>>103501231
Eric needs to blanket ban the obvious brown names, and apologize to the 5 smart ones: "Nothing personal".
>>
>>103501216
>>103501220
One vector could have been a multiple of the other though.
>>
It took me a fucking hour to work around numpy's fucking rounding.
>>
>>103501231
>>103501236
saar very good at grade school math saar
kindly hire me pls saar
>>
>>103501243
>probably
>>
File: i keep screaming.png (367 KB, 568x454)
367 KB
367 KB PNG
>ok there has to be a certain amount of B presses and then the remaining should be some other combination
>don't realize linear equation
>get filtered
FUCK
>>
File: 1721474221566376.png (30 KB, 690x330)
30 KB
30 KB PNG
I really hope none of you got filtered by middle school math.
>>
File: LS20241213161047.png (1.31 MB, 3260x702)
1.31 MB
1.31 MB PNG
>>103500987
>>
>>103501259
I had to google how to solve linear systems of equations programmatically desu
>>
File: idiomatic_calendar.png (3.23 MB, 9859x4120)
3.23 MB
3.23 MB PNG
boring day
>>
>non broot now works on part1 answer
>incorrect answer for part 2

well fuck
no part 2 example answer to test against? im fucked
>>
>>103501225
px = a ax + b bx
(px - b bx)/ax = a

Substitute that into the py equation and solve for b, and you will get the other equation
>>
So when is the real advent of code going to start?
>>
>>103500723
I blame you
>>
>>103500733
hang yourself kek
got what you deserve
>>
>>103500723
>>103500759
Well that happened. We got the "math" day that was absolutely trivial, and yet just advantageous enough to look smug for a couple minutes.
>>
Seems silly the solution doesn't allow for half-A presses, which are pretty well known at this point.
>>
you guys are able to solve systems of equations by hand... right?
>>
>>103501262
I haven't used numpy in a long time, and I could solve it the retard way by hand faster than the linear algebra way. There is a trick to quickly Invert 2x2 matrices by just using the determinant or something right? It's been a while.
>>
>>103501287
>There is a trick to quickly Invert 2x2 matrices by just using the determinant or something right?
yes, for 3x3 too
>>
>>103501271
Tomorrow for sure
>>
File: file.png (30 KB, 511x414)
30 KB
30 KB PNG
>>103501287
>There is a trick to quickly Invert 2x2 matrices by just using the determinant or something right?
Yes. Back in grade 11 I knew this equation by heart. Now that it's 25 years later I have to google it.
>>
that took an embarrassingly long time to solve
>>
Who has two thumbs and took 45 minutes to remember that a linear system with two equations and two unknowns has at most one integer solution?
>>
and how does the inverse of a 2x2 matrix help?
>>
File: xarbon.png (9 KB, 772x388)
9 KB
9 KB PNG
>>103501062
washed ass
>>103501294
the number of equations is a constant and is literally 2. solving it with matrices is overkill.
>>
>>103501302
Its just the math fag way to solve a system of equations so they can say they are better than you.
>>
>>103501301
couldn't it have a ton of solutions if both lines had the same slope? A button goes +2, +2 and B button goes +1, +1 and target is +999, +999, lots of ways to get there
>>
>>103501302
Cramer's rule
>>
>>103501307
4 buttons would filter you
>>
>>103501271
TWO MORE DAYS
>>
>>103501294
that's the problem with math taught in school. you never use it so you forget it all
>>
>>103501324
the same goes for stuff taught at uni. the trick though is remembering what subject to look up in the textbook
>>
File: carbon(13).png (1.11 MB, 1818x1616)
1.11 MB
1.11 MB PNG
Haskell solution.
Don't know why I went with a midwit solution for part 1. I expected part 2 to be harder, either operating all machines at once, or having a real issue with minimal cost.
I checked that no buttons were colinear before solving the matrix systems, but given this year's difficulty idk what I expected.
>>
>>103501314
I never said I couldn't solve a 4x4 matrix. I just would rather not. Also I wouldn't do it the smart way I would just do row elimination because that's all I remember. So I guess you are ultimately right.
>>
>>103501308
Fortuitously the AOC input seems to always have both lines have different slopes, so I wouldn't have to worry about it there at least. If they did have the same slope though, we can just ignore one coordinate and do this same problem in 1D, which should be fairly straightforward to implement
>>
File: aocp.png (2.81 MB, 9781x3115)
2.81 MB
2.81 MB PNG
see you fags morgen
>>
>>103501308
Yeah but you'd get a division by zero error instead of a wrong answer, so it's not worth preemptively dealing with that case.
>>
alright i googled formula for solving linear equations so im not filtered
>>
>>103501330
I meant plug the matrix into numpy or something. Zero usecase for doing these by hand, I don't even know if I remember row elimination lol
>>
File: 24_D13_C#.png (428 KB, 2372x1750)
428 KB
428 KB PNG
I was pretty bummed today about failing one of my classes, but nothing cheers me up quite like algebra
>>
>>103501347
actually sweaty you were filtered if you didn't know how to solve this type of math problem off the top of your head
>>
>>103501355
i knew i just sharted the bed trying to derive it myself
kept getting the wrong answer
>>
File: file.png (19 KB, 536x264)
19 KB
19 KB PNG
>>103501355
>>103501358
i probably fucked up on some simplification step somewhere
(old non-working version)
>>
>>103501187
Ok, I managed to solve it. Had to take a pen and paper — rare case.
const input = require("fs")
.readFileSync("./input", "utf-8")
.trim()
.split("\n\n");

const games = input.map((gameStr) => {
const [Ax, Ay, Bx, By, Px, Py] = gameStr.match(/\d+/g).map(BigInt);
return {
Ax,
Ay,
Bx,
By,
Px,
Py,
};
});

const solveGame = ({ Ax, Ay, Bx, By, Px, Py }) => {
if ((Py * Ax - Px * Ay) % (By * Ax - Bx * Ay) !== 0n) return false;
const b = (Py * Ax - Px * Ay) / (By * Ax - Bx * Ay);
if ((Px - b * Bx) % Ax !== 0n) return false;
const a = (Px - b * Bx) / Ax;
return a * 3n + b;
};

console.log(
games
.map(solveGame)
.filter((s) => s)
.reduce((acc, game) => acc + game, 0n),
);

const games2 = games.map((game) => ({
...game,
Px: game.Px + 10000000000000n,
Py: game.Py + 10000000000000n,
}));

console.log(
games2
.map(solveGame)
.filter((s) => s)
.reduce((acc, game) => acc + game, 0n),
);
>>
>trying to do it in shitty JS
>realize I need to solve the system of equations
>the equation spits out floating point precision problems like a value of "120669521378.00000003"
>I added a handleFloat() function to round to the nearest if it's within a certain tolerance
This felt like bullshit, surely there must be a better way to deal with floating point math that I'm missing?
>>
>>103501392
Use BigInt
>>103501391
>>
>>103501392
Of course, just don't use floating point and instead use a library to use rational numbers.
>>
>>103501374
That looks correct though.
>>
>>103501392
if its float then dont count it as solved i.e. skip it
>>
>>103501392
yeah, use integers
>>
>>103501401
well it didnt work
>>
>>103501398
Oh, good call. Okay that makes sense; totally forgot about that
>>
>>103501409
dont need bigint
>>
>>103501392
round, then test if the answer's exact by doing the multiplications
>>
>not all are possible in part 2
FUCKING KILL ME
One if statement and I would've had the correct answer ages ago
>>
>>103501269
Got it. Thanks anon
>>
how do I time warp ahead 22 hours from now so I can work on a puzzle better than today's
>>
>>103501405
Oh you have to multiply the denominator of b by -1 i think. Not looking through to see where you fucked it up.
>>
>>103501432
yeah it doesnt really matter
when the equation gets that long my brain just switches off
>>
>>103501423
Happy to help (you are still filtered, though)
>>
> I added "10000000000000" string in front of a string number, not number 10000000000000 to number.
Fuck
>>
>>103501424
Sleeping is a good start
>>
is it possible to make this solution work?
>>
comfy cnile solution, although most of it was done on pen and paper to figure out the equation
also scanf parting ftw
>>
>>103501447
>also scanf parting ftw
why are you parting ways with scanf?
>>
>>103501446
I found that isclose isn't good enough
>>
>>103501424
get a bottle of liquor
>>
while developing the math solution I felt bruteforce running and it did finish one entry.
there is still hpe for you, broot bros
>>
Is this one like that ore mining puzzle from a year or two ago?
>>
File: carbon (10).png (188 KB, 848x893)
188 KB
188 KB PNG
Washed Python.

Original solution had a manual approach for Part 1 and a numpy approach for Part 2. This seems cleaner and imports are cheating.
>>
>part 2
>right for sample, wrong for real input
Fuck this
>>
fucking linear equations in golang. sigh.
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
13 00:50:42 5328 0 02:10:11 5837 0

I first did a n*n table and just stored the sum of the prev moves until I got to goal and then kept the min costs.

Didn't work in part2.
Thought I needed to get some combination of buta + butb that is a multiple of 10000000000000. Then I can use my answer from part1 + this multiple * costs for part2.

Then I tried DFS + memoization, keeping the lowest costs. Didnt work.
Then I tried just solving the linear equation. Thought that would fuck with the 'min cost'. But in hindsight, its a linear equation, so only one valid solution for a/b. very dumb of me not just to do it from the start.
>>
Gotta say, there's not really much to talk about for this problem.

Garden groups had a lot of different ways you could approach it and organize your code. This is basically "do you remember linear algebra" and if the answer is yes you don't get filtered.
>>
>>103500957
mathematica
> import solution
nice
>>
File: 1705301274023888.png (653 KB, 1414x1452)
653 KB
653 KB PNG
For completeness.
I need to wake up earlier, I definitely could've written this in ten minutes.
>>
>>103501547
>using a sat solver on day 13
giga brain moment
>>
C++
#include "aoc.h"
int main(int argc, const char** argv) {
if (argc != 2) return puts("Missing file name"), 2;
MmFile in(argv[1]);
if (!in.α) return puts("Failed to read file"), 1;
def problems = in / "\n\n" * λx(ϙNg(x));
const Z cost_a = 3, cost_b = 1, num[2] = {0, 10000000000000};
Z res[2] = {0};
ɤi (2) ɤc (problems) {
const Z ax = c[0], ay = c[1], bx = c[2], by = c[3],
x = c[4] + num[i], y = c[5] + num[i];
if (bx == 0 || by == 0) continue;
def den = ay / R(by) - ax / R(bx);
if (den == 0) continue;
def num = y / R(by) - x / R(bx);
const Z k = std::round(num / R(den));
const Z l = std::round((x - R(k) * ax) / bx);
def x_ = k * ax + l * bx;
def y_ = k * ay + l * by;
if (x_ == x && y_ == y) res[i] += k * cost_a + l * cost_b;
}
$o res[0], res[1];
}
>>
Part 1
data = open("Day 13 input.txt", "r").read().strip().replace("Button A: X+", "").replace("Button B: X+", "").replace("Prize: X=", "").replace(", Y+", " ").replace(", Y=", " ").split("\n\n")

total = 0
for i in data:
temp = i.split("\n")
a = map(int, temp[0].split())
b = map(int, temp[1].split())
target = map(int, temp[2].split())
cheapest = None

for apress in range(100):
for bpress in range(100):
if a[0]*apress+b[0]*bpress == target[0] and a[1]*apress+b[1]*bpress == target[1]:
if cheapest == None or apress*3 + bpress < cheapest:
cheapest = apress*3 + bpress

if cheapest != None: total += cheapest

print total

Part 2
data = open("Day 13 input.txt", "r").read().strip().replace("Button A: X+", "").replace("Button B: X+", "").replace("Prize: X=", "").replace(", Y+", " ").replace(", Y=", " ").split("\n\n")

total = 0
for i in data:
temp = i.split("\n")
a = map(int, temp[0].split())
b = map(int, temp[1].split())
target = map(int, temp[2].split())
target[0] += 10000000000000
target[1] += 10000000000000

x = a[0]*(b[0]*target[1] - b[1]*target[0])/(a[1]*b[0] - b[1]*a[0])

apresses = (x/a[0])
bpresses = (target[0]-x)/b[0]
cost = apresses*3 + bpresses
if a[0]*apresses + b[0]*bpresses == target[0] and a[1]*apresses + b[1]*bpresses == target[1]:
total += cost

print total

Slightly washed, removed redundancies in the math. This solution brought to you by .replace()
The most boring type of puzzle, just implement a formula and call it a day. The only "aha" moment is realizing that there's only one solution each.
>>
>eric says: get a constraint solver
I couldn't get libglpk to work with Zig so here's a Perl part1
>eric says: do math
no point in doing this one in any particular language either
>>103501561
r8 mine
>>
File: perl.png (405 KB, 1342x1966)
405 KB
405 KB PNG
>>103501566
>>
Wow, I got absolutely filtered today.
I got so hung up on thinking of the equations as diophantine equations, modular arithmetic, etc, that it did not occur to me at all to just solve them as ordinary linear equations and see if the result is an integer.
I eventually ended up solving them as diophantine equations in sympy.
I feel so stupid.
>>
File: day13washed.png (185 KB, 1860x1203)
185 KB
185 KB PNG
Modern C++
>>
This is officially the furthest I've made it in any Advent of Code and I'm not even close to being filtered.
>>
>>103501599
it's the easiest year by far
>>
File: day13.png (251 KB, 2002x1330)
251 KB
251 KB PNG
$ mix run -e 'AOC.main()' -- 2024 13 b input/real
36954
79352015273424

Ran in 1.201ms


Advent of Wolfram Alpha
>>
>math trick day
>>
>>103501447
i want too to build a aoh.h lib what do you put inside it? any suggestion?
>>
>>103501640
>trick
>>
>wake up
>pure math problem
i'm going back to sleep
>>
>>103501681
NTA but I'm tempted to create one with linear algebra structures and operations
>>
>advent of open up the notes from that one class I took where I had to use a constraint solver and just import solution
>>
File: IMG_3838.jpg (56 KB, 631x842)
56 KB
56 KB JPG
>>103501564
> Ǫ
>>
File: 1704914214162182.jpg (215 KB, 1024x1024)
215 KB
215 KB JPG
>>
>>103501601
I was about to say that 2020 was probably even easier, but then I checked day 13 to compare and it turned out to be the Chinese bus schedule one, which is much more advanced than anything we've gotten this year.
You'd think he could start making things a bit more challenging again, now that the pandemic overhiring lrn2code hype is over and you can literally just ask an LLM to give you some ideas if you're stuck.
>>
>>103501530
unwashed sigh. pathetic.
    acost := 3
bcost := 1
sum := 0
for _, bconfig := range bconfigs {
goal := bconfig.prize
_ = goal

ss := 101
state := make([][]costsum, ss)
for i := 0; i < len(state); i++ {
state[i] = make([]costsum, ss)
}

state[0][1] = costsum{3, xy{bconfig.buta.x, bconfig.buta.y}}
state[1][0] = costsum{1, xy{bconfig.butb.x, bconfig.butb.y}}
for i := 2; i < ss; i++ {
prev := state[0][i-1]
state[0][i] = costsum{prev.cost + acost, xy{prev.pos.x + bconfig.buta.x, prev.pos.y + bconfig.buta.y}}
cprev := state[i-1][0]
state[i][0] = costsum{cprev.cost + bcost, xy{cprev.pos.x + bconfig.butb.x, cprev.pos.y + bconfig.butb.y}}
}

mincost := math.MaxInt
for r := 1; r < len(state); r++ {

for c := 1; c < len(state[0]); c++ {
colp := state[r][0]
rowp := state[0][c]
state[r][c] = costsum{colp.cost + rowp.cost, xy{colp.pos.x + rowp.pos.x, colp.pos.y + rowp.pos.y}}

nstate := state[r][c]
if nstate.pos.x == goal.x && nstate.pos.y == goal.y {
mincost = min(mincost, nstate.cost)
break
}
if nstate.pos.x > goal.x {
break
}
if nstate.pos.y > goal.y {
break
}
}
}
if mincost < math.MaxInt {
sum += mincost
}

}
fmt.Println("sum", sum)

fmt.Println("second")
sum1 := 0
for _, bconfig := range bconfigs {
goal := bconfig.prize
adj := 10000000000000
goal.x += adj
goal.y += adj
fmt.Println("goal", goal)

x1 := bconfig.buta.x
x2 := bconfig.butb.x
x3 := goal.x
y1 := bconfig.buta.y
y2 := bconfig.butb.y
y3 := goal.y

b1 := (x1 * y3) - (x3 * y1)
b2 := (x1 * y2) - (x2 * y1)
b := b1 / b2
a := (x3 - (x2 * b)) / x1

xx := (a * x1) + (b * x2)
yy := (a * y1) + (b * y2)
if xx == goal.x && yy == goal.y {
sum1 += acost*a + bcost*b
}
}

fmt.Println("sum1", sum1)

>>
File: bqn.png (49 KB, 864x378)
49 KB
49 KB PNG
totally inept bqn
>>
>>103501725
>and you can literally just ask an LLM to give you some ideas if you're stuck.
No, cheating should not be normalized
>>
>>103501722
cute!
>>
File: carbon.png (284 KB, 753x2205)
284 KB
284 KB PNG
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
13 00:35:19 3880 0 02:31:29 6551 0

I solved part 1 using Dijkstra, then couldn't figure out what the fuck to do for part 2, so I tried writing another solution for part 1 hoping it might help. It didn't. I never learned linear algebra, so instead of doing what's obvious to mathfags, I spent like an hour and a half trying to remember how the fuck to use Z3, which thankfully eventually worked.
>>
>>103501759
>import solution
you didn't solve it
>>
>>103501759
>import solution
>>
File: day13.png (113 KB, 867x1044)
113 KB
113 KB PNG
boring day. literally high school math.
>>
>>103501759
>import solution
>still way more code than a proper solution
Very pythonic
>>
>>103501747
How is this different than googling something? If you're at this point, you're not going to get on the leaderboard anyway, so it's just a matter of what helps you learn more effectively (which will often be the LLM).
>>
File: phone.jpg (8 KB, 200x200)
8 KB
8 KB JPG
Can a nigga get a hint for part two? I feel like it has to do with some modulo trick that I can't quite get right.
>>
>>103501794
Googling a solution is also cheating. What?
>>
>>103501798
Have you tried reading the thread?
>>
>>103501747
>cheating should not be normalized
It already was normalized (even encouraged) to google things and ask other people.
It happens in this very thread, actually.
Or are you going to start mass-replying to every post asking for help?
>>
>>103501810
>Or are you going to start mass-replying to every post asking for help?
Don't tempt me you little twerp
>>
>>103501800
I mean, if you straight up ask it for the specific advent of code answer sure. But for today's problem, I don't see much difference between googling how to solve systems of linear equations versus asking the same thing to an LLM.
>>
>>103501798
Hint: This has nothing to do with moduli. In fact, forget for a moment that the solutions have to be integers. What now?
>>
File: carbon.png (99 KB, 689x752)
99 KB
99 KB PNG
>>103501787
Well yeah, it's unwashed, with multiple suboptimal solutions deliberately left in.
Here's as much as I'm cleaning it.
>>
>>103501805
I haven't because I don't want to be spoiled outright, I just need a nudge in the right direction.
>>
>>103501824
hint: it's a linear algebra problem
>>
>>103501814
If you have to google how to solve a system of equations for this problem, you are cheating and you were filtered. Cheating and being filtered are of course fine for newbies who are just trying to learn though.
>>
>>103501821
>import solution
you didn't solve it
>>
>>103501716
static auto ϙNg(const Sv& v) {
V<N> r;
int count = 0;
N num = 0;
for (const auto c : v) {
if (c < '0' || c > '9') {
if (count) r.push_back(num);
num = count = 0;
} else {
num = num * 10 + c - '0';
++count;
}
}
if (count) r.push_back(num);
return r;
};
>>
>>103501824
There's a constant time solution for each "game" that you can figure out with algebra.
>>
>>103501830
Let's agree to disagree, good sir!
>>
>>103501810
Asking people for help is better for two reasons:
1) People have an innate sense of fairness and will not just give you the solution
2) People are directly competing with you and can't possibly help you until they have solved the problem themselves
>It happens in this very thread, actually.
People also post solutions in this thread so you can just copy one, doesn't mean it's normalized to do that
>>
>>103501759
>z3_this_nonsense()
that is certainly a mood
>>
File: 1715880709989264.jpg (18 KB, 384x404)
18 KB
18 KB JPG
>>103501759
>>103501547
>using SMT solvers, the product of 70 years of the most advanced math and CS theory, with thousands of PhDs worth of algorithmic advancements, using the full power of your computers 100+ billion arithmetic operations per second, to solve a system of two (2) linear equations
>>
>>103501836
No, I will not agree to that. You are wrong and less of a person because of it. Don't reply to my posts ever again.
>>
>>103501840
it really shows how bad these tools are. Look at how much work it is to get them to solve such a simple thing! CAS should have improved since the HP calculators that my dad used as a kid.
>>
>>103501843
do you not know what agree to disagree means?
>>
>>103501840
Yeah and? You think the GHz-class CPU you ran your solution on isn't overkill for doing a small amount of arithmetic?
>>
>>103501840
I did the same and it was because the word "diophantine" was stuck so firmly in my head that I ignored everything else
>>
>>103501830
i dont HAVE to
its more convenient to
thus i am not filtered
>>
>>103501852
Apparently you don't
>>
>>103501830
THIS. It's also how I run coding interviews. You shouldn't need to google syntax in a language you yourself picked for the interview.
>>
>>103501857
Lying to yourself is a terrible look
>>
>>103501866
you could have solved it with pen and paper but you used a computer to do it
for convenience
>>
>>103501861
If you refuse to agree to disagree with me it means you agree with me
>>
>>103501840
Ackshually Z3 should specialize to a solver for integer linear systems, so the complete SMT engine won't be used.
And I also haven't seen any other solutions that bother correctly handling collinear vectors.
>>
>>103501873
>If you refuse to agree with me it means you agree with me
>>
>>103499273
my bro, intcode is king
you only build on the vm up until day 9, that's when it's feature complete so to speak. i don't understand what you mean with "organizing my intcode", you don't really have to write any intcode but if you insist on doing that I would have a large data section at the end of the program which you can write to and read from, it's easier to reason about than interleaving data and instructions. better yet, write a frontend with some assembly-like grammar
>>
>>103501880
retarded ESL nigger
>>
Tomorrow is the REAL filter. The fact that today was easy is just to lull you in.
>>
>>103501883
>If you refuse to agree with me it means you are a retarded ESL nigger
>>
>>103501873
No, it means that I still think you're wrong and should change your incorrect conclusion to my correct one. I'm not agreeing to disagree, I'm maintaining that you're wrong.
>>
agree to sneed
>>
>>103501883
imagine only speaking 1 language
>>
i cheat almost every day
>>
>>103501908
go back to r3ddit, bikatr
>>
Who else can't solve the system of equations?
>>
>>103501893
>>103501891
"Agree to disagree" doesn't mean "you have to agree with me", it means "let's agree that we disagree here." And we do disagree here. So to disagree with that statement, you're disagreeing with the idea that we disagree--you're saying we agree.
>>
>>103501953
>it means "let's agree
we don't agree
>>
File: xavier-speech-bubble.png (245 KB, 613x460)
245 KB
245 KB PNG
>>103501953
>>
>>103501836
>>103501843
>>103501852
>>103501861
>>103501873
>>103501893
>>103501953
>>103501963
please keep arguing about this for another 200 posts, it's really improving the quality of this thread
>>
File: yourwallet.png (760 KB, 830x624)
760 KB
760 KB PNG
>>103501963
>>
File: 1723618761985944.jpg (232 KB, 1024x1024)
232 KB
232 KB JPG
Anon-kun, stop arguing please and win me this prize!
>>
File: reimu-wants-to-win.jpg (599 KB, 1002x1002)
599 KB
599 KB JPG
>>103501977
>>
File: 9dmrhi.jpg (110 KB, 750x500)
110 KB
110 KB JPG
>>
File: sexy_dog.png (3.39 MB, 1236x1236)
3.39 MB
3.39 MB PNG
>>103501977
here's what i think of your stupid elf
*uses AI and combines it with a sexy dog*
>>
File: file.png (405 KB, 1280x720)
405 KB
405 KB PNG
>>
>>103501977
>>103501982
CUTE
>>103501997
not cute
>>
File: claw machine.jpg (464 KB, 1920x1080)
464 KB
464 KB JPG
>>
>>103502033
me on the right
>>
>>103501996
>high school
do amerisharts really only learn this in high school?
>>
>>103502043
I didn't even go to high school
>>
>>103501446
>>
>>103502047
you have to be 18+ to post here
>>
>>103502055
You didnt solve it. What if a and b are linearly dependant and thus the determinant is 0?
>>
>>103502087
None of the inputs have a determinant of 0. So I did solve it.
>>
>>103502098
The problem statement doesn't disallow it thoughbeit AKCTHIHUALLY sweetie
>>
>>103502066
Retard
>>
I'm ashamed to admit it but It took me 2 hours to solve the formula right. I don't think I've used a pen in years let alone do math by hand.
>>
Who here is a diophantine equation chad and who's a linear algebra loser?
>>
>>103502171
neither, I copied from reddit
>>
File: codesnap1.png (309 KB, 1860x1432)
309 KB
309 KB PNG
>>103497970
Racket here
>>
>>103502144
Read the global rules retard before you post.
>>
how do you look this problem and immediately know it's a system of linear equations?
>>
>>103502229
college
>>
>>103502229
retard
>>
>>103502249
i am in college and i took linear algebra...
>>
I am too small brain for this part b.
>>
>>103502229
fucking retard
>>
>>103502269
I was, too, until I figured out that there are only 1 or 0 solutions for a linear equation system with 2 equations and 3 variables.
n * a.x + m * b.x = prize.x
n * a.y + m * b.y = prize.y
>>
>>103502269
https://en.wikipedia.org/wiki/Diophantine_equation
>>
>>103502289
Uh, with 2 variables of course. Typo.
>>
>>103502253
>>103502272
rude :(
>>
File: carbon.png (601 KB, 1886x2766)
601 KB
601 KB PNG
Highly optimized rust.
day 13                  time:   [1.4811 ns 1.4842 ns 1.4874 ns]                    
change: [-99.994% -99.994% -99.994%] (p = 0.00 < 0.05)
Performance has improved.

I tried doing everything at compile time since it's such a simple day. I'm a bit surprised round() isn't a const function.
>>
>>103501953
agree to disagree implies that each side has some validity
>>
>>103498258
I will
>>103500229
correct, I just like a good christmas tale
>>
>>103501997
what the fuck
>>
File: 13.png (1.28 MB, 1668x2694)
1.28 MB
1.28 MB PNG
Had to shake off a lot of math rust for this one. I am disappointed it took me so long to figure out how to set up the equations. Oh well.

Ugly C++ ass.
>>
File: day13.png (32 KB, 730x367)
32 KB
32 KB PNG
BQN day 13

good day for us array bros
>>
>>103502329
In this case you are wrong and the other guy is correct. You have no validity.
>>
File: image.png (282 KB, 907x370)
282 KB
282 KB PNG
my humble BQN solution for day 13.

initially solved part 1 with a dfs and was stumped at part 2, but then realized it can be broken down into a matrix equation thingy and then solved with cramer's rule.
>>
>>103502341
nice
>>
any madman still trying to broot this?
>>
If you use third party dependencies you did not beat AoC.
>>
File: thinking-yuno.png (499 KB, 536x567)
499 KB
499 KB PNG
>>103502376
now that i think about it a bit more, i'm not sure if this is even a "proper" solution. it solves the equation, but doesn't really make sure that the final cost is minimum possible.

i guess there's only one possible way to win the prize so that's why it worked out??
>>
>>103502408
like a compiler or programming language.
>>
>>103502411
There can only be one solution to two linear equations of two variables.
>>
>>103502376
>that smile
cute
>>
>>103502421
consider the following

A     {2, 2}
B {1, 1}
Prize {4, 4}


you can win the prize by either pressing B 4 times (cost 4) or by pressing A twice (cost 6).
>>
>>103502408
If you did not solve every day using only pen & paper, you did not beat AoC

>>103502421
Button A: X+16, Y+16
Button B: X+32, Y+32
Prize: X=3360, Y=3360

I can't even get my shitty code to calculate this properly, but there are many valid combinations of A and B with an answer of >=105 and <= 630 for part 1, and >= 312,500,000,105 and <= 1,875,000,000,630 for part 2
>>
>>103502441
2t + k = 4
2t + k = 4

you're right what I said only applies to independent bases. If they're dependent you can just choose either and minimize t for positive integer solutions I believe.
>>
>>103502497
and to do that you can use bezout's identity.
>>
>>103501166
Yeah, I failed high school math.
>>
>>103502228
Retard
>>
>>103502371
i AM heckin cute and valid
>>
I don't remember ANY math from high school
That was like 23 years ago.
>>
>>103502482
it's a system with 2 equations and 2 variables, it literally has 1 solution possible
>>
>>103502497
I think a lot of people are glad ( because they didn't think about it ) that it was two independent equations.
>>
File: your an retard.jpg (69 KB, 443x602)
69 KB
69 KB JPG
>>103502554
>>
I think he would force us to implement Simplex instead of this high school shit.
>>
>>103502441
If they are linearly independent the image vector space is 1D
If the target is NOT in the vector space then no solution
And it is always the case in the input
Otherwise only one coord need to satisfy so express B button counts if you assume A
A*dxa+B*dxb=X
B=(X-A*dxa)/dxb
Put it in equation to minimize
3*A+(X-A*dxa)/dxb
3*A+X/dxb-A*dxa/dxb
A*(3-dxa/dxb)+X/dxb
This is a linear function mx+b=y
with m=3-dxa/dxb and b=X/dxb
If m>=0 => dxa/dxb<=3
Then if A is minimal y is minimal, take the minimum integer A such that X-A*dxa is a multiple of dxb
Else same but take the maximum such integer
>>103502538
Fucking retard you can read the rules on https://4chan.org/rules#global
>>
File: 1658772537401632.jpg (70 KB, 1080x1080)
70 KB
70 KB JPG
>HAHA retard! you don't know this simple math equation
>HAHA retard you got filtered by this EASY programming puzzle made for CHILDREN
>HAHA retard! its JUST hight school MATH
>HAHA retard! look i implemented this solution on my OWN and i've been programming for only 2 days
>HAHA i m better than these RETARDS AMIRITE
>HAHA FILTERED FILTERED FILTERED
what causes such behavior in AOC threads
>>
>>103502583
There are only 5 people left and they are just fighting with themselves because they are bored and miss the earlier aoc days where more people participated and made memes and shit.
>>
>>103502583
not being a mathlet
>>
>>103502574
>thought
Fixed. My brain isn't braining anymore.
>>
>>103502583
Mathfags have had a superiority complex since the beginning of time
>>
File: image (2).png (71 KB, 1330x382)
71 KB
71 KB PNG
>>103500957
Here is my own Mathematica solution. The fun thing is, you don't even need to minimize anything. There aren't even any singularities that would forbid my solution.
>>
>>103502623
>Mathfags have had a superiority complex since the beginning of time
but this has been happening more or less since day 1
>>
File: file.png (1.13 MB, 1422x1532)
1.13 MB
1.13 MB PNG
>>103502623
we are superior
>>
>he can't solve a 2 eqs 2 unks system
rumao
>>
>>103502630
I dunno man, we had that problem a few days ago where you could easily get a generic graph library like networkx to do the heavy lifting and there were loads of posts like:
>import solution
based
>>
File: file.png (1.77 MB, 1920x2157)
1.77 MB
1.77 MB PNG
>>103502623
>>
what an easy day thanks for the free stars mathfags
>>
>>103502583
newfaggotry
>>
>>103502583
when the puzzle is as cut and dry as today's was, there isn't much to discuss about it other than how <my solution> is the REAL way to solve it and <your solution> was wrong and you are now disqualified from the competition (filtered)
>>
>>103502576
Retard
>>
No big boy for today?
>>
>>103502672
what for?
>>
>>103502675
For sneaking in edge cases not in the real input like >>103502441
so that we can all argue about who got the right answer
>>
File: 0758_-_ONhLzZi.jpg (6 KB, 200x193)
6 KB
6 KB JPG
there are people itt that think they ca put their score on their resume to get hired more reasily
>>
>>103502670
kek you can't read. Ask someone else then here to verify if you don't believe that underage kids cannot post here.
>>
>>103502682
where frogfren?
>>
>>103502672
If you know Cramer's rule you can literally calculate the button presses for A and B for every machine, or instantly find out that there's no solution for a machine.
>>
>>103502672
if you want to be a big boy solve the problem in 3 dimensions and for arbitrarily many buttons
>>
>>103502690
I'm in disbelief actually. I hope you are a third worlder so you have an excuse.
>>
Haskell
import Data.Maybe (mapMaybe)

solve xs = sum $ map cost $ mapMaybe solveEqn xs
where cost (a,b) = (3*a+b)

solveEqn ((ax,ay),(bx,by),(cx,cy))
| a1 == 0 = Just (a,b)
| otherwise = Nothing
where (a,a1) = (cx*by-cy*bx) `divMod` (ax*by-ay*bx)
b = (cy-ay*a) `div` by

parseLines :: [String] -> [((Int,Int),(Int,Int),(Int,Int))]
parseLines [] = []
parseLines xs = (parse $ tail as, parse $ tail bs, parse cs) : parseLines zs
where (as:bs:cs:_) = map words ys
(ys,zs) = splitAt 4 xs

parse xs = (read $ init $ drop 2 $ xs !! 1, read $ drop 2 $ xs !! 2)

add d (a,b,(cx,cy)) = (a,b,(cx+d,cy+d))

main = do xs <- parseLines . lines <$> readFile "input"
print $ solve xs
print $ solve $ map (add 10000000000000) xs
>>
File: file.png (44 KB, 791x439)
44 KB
44 KB PNG
>solves part 2 easy
>>
If I have the time later I'll try to solve today in Z3 or CVC5. It should easily handle some linear equalities.
>>
>>103502643
are you meg in this picture?
>>
>>103502675
>>103502679
Does 0 x/y movement buttons actually move the claw?
>>
>>103502728
Wonderful topic for the next thread. Really makes you think!
>>
>>103502728
yes but there would never be a reason to press that button because it adds a cost without getting you closer to the prize
>>
>>103502735
I am sorry, but that fucking 0 length file guy on the file expand/defrag day is making me laugh. He thought 0 length files takes up 1 block of space.
kek
>>
>>103502745
a whole day arguing about that retardation, kek
>>
>>103502703
I'm sorry but if I'm right in the English language high school is for people who are under 18.
>I'm in disbelief
That's why I posted a direct link to the global rules
>>
>>103502745
They do in real life. They take up an entry in a dictionary and a node in the file system. They did not however take up space in the puzzle context. The puzzle text implied this if you read it.
>>
>>103502759
i agree with your statements
>>
here we go again
>>
File: file.jpg (28 KB, 650x400)
28 KB
28 KB JPG
>>103502695
its simple maths jerry
>>
>rounding
>tolerances
omegalul
what are yall niggas doing
>>
>>103502794
you can avoid all floating point math with just a check
        b1 := (x1 * y3) - (x3 * y1)
b2 := (x1 * y2) - (x2 * y1)
b := b1 / b2
a := (x3 - (x2 * b)) / x1

xx := (a * x1) + (b * x2)
yy := (a * y1) + (b * y2)
if xx == goal.x && yy == goal.y {
sum1 += acost*a + bcost*b
}

>>
>>103502757
I'll be polite because it's Christmas
>I didn't even go to
does not mean
>I have not [yet] been to
In fact the past tense "didn't" implies that the time frame has long since passed.
>>
how do I solve this in ARM assembly?
>>
>>103502789
It is literally done with addition, subtraction, multiplication and division of integer numbers, plus one check if a certain value is 0, because you can't divide by 0. In which case the machine in question has no solution for the number of A and B button presses.
>>
lame day
>>
File: image (3).png (110 KB, 1091x709)
110 KB
110 KB PNG
>>103502810
You don't even need to check.
Here is a version with no floating point numbers, no rational types, no "import solution"*. Just the pre-solved inverse. Of course this assumes that the determinant is non-zero, just like most other solutions here.
*besides parsing
>>
>>103502672
The only thing it would measure is how bad your parsing is
The actual solving is trivial to compute unless you did something roundabout
>>
>>103502845
Disregard the first sentence, I just equivalently check the modulo instead of course. This could also just be
(b*e-d*f)%detM * (b*e-d*f)/detM  
, to lose the explicit condition. Anyway, no floating point problems.
>>
>>103502889
hmm. that is neato.
>>
>>103502830
>division
Look at this guy with his fancy division.
>>
File: codeimage-snippet_13.png (32 KB, 632x184)
32 KB
32 KB PNG
>>
>took me like an hour to figure out this easy ass maths
its over for me
>>
File: aoc_13.png (274 KB, 2000x1000)
274 KB
274 KB PNG
We are so back LLM bros
>>
>>103502971
Are the boxes missing characters in the font, or does APL just have a box symbol?
>>
File: death.png (168 KB, 500x207)
168 KB
168 KB PNG
im filtered, i dont care to try anymore, looked at someone elses solution
removed myself from the leaderboard
might still hang out in the threads and do later days
what a boring day to get filtered by...
>>
>>103502992
its a literal box
>>
>>103502999
oof. Why look when you have 17hours left?
>>
>>103502992
is how you call system functions (NGET to read a file or blank to print)
>>
>>103503007
i dont care to think about the problem any longer
i've spent half my day on the problem
i thought it was chinese remainder theorem and wasted so much time
i will not waste any more time
i didnt find today fun
i will not waste any more time
>>
>>103502999
Eh, don't worry about it.
It's just a silly math question in a coding puzzle.
>>
>>103503021
In the time you spent whining you could've solved it. Literal 5 minute problem.
>>
>>103503025
i'm going to absolutely worry about it
need to get some beers before i decide if i should kill eric and his family
>>
>>103503026
i've already spent hours
i can whine for 5 minutes if i fucking want you jewish nigger
>just 5 minutes more bro
maybe i'll kill you too
>>
>>103503021
>crt
>for today
kek this has to be bait
>>
>>103503042
day 13 2020 was literally chinese remainder theorem
>>
>>103503047
yup. And I took about 6hours on it. I stared at lists and lists of numbers trying to find some pattern and in the end derived a random formula.
Looked at /aocg/ and saw its like a random math 2 liner. Looked at the wiki page and saw I derive the formula for CRP. felt good that day.
>>
>>103503039
already backtracing your IP fakkit, better have part 2 finished when I roll up or I'll eradicate the pathetic little shitstain you call your life
>>
>>103503021
Look, I get you. I personally much prefer when the problems are just logically solving.
I solved yesterdays with some stupid wall creation solution instead of counting corners.
When the solution requires a specific understanding of some math problem that you're probably never going to solve without that prior knowledge, it sucks. Especially when many languages have an import solution that will do it in a single line.
But that lack of knowledge can just be something you learn.
>>
>>103503062
ok, wasnt quite that long:
13   01:23:26   7746      0   04:42:28   6133      0
>>
File: 1723271284675784.png (12 KB, 372x204)
12 KB
12 KB PNG
lol, lmao even. i had to set float precision to 3 to get the right answer
>>
File: maxresdefault.jpg (150 KB, 1280x720)
150 KB
150 KB JPG
>>103503070
i wish there was a way to find hints on which specific mathshit you need to know without ruining the entire problem
the other problem with all mathshit is the internet is flooded with literal indian mathshit content
>>
>>103503104
imagine getting filtered by something which even literal shitskins and sandniggers know
really shows your level
>>
>>103503116
maybe one sandnigger understands it
other sandniggers then copy his script or powerpoint verbatim
this is a known phenomenon
>>
Alright, time to cheer up, people.
>>
File: day7.png (918 KB, 1952x3663)
918 KB
918 KB PNG
>>103503170
And the code.
>>
>No matter how the stones change, their order is preserved
>What is the fewest tokens you would have to spend
What's next, Eric? Just giving an example that is incorrect?
>>
>>103503170
>2 hours
goddamn
>>
>>103503182
I don't get your problem. First of all the problem statement doesn't disallow matrices with zero determinants, in that case the solution is >>103502576
Thank eric rather that he didn't include such input.
And in both cases the correct answers for both questions were accepted. What's the issue.
>what's x+y (x and y are written in this order)
>nooooo addition is commutative, you can't just put that additional text there
Not his problem.
>>
>>103503170
basedboy!
Very cool.
>>
>>103503170
based GBA solver
>>
>>103503211
it is his problem doe
>>
>>103503201
It was a slight improvement on 9.
The biggest problem is that I don't have a really fast way of getting from binary to BCD for the concatenation. ARM7TDMI doesn't have a division instruction.
Initially I also implemented a reverse double dabble for the BCD to binary, but then I changed it to multiplying each digit by it's place, switching to 64bit multiplication after the 9th position and found it averaged about 50,000 cycles faster than doing the reverse double dabble.
Also changed it so that the the vblank interrupt for updating the results (which still uses double dabble) disables itself and I enable it whenever the results are updated to reduce wasted cycles. And put in that "Done" message when the solver completes.
Lots of little improvements.
>>
>>103503291
awesome
>>
File: aoc24_13.png (507 KB, 718x3597)
507 KB
507 KB PNG
unwashed Odin abomination
Rather than opening up my old linear algebra textbook, I decided to trial-and-error my way through it based on vague memories from 15 years ago
>>
>>103503333
unchecked quads on page 9!
>>
>so much seethe over babbys first math problem
This is sad.
>>
is this math?
>>
>looks like optimization problem
>solve equations on paper
>didn't work for part 1
>fuck it, bruteforce
>see part 2, panic
>try again to solve it on paper
>paper solution works now
I knew how to solve it and still somehow fucked up
>>
>>103503437
all programming is math
>>
>>103503439
That's because you're retarded.
>>
wall when
>>
File: programming.png (229 KB, 1854x852)
229 KB
229 KB PNG
>>103503447
this is programming for me
last time i had to do any math was a linear weighted sum
>>
>>103503492
>bloading game
wut?
>>
>>103503492
functions are nodes in a graph
every problem is a graph problem
>>
>>103503504
convention to use b for bool types

>>103503507
i'll take your word for it
>>
>>103503492
this hurts to look at. this looks like some string of characters some pajeet sharted out in a minute. it's amazing that it spans the entire screen and literally not a single piece of logic is included, it's all literally empty expressions. reminds me of libtard politions, they somehow speak for hours without saying a thing.
>>
>>103503511
*politicians
>>
File: logic.png (50 KB, 943x789)
50 KB
50 KB PNG
>>103503511
well those are high level functions, they orchestrate systems they don't perform much logic they just do things
if you mix execution and logic it becomes a mess pretty quick, but that's just my opinion
even then the underlying logic doesn't need much math
>>
>>103503544
lol "Actor" spelling mistake
>>
>>103503447
true. but this problem is just math
>>
i'll still try to solve it
i think i remember how to work with systems of equations
>>
>>103503563
that's not a spelling mistake that's my IDE bitching it should be made const, and it probably should I guess I forgot about it
>>
>>103503577
I am just joshing with you.
Is this an engine only? or are you making a game?
>>
>>103503492
how did you manage to make sepples look as retarded as cshart
>>
kek this guy unironically brooted today
I must kneel
https://www.youtube.com/watch?v=GqWX9MmFhX8
>>
>>103503596
Ask Epic Games, that's Unreal Engine code.
Turns out its code is as shit as its performance.
>>
>>103503606
Ever heard of SDL? Or are you a wagecuck?
>>
>>103503591
working on a game on my free time

>>103503596
cniles hate me

>>103503606
ackshually that code is extremely performant and parallelized and the deferred/VR rendering pipeline runs at 120fps on a toaster
>>
>>103503617
For me it's GLFW + OpenGL
>>
>>103503604
I'm watching him since last aoc to learn how to solve the problems and it's baffling to me that I'm doing better than him this year in terms of problem recognition
>>
>>103503618
I meant clustered forward not deferred
>>
NEW THREAD
>>103503635
>>103503635
>>103503635
>>
>>103503632
Paulson fell off, i recommend Neil Thistlethwaite instead. he also commentates pretty decently during solving.
>>
File: Day13.png (195 KB, 1117x1129)
195 KB
195 KB PNG
C#. Advent of forget-line-equations-so-hamfistedly-copy-one-of-Wikipedias.
>>
>>103503648
Idk which day it was when you had to sort the pages but that day nthistle just insisted on toposort and for some reason he debugged it why are there cycles in it, but there were n*(n-1) edges and theres only one way not to have cycles such way so it's not surprising.
could have just cmp_to_key-d
>>
>>103503604
kek
i was actually thinking there could be some way to brute it to find a combination where the target is divisible by it, then just multiply it up to get the actual cost
but then again the linear equation way is so simple its not worth the effort



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