#2023 Day 06
70 messages · Page 1 of 1 (latest)
This seems easy?
today's seems more like a mathematics puzzle than a coding one
brave to say that before seeing part 2 😉
fair lmao
part 2 was also easy
arguably easier
isnt its a bit easy for AoC?
did this one in Excel, just because
https://github.com/monbrey/aoc2023/tree/main/day-6 ||I suspect there's technically a faster way than starting at 0 of calculating this correctly, but it runs fast enough anyway||
||the elegant solution would be to solve the quadratic||
oh of course
||waits, whats squared here?||
||nvm I understand||
I havent been in school for 15 years cut me some slack 
its enough to work
speed is unnecessary

lmao
part 2 is somehow flying over my head
You could hold the button anywhere from 14 to 71516 milliseconds and beat the record, a total of 71503 ways!
and asks
How many ways can you beat the record in this one much longer race?
what?
||Yeah so, instead of doing the multiplication thing from part 1, literally just say the number of ways||
||a "way" to win is just a number of ms you can hold it which will result in a record break||
First time I found part 2 easier than part 1 
Yeah haha
it is, if you don't dumbo p1 like i did
because then p2 is not happening apparently it is, just takes a few secs


I suppose I dumbo'd part 1 as well then, because p2 results in the same as the number already mentioned in p2 
|| iterating possible races might not be the way to go ||

||floor((sqrt(time ** 2 - (4 * distance)) + time) / 2) * 2 - time + 1 in case anyone was wondering...||
undoubtedly slower than brute-force iteration for the size of numbers in part 1
but likely quicker for the part 2 calculation
|| oh... i also could've waited 3 more secs
||
|| naive p1 does actually work for p2, it's not as terrible as it looked ||
AoC playing games, yesterday's was so hard and this one's so easy
|| I‘m being proud of everyone not dumbo‘ing it ||
||Mine was half dumbo, I just iterated to find the first winning race, but recognised that the last winning race is that time subtracted from the max time||
||Commutative multiplication||
||i did newton's method|| https://github.com/brownie-in-motion/advent-of-code/blob/main/2023/source/bin/day_06.ml
mostly because ||i don't know how floats work|| :p
what is that, MATLAB?
ocaml
||x' = x - (- x * x + t * x - (d + 1)) / (- 2 * x + t)||
||repeat this and it converges very fast||
how many iterations for part 2?
10
||yes five for each root||
||I personally just found one solution and then reflected it about x=(time/2)||
I like the method though, very elegant
oh that's crazy didnt realize u could do that
|| that’s how quadratic functions look like, they are symmetrical ||
||yeah, if you think of the graph, it's always 0 at x=0 and x=time, and the maximum is always halfway between the two||
||ah yes because after u shift it vertically it doesn't change the center||
i feel like you can get it to like ~2 iterations ||using the convexity of parabolas||
todays was refreshing
wow the perl devel profiler is really nice
Few seconds? ||What magnitude is your input? Mine is around 60mil and solves in 71ms using js||
Little faster once the jit warmed up (and I wrote a slightly optimized version)
with the naive approach
meant to say: no optimization necessary, even if you took the worst possible solution || iterating through every race and calculating if it is won or not ||
that would be shockingly bad to completely ignore ||commutative multiplication|| at least
nah, it actually works okay
i expected it to not, which is why i didn't even try it, but after having a better solution (shockingly close to yours, actually) i tried it again
I mean yeah iterating every race definitely would work, it's just a waste of time lol
i absolutely expected it to not work
that's what he does, usually
naive gets you to 1, but p2 is off limits
My solution for p2 was ||brute force and it took only 60ms without logging||