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


buttons pushing robots pushing buttons 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: >>103596224
>>
yo dawg
>>
File: file.png (142 KB, 1200x1200)
142 KB
142 KB PNG
>>103604614
Show me your dance of death!
>>
>>103604619
>>
>>103604627
She's going to be dancing for a very long time!
>>
>>103604627
it's peak
>>
File: carbon.png (548 KB, 1724x3220)
548 KB
548 KB PNG
wew, just barely made it in time. Of fucking course sickness would strike on the hardest day so far.
Butt ugly but it works and is much faster than I expected.
>>
Man I really half assed my answer today. I gotta rewrite it to tabular.
>>
File: FJuts1NXwA4j9jY.jpg (38 KB, 680x680)
38 KB
38 KB JPG
>>103601988 #
did I say dijkstra? I meant Floyd warshall
Did I say Floyd warshall? I meant kruskal
Did I say kruskal? I meant bellman ford
Get on my level pytoddler
Where you at you sweaty ol tryhard? Post cheese-scented code bb and get on my level
>>
File: crazy-cat-insane-cat.gif (3.35 MB, 452x498)
3.35 MB
3.35 MB GIF
god damnit I can't figure out how to carry over all path subsets to the next level, I'm fucking filtered
I don't know why I can't think properly with this problem, my brain is a jumbled mess. if I store each instruction set into it's own array, on the next iteration it'd become an array of arrays since each instruction potentially gets its own array therefore it becomes an array of array of arrays and so on... aaaaaaaaaaaaaaaaaaaaaaaa

I can generate all paths between two buttons just fine but theres so many different things in my head about what to do next and none of it is coming into focus. going to try a dp tree pruning solution as my last hail mary and then i'll have to do this some other time, tomorrow maybe
>>
>>103604704
Did you solve day 11?
>>
>>103604704
same something about this puzzle just ruins my brain
>>
>>103604722
Yeah but I can't figure out how to properly apply the same logic. If group 1 has 3 possible paths, those need to be put together, not added to the larger group. So on the next iteration, when I go through paths I have to go through each of those individually but since everything has to be segregated you can't use the counting trick of day11 and just keep a count of how many times an operation occurs to prevent doing it multiple times... my head is spinning
>>
1 HOUR
>>
>>103604627
Kino
>>
>>103604793
You are late
>>
>>103604793
retard cant math
>>
FIFTY FOUR MINUTES AND TWENTY TWO SECONDS
>>
>>103604736
My approach was something like that
1) Literally store all movement strings and do the presses layer-by-layer. For the last layer of all the solutions find the shortest one. Slowish, but worked for part 1.
2) For each layer store only shortest solutions and feed those into the next one. Slightly faster, gave same results as 1), but failed even for 3 robot directional keypad presses.
3) Do the same as 2), but not layer-by-layer, but recursively key-presses by next layer key-presses and add memoization. Worked for up to some number of layers around 20, because I was still using movement strings.
4) Dont' use strings, but only the lenghts. Solved part 2.
>>
>>103604817
How can I learn this power?
>>
>>103604825
import time
>>
>>103604825
>look at time on computer
>press post button a second or two before the intended time
that's it
latency may fuck you by a couple seconds if you're unlucky
>>
>>103604823
>4) Dont' use strings, but only the lenghts. Solved part 2.
this part is confusing me, because it seems like you should be able to use lengths, but then dont you need the actual path to be able to map it to the next depth?
>>
>>103604859
Sort of, but the actual sequence has huge amounts of fractal repetition so you don't need to actually compute the entire thing
>>
>>103604859
Ok, to be more precise, I fed the keypresses recursively to the next layer, but got lengths back, not the actual keypresses themselves.
>>
>>103604704
okay I keep thinking about it and it keeps confusing me even more, I don't understand how the data is supposed to be stored. god damnit
>>
>>103604859
All you need is a from,to pair to iterate a path. My solution doesn't even use co-ordinates.
>>
>>103604938
oh well no chance im gonna avoid the filter in the next half hour
i'll give it another try after todays puzzle
>>
File: carbon(65).png (729 KB, 1522x3588)
729 KB
729 KB PNG
>>103604938
forgot pic
>>
I solved it the same way as the stones, where you just keep track of how many times each transformation occurs (a transformation being moving from one button to another and pressing it (you prioritize buttons closer to A in a tie))
>>
File: reimu-smug-thinking.jpg (321 KB, 1504x2048)
321 KB
321 KB JPG
any AOC++ leakers in chat?
>>
>>103604958
Pathfinding on a 2D grid 4
>>
>>103604964
you mean 5
>>
>>103604958
Brush up on Riemannian manifolds, and I think you'll be ok for tonight.
>>
>so close
>still didn't get it
this feels so much worse than not even understanding the problem. at least then I can just say there's nothing I can do, here I am fucking close and I could not get it. utterly disheartening
>>
>>103604958
Conway's Game of Life with a twist
>>
>>103605058
What would happen if you split your instructions after every A, and then iterated those individual groups down to layer 25, picking out the best one? Who knows....
>>
>>103605078
Delete this immediately. Eric works very hard on these puzzles and it is not acceptable for you to spoil them.
>>
>>103605058
Do you check all possible paths?
>>
>>103604285
Bigboy for Day 19.
https://files.catbox.moe/wd7m0x.7z
Silver: 1
Gold: https://files.catbox.moe/bsc8tt.txt

Aho-Corasick solves both parts under 0.5s
>>
>>103605080
gay larp
>>
dijkstra but 3d
>>
dijkstra today
>>
Aoc++ leaker here
Eric heard you guys loved grid puzzles, get your popcorns ready you will love today
>>
10 MINUTES
>>
dijkstra but 25d
>>
Do we want today to be easy or hard?
>>
File: 1733201676061642.png (453 KB, 1858x1829)
453 KB
453 KB PNG
Showtime
>>
>>103605124
easy if it's another grid problem
>>
TODAY WILL NOT BE A FILTER
>>
let me guess dungeons and dragons dicerolls
>>
>>103605124
As hard as possible to filter everyone.
Eric should show his iron fist or AoC will die.
>>
>>103605143
Seems like making it too hard would actually have the effect of killing it.
>>
>>103605107
THATS IT!!!! You and every one of you fuckers here are done for. I've arranged for each of you on your silly /g/ leaderboard to get VERY special inputs. You mess with reddit for the last time bucko.
>>
Today will be grid but "." is wall and "#" is safe
>>
>>103604958
the leaderboard for gold will be open for 2 hours
>>
>>103605146
jokes on you dildodragon I never joined the /g/ leaderboard
>>
>>103605141
Has there ever been an AoC problem that required probability? Something like
>simulate this dice roll game for the best score
>BUT if the probability of getting that exact score is under 1% of all possible games, don't use that strategy, the elves will know you cheated
>>
i hate recursion AIEEEEEEEEEEEE
>>
It's the 3D block puzzle today. It should have been yesterday, but Eric thought it was too hard, so you got the robots instead.
>>
>>103605152
no
>>
>>103604627
CUTE!
>>
mmm hand crafted directions that are the fastest
>>
>>103604627
would watch for hours
>>
File: showtime.jpg (46 KB, 640x480)
46 KB
46 KB JPG
https://www.youtube.com/watch?v=hjGZLnja1o8
>>
>>103605170
cancer music
>>
File: 1733918771573481.jpg (59 KB, 598x417)
59 KB
59 KB JPG
why does Eric hate brooters
>>
>>103605170
cancer music
>>
>>103605170
SHOWTIME
>>
>>103604704
I was stuck on this for a while. The way to recurse is something like this:
def expand(code, depth):
if depth == 0 : return len(code)
cur = "A"
total = 0
for i in range(len(code)):
total += expand(transition_matrix[cur][code[i] ]+ "A", depth - 1)
cur = code[i]
return total

This way, you drill right down to the base case first, Add memoization and you're good to go.
>>
>>103605170
kino music
>>
File: mokou-showtime.jpg (130 KB, 440x518)
130 KB
130 KB JPG
>>
>>103605170
kino music
>>
>>103605170
whats the picture even from
>>
>>103605173
Just use quantum computations, bro.
>>
>>103605170
everytime I see them I get incredibly erect and become unable to solve the puzzle
>>
I NEED TO SHIT
>>
>>103605181
if you have to ask you don't know
>>
>>103603871
const Ƶ = "029A 980A 179A 456A 379A".split(' ');
const Γ = {'7': 0, '8': 1, '9': 2, '4': 4, '5': 5, '6': 6,
'1': 8, '2': 9, '3': 10, '0': 13, 'A': 14};
const Δ = {'^': 13, 'O': 14, '<': 16, 'v': 17, '>': 18}
const ψ = (α, ω, Ϫ) => {
const m = α in Δ ? Δ : Γ;
const r = (m[ω] & 3) - (m[α] & 3), i = (m[ω] >> 2) - (m[α] >> 2);
const θ = '<'.repeat(r < 0 ? -r : 0) + '>'.repeat(r > 0 ? r : 0);
const Φ = '^'.repeat(i < 0 ? -i : 0) + 'v'.repeat(i > 0 ? i : 0);
if (12 === m[α] + r) return ϟ(Φ + θ + 'O', Ϫ);
if (12 === m[α] + i * 4) return ϟ(θ + Φ + 'O', Ϫ);
const a = ϟ(θ + Φ + 'O', Ϫ), b = ϟ(Φ + θ + 'O', Ϫ);
return a < b ? a : b;
};
let ξ;
const ϟ = (σ, Ϫ) => {
const Ȣ = σ + Ϫ;
if (Ȣ in ξ) return ξ[Ȣ];
return ξ[Ȣ] = Ϫ === 0 ? BigInt(σ.length) : Array.from(σ).reduce(
(Σ, c, i) => Σ + ψ(σ[(i ? i : σ.length) - 1], c, Ϫ - 1), 0n);
};
const Ʊ = (Ϫ, Σ = 0n) => (ξ = {},
Ƶ.forEach(σ => Σ += ϟ(σ, Ϫ) * BigInt(+σ.slice(0, -1))), Σ);
const silver = Ʊ(2 + 1), gold = Ʊ(1000 + 1);
console.log(silver, gold);
>>
>>103605186
that's how asking works, yes
>>
>>103605186
holy tautology
>>
>>103605186
well yeah
>>
>>103605183
>he doesn't use post-nut clarity to solve puzzles
Do you even compete?
>>
>>103605183
same
>>
>>103605186
No shit
>>
FUCK
>>
FUCK
>>
advent of math
>>
FUCK
>>
File: 24_D21_C#.png (1.19 MB, 2548x5364)
1.19 MB
1.19 MB PNG
Eh, Gave it a fair shake, but couldn't get it right in time.
>>
stonks
>>
>12 seconds solve
another free day for to_claude.txt
>>
part 2: simulate the 1000000000000000 secret number by detecting the cycle
>>
each day is turning into more of a word salad
>>
advent of reading comprehension
>>
yea I don't know wtf to do for p2
>>
>Advent of words words words words

Holy shit, I have no idea what part 2 is asking
>>
No seriously, what the fuck is part 2 asking for? I've now spent more time reading and rereading the problem than I spent actually solving part 1.
>>
>>103605308
you need to maximize the bananas you can get
>>
File: file.png (59 KB, 645x773)
59 KB
59 KB PNG
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
22 00:03:24 195 0 00:18:41 259 0

BROOTCHADS WIN AGAIN, TOTAL BROOTER VICTORY
>>
>>103605308
for every single sequence of 2000 numbers, determine what sequence of 4 differences in values of the first digit will result in maximum price if used to trigger a buy from every single monkey
>>
File: UNWASHED ASS.png (218 KB, 824x1657)
218 KB
218 KB PNG
UNWASHED POST ASS POST ASS UNWASHED ASS POST ASS POST POST UNWASHED
>>
Thread theme (iykyk)
https://www.youtube.com/watch?v=fako89vRIdk
>>
File: file.png (368 KB, 1202x2078)
368 KB
368 KB PNG
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
22 00:07:03 757 0 00:23:01 449 0

nice comfy one today
>>
im brooooooting
>>
File: D22.png (790 KB, 2400x3352)
790 KB
790 KB PNG
Unwashed Kotlin.
>>
File: day22.png (128 KB, 782x1174)
128 KB
128 KB PNG
for part2 I first iterated until all combinations were rreached, only to realize, that the 2000 from part1 still holds.
slow bruteforce.
Day       Time   Rank  Score       Time   Rank  Score
22 00:09:09 1198 0 00:28:36 744 0
>>
my brute force will only take 108 hours!
>>
File: day22clojure.png (516 KB, 892x795)
516 KB
516 KB PNG
Clojure isn't filtered yet
>>
Are there other anons who expected Part 2 to be
>Now calculate the 2000000000th number
?
I can't be the only one.
>>
>>103605439
i though it was gonna be unbounded instead of still 2000, and youd have to do some kind of cycle detection to figure out when you can stop
>>
>>103605439
yeah, I think there is still a lot of structure to exploit (?). would have been nice if the optimization was an "official" part and not just optimize it afterwards if you want.
>>
nice relatively easy day
Day       Time   Rank  Score       Time   Rank  Score
22 00:13:16 1964 0 00:38:14 1223 0

func main() {

var err error
var dat []byte
dat, err = os.ReadFile("./" + os.Args[1])
check(err)
fmt.Println()

init := make([]int, 0)

for _, vs := range strings.Split(string(dat), "\n") {
vs = strings.TrimSpace(vs)
if len(vs) <= 0 {
continue
}
n1, _ := strconv.Atoi(vs)
init = append(init, n1)
}

sum := 0
type seq struct {
a, b, c, d int
}
seqsets := make([]map[seq]int, 0, len(init))
allkeys := make(map[seq]struct{})
for _, s := range init {
// s = 123
fmt.Println("check", s)
s1 := s

tdeltas := make([]int, 0, 2000)
tprice := make([]int, 0, 2000)
price := s % 10
tprice = append(tprice, price)
seqperprice := make(map[seq]int)
for range 2000 {
ns := secret(s1)
nprice := ns % 10
delta := nprice - price
tdeltas = append(tdeltas, delta)
tprice = append(tprice, nprice)
s1 = ns
price = nprice
}
for i := range len(tdeltas) - 4 {
tseq := seq{tdeltas[i], tdeltas[i+1], tdeltas[i+2], tdeltas[i+3]}

_, ok := seqperprice[tseq]
if ok {
continue
}
seqperprice[tseq] = tprice[i+4]
allkeys[tseq] = struct{}{}
}

sum += s1
seqsets = append(seqsets, seqperprice)
}


msum := 0
for key := range allkeys {
tsum := 0
for _, m := range seqsets {
v, ok := m[key]
if ok {
tsum += v
}
}
msum = max(msum, tsum)
}

fmt.Println("sum", sum)
fmt.Println("gold", msum)
}

func secret(x int) int {
s1 := x * 64
s1 = s1 ^ x
s1 = s1 % 16777216
s2 := s1 / 32
s1 = s1 ^ s2
s1 = s1 % 16777216
s2 = s1 * 2048
s1 = s1 ^ s2
s1 = s1 % 16777216
return s1
}


>>
>works on example
>but not real input

My old nemesis. We meet again.
>>
>>103605439
I was expecting either cycle detection on unbounded rounds, or some DP stuff.
>>
>>103605436
lmao shitter, mine's only gonna take 55 hours
>>
>>103605473
Check your int sizes
>>
Brootforcers you are eating good today!
>>
You can definitely try to brute this one the wrong way.
>>
>>103605469
oh I am retarded. I used a hashmap for each value then sum the keys between the hashmaps.
I only need one hashmap per seq.
>>
>>103605482
Using python, so that shouldn't be a problem. And if it were, it should have screwed up part 1 too.
>>
File: d22.png (466 KB, 1492x3268)
466 KB
466 KB PNG
Now I can get back to day 21.
>>
>>103605502
oh no double retarded. I need a hashmap per value in order to get the first time a seq appears for that specific value. I just dont have to store them all. can merge after each value
>>
solution is halfway done....
>>
File: 1722732778698397.png (131 KB, 1729x490)
131 KB
131 KB PNG
BROOTBROS WE'RE SO BACK
>>
>>103605533
>Broot process killed (????? it wasn't allocating any more memory in the loop so idk what was going on here)
>The max number it spit out before completing was correct
HAHAHAHAH. WE DINE IN VALHALLA TONIGHT BROOTERS
>>
>example works but not real input
edgecase bros?
>>
File: 1711519041650714.png (34 KB, 371x764)
34 KB
34 KB PNG
takes about 30 seconds to run. Messed up at first because I forgot to check if the dict already had the value in it so I was overwriting with a later value
>>
File: 1729385908343.png (598 KB, 1396x3224)
598 KB
598 KB PNG
So... What is the smart way? I just made a hashtable of all patterns and it takes 17 seconds to run. Is there some trick?
>>
>>103605536
My solution >>103605510 runs in 10 seconds on a single core.
What are you doing? I already thought I was brooting it.
>>
>>103605572
Calculate the sums inline, then it takes 20ms.
>>
>>103605545
>edgecase bros?
What do you return if the price diffs never occur in the sequence?
>>
>>103605545
try changing 2000 to 2001
>>
>>103605575
probably not using a hash map. I tried that at first because I thought the memory usage would be too high but that was gonna take 50 hours
>>
>>103605575
I literally generated all [a, b, c, d] sequences and tested them in parallel, didn't even bother filtering the impossible ones. Left it running in the background just in case and it finished way faster than expected.
>>
File: shoot_2024-12-22_00:52:24.png (356 KB, 1209x2495)
356 KB
356 KB PNG
unwashed. Would it be safe to say that the final change in the input is always positive? or at least above -5 or something? Just to lower the search space a bit? or is that overfitting for the input.

My loop only makes it 80000 iterations through the space of price differences before my ram fillls up and the program crashes. I find that strange as all i am doing is updating the target price list and iterating through the same list again and again without creating any new variables. what exactly is python doing here to have a memory leak, and how do i prevent it?
>>
>>103605577
What do you mean? I didn't understand.
>>
>>103605578
that’s covered in the example
>>
>>103605596
is it just your env? I have a list of 2000 dictionaries with 2000 entries each and no problems
>>
>>103605596
I think you're expanding the defaultdicts as you keep looking things up in them that don't exist.
>>
>>103605575
>>103605593
real    2m51.238s
user 57m20.131s
sys 4m24.580s
>>
>>103605600
totals = {}
for monkey in data:
window = ()
seen = set()
bananas = monkey % 10
for _ in range(2000):
monkey = secret(monkey)
newbananas = monkey % 10
window = window[:-3] + (newbananas - bananas,)
if len(window) == 4 and window not in seen:
seen.add(window)
totals[window] = totals.get(window, 0) + newbananas
>>
>>103605627
ahhhhh that makes sense thanks anon.
>>
>>103605596
bro you literally just checked for every possible combination of sequence values
>>
File: 1721336055727915.png (1.09 MB, 1442x1281)
1.09 MB
1.09 MB PNG
>>
>>103605639
yes and?
>>
File: asuka-angry-shout.jpg (50 KB, 500x500)
50 KB
50 KB JPG
>waste hour trying to debug my code since part 2 doesn't work on the example
>just noticed that part 2 uses a different example from part 1
>code was working fine all along lol
ERIC YOU PIECE OF SHIT
>>
>>103605646
filtered
>>
>>103605648
had the same thing
>>
File: 1708091722802027.png (365 KB, 1264x3456)
365 KB
365 KB PNG
Sorry brootchads
I figured out the intended answer before the broot finished
>>
>>103605634
Oh, that makes sense.
>>
>>103605627
Yes i can confirm that adding a check to see if the target is in the dict eliminates the crash. Thanks anon!
Thank god I got the answer before the crash, It would have not been a fun hour of pruning attempts.
>>
>the monkey will only look for a specific sequence of four consecutive changes in price, then immediately sell when it sees that sequence
they're just like us
>>
>>103605651
Yes I check every combination and then filter out the answer, and my 2 gold stars.
>>
Anyone not even try out the example? Feels like today was too simple.
>>
File: carbon(66).png (288 KB, 1084x1616)
288 KB
288 KB PNG
>>103605648
are you me?

      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
22 00:16:36 2467 0 01:01:11 2259 0
>>
data = map(int, open("Day 22 input.txt", "r").read().strip().split("\n"))

sequences = {}
for i in data:
last = int(str(i)[-1])
state = i
deltas = []
seen = set()
for j in range(2000):
state ^= state*64
state %= 16777216

state ^= state/32
state %= 16777216

state ^= state*2048
state %= 16777216

deltas.append(int(str(state)[-1])-last)
last = int(str(state)[-1])
if len(deltas) > 4: deltas.pop(0)
if not tuple(deltas) in seen:
seen.add(tuple(deltas))
if not tuple(deltas) in sequences: sequences[tuple(deltas)] = 0
sequences[tuple(deltas)] += int(str(state)[-1])

print max(sequences.values())

Unoptimized. A bit ugly but gets the job done.
>>
>>103605648
same
>>
oh thank god
my code took over ten minutes to finish and it was RIGHT
NOT FILTERED
>>
>>103605689
What the fuck are you doing anon? Post UNWASHED ASS?
>>
What is the non broot way to determine good sequence values to check?
>>
>>103605699
You don't even need to check. See >>103605634
>>
>>103605701
oh I'm retarded this is much better. still not washing my ass.
>>
>>103605682
>int(str(state)[-1])
good god my brain really is fired, what the fuck was I thinking
>>
File: img-2024-12-22-07-11-26.png (949 KB, 4792x3452)
949 KB
949 KB PNG
idiomatic Rust solution
>>
ah fuck I though it said one digit
>>
>>103605720
Look, I did the same thing.
Sure, now that I think about it I should have just %10.
>>
>>103605722
Taylor?
>>
>>103605733
yes?
>>
File: file.png (35 KB, 594x407)
35 KB
35 KB PNG
>>103605572
>smart way
do a and b at the same time
hashmap of diffs (0,-1,1,2) to total score of that diff
>>
what if you give the monkeys a 0 length sequence?
market loophole?
>>
File: D22_washed.png (414 KB, 2200x1714)
414 KB
414 KB PNG
Washed Kotlin.
>>
>>103605756
my monkey doesn't store 0 length programs
>>
>>103605648
did the same thing
FUCK ERIC
>>
File: day22-mathematica.png (89 KB, 1473x897)
89 KB
89 KB PNG
Nothing clever about it. Merge was pretty useful.
>>
Retard here. Is there a fancy CS name for doing the iterations in a different order than the naive order? Is it just called memoization again?

for example today, instead of iterating through every monkey for each price window, you can flip that around and keep a map of each price window for each monkey.
Does changing the order in which you do things to reduce iterations like this have a name?

Sorry for not communicating this comprehensibly. I only got 2 hours of sleep thanks to yesterdays robot problem.
>>
>>103605771
>keep a map of each price window for each monkey
That's called precalculation. It's not memoization, because you don't reuse the values.
>>
File: Capture.png (75 KB, 690x382)
75 KB
75 KB PNG
LLMs are back baby
>>
>>103605794
eric is a KEK for saying "umm.. don't use LLMs please!" without having a way to enforce it
>>
>>103605794
they're just really fast coders
>>
>>103605794
Not many jeets and mohammads, maybe it required a more expensive model?
>>
>>103605771
>>103605779
>instead of iterating through every monkey for each price window, you can flip that around and keep a map of each price window for each monkey
I thought about it a bit more and it's called indexing. Databases do this stuff all the time.
>>
>>103605807
>pays 200$ for o1 pro for a meaningless online competition
>>
>>103605813
maybe they already pay for o1 for other stuff
>>
yearly cope thread just dropped
https://old.reddit.com/r/adventofcode/comments/1hjiaul/i_stopped_with_aoc/
>>
>>103605813
Saar, prestigious leaderboard is gateway to opportunity my guy.
>>
>>103605794
It kind of creeps me out that LLMs have developed to the point where they can decipher erics wall of text without 'forgetting' key details.
>>
>>103605818
Thanks for the laugh.
Not sure why you have to announce shit like that. seems very narcissistic
>>
My stupid fucking ass messed up reading the problem statement twice today... First was thinking to use the first price of the sequence and the second was not realising the example input changed from 1-10-100-2024 to 1-2-3-2024...
>>
>works on example
>too high for real input
>>
>>103605818
It's not a fucking airport, you don't have to announce your departure.
>>
>>103605176
thanks, finally got me to the finish line. still feels bad that I needed to look at a solution essentially but oh well, it's not nagging in my mind at least
>>
>>103605818
Hahhaahahah. Why is reddit such a retarded hug box. If somenone posted this here, the absolutely kinding thing you'd get would be "Filtered!"

>Like every year, around this time, I stop participating in AoC for two reasons:
>I have too many other things to do with family and holiday shenanigans.
I-I-I c-could solve it, I just choose not to. You know, unlike you guys I have a life. Couldn't be me sitting there doing this crap... heh

>It gets too complicated, so I’ll probably solve it sometime next year—or maybe not!
Change that to definitely not you colossal incorrigible nigger brained faggot
>Either way, I absolutely love these first two-ish weeks of this challenge and this community!
Fuck off faggot
>>
>>103605818
all of them are me btw
this year just wasn't fun i stopped doing puzzles at day 10
>>
>>103605835
check your loops 2000 or 2001
check you are not cross pollinating your hashmaps
>>
>>103605847
shut the fuck up nigger this year was ass
>>
>>103605828
its a measure of self delusion
>yeah i totally would have finished but im just too busy
by announcing it publicly they think other people will believe it too thus reinforcing their own delusion
>>
>>103605818
what a non straight comment to make
>Relax... breath in, breath out.....
>Give it some time, and don't forget to read the solution threads to get you some inspiration :D
>>
>>103605858
i used to skip my lunch break and use that to do AOC. a little later i realized its not worth it
>>
>>103605854
Filtered IQlet.
>>
>>103605876
delusional eric cocksucker
>>
>>103605868
It starts at 7am here. I just went to work and did it there. nobody bothered me and nobody cared
>>
File: bqn.png (150 KB, 1284x1018)
150 KB
150 KB PNG
BQN trivialized part1 but on part2 I got hit again by not yet understanding search functions in this language beyond filtering with a mask
33s brute
>>
>>103605854
>this year was ass
It was definitely too easy.
As in, only Day 21 had a difficult puzzle.
>>
File: file.png (14 KB, 904x78)
14 KB
14 KB PNG
Why is eric such a nigger? How fucking hard can it be to include a test case where a later occurence of the diff sequence has a lower banana count
>>
File: 1628326187410.png (455 KB, 1076x2442)
455 KB
455 KB PNG
This is still ~5 seconds, but I guess it is because I use bigints (js has retarded numbers).
>>
File: out.webm (1.03 MB, 800x450)
1.03 MB
1.03 MB WEBM
Actually, As long as all of the brighest unfiltered minds of /g/ are in one place and I have the attention of all of you algorithmGODS. I could use your help for my own purposes.

Imagine the elves have set up a 3d grid problem, with objects that take up positions on the 3d grid.
The objects have velocity, and a bounding box that can be set slightly larger than the space they take up (for example, an additional +1 in each direction )
The objects do not have access to a global list of all objects, and only know about objects within their bounding box

Design an *efficient* algorithm that can detect collisions between these 3d objects, and can propagate their velocity to things down the tree to be pushed in a way not unlike the sokoban problem.

(PART 2: Objects are processed IN A RANDOM ORDER) (right now I am just doing the calculation in multiple steps)


Right now its basically just a shitty broot and could never scale to be actually usable. are there any fancy algorithms that can help?
I was thinking keeping a list of the "edges" of each object for each face, and then I would only have to check collision certain faces depending on the velocity of the colliding objects. but this is surely a solved problem right?
>>
>>103605941
>Expecting shit from Eric
See your mistake
>>
>>103605956
>Design an *efficient* algorithm that can detect collisions between these 3d objects, and can propagate their velocity to things down the tree to be pushed in a way not unlike the sokoban problem.
I did this in uni, it's called "impact-based collision resolution".
You can read about it here:
https://www.plasmaphysics.org.uk/print/collision2d.htm
>>
>>103605982
Thank you, I love you
>>
why is everyone hating on Eric this year
>>
>>103605983
Sorry, it's not impact-based, it's impulse-based.
You get the impulses of the objects, project them on the collision normal, and then use some formulas to calculate the new velocities.
https://research.ncl.ac.uk/game/mastersdegree/gametechnologies/physicstutorials/5collisionresponse/Physics%20-%20Collision%20Response.pdf
>>
>>103605987
>this year
>>
>>103605987
he's failed to filter the haters, so they're still here
>>
>>103605818
A lot of salt to mine from that thread.
>I couldn't figure out today either. Not even part 1. I feel like such an idiot and a failure. With the test cases I kept getting 68, 60, 68, 64, 68. That final test case for 397A I just could never get right. I really struggle with this stuff too. It's lowkey demoralizing on here seeing how people are like yep part 1 ez pz. I just try to think about how people who didn't figure it out probably aren't posting here so only the people who know what's going on are going to be posting. And I'd also like to believe that the majority of people struggled, but I'm probably just really bad so. Idk I'm with you I think I might stop It just makes me feel bad spending literally the whole day and getting stumped on a problem that is supposed to be a little game that people are golfing into oblivion.
>I'm also unsure what today's problem difficulty would be if it were on leetcode. If people consider this to be a leetcode medium then I probably need to find a new career.
>>
>>103605988
The projecting thing seems like what I was thinking with the faces of the object. Glad to see i was somewhat on the right track. This will be very very helpful.
>>
>>103605941
read nigga
>>
>>103605941
Retard
>>
>>103605818
>I feel you. I wish AoC was more about "consistency", but unfortunately there are always some really hard problems, which discourage people from participating. I have lots of friends who tried before and now they don't want to because they say they simply don't have hours to spend on the puzzles. To make it worse, usually those insane problems come up on the last days, when people are already busy with Christmas.
>>
>>103606018
>usually those insane problems come up on the last days, when people are already busy with Christmas.
Are Redditors even aware that this is by design?
Eric wants the Stats page to look like a Christmas tree, so of course he puts trivial puzzles in the beginning and the mind-breaking math puzzles near the end.
>>
>>103605851
Thanks. Fixed. I actually didn't read properly and was maximizing considering the monkey wasn't going to necessary sell at the first occurrence.
>>
>>103606018
I just threw up in my mouth reading that. The depressing thing is that Eric get all his feedback from reddit and they are directly responsible for the trajectory of AoC
>>
>>103606018
Ah yes, a totally better design would be to start with the insane puzzles so everybody just quits immediately because they aren't invested
>>
>>103606018
It's true tho
>>
>>103606029
imagining him filtering 90% of people just too feed his OCD sounds pretty based.
>>
File: retardbtfo.png (128 KB, 1501x663)
128 KB
128 KB PNG
>I came here to cheat, and you're just having fun!!! This is about MEEEEEEEEEE.
>>
>>103605956
>Design an *efficient* algorithm that can detect collisions
About this part - you can always use an Octree to index the objects by their coordinates. Then for every object you calculate its Axis-Aligned Bounding Box and query the Octree using this box. Every object returned by the Octree has a collision with the querying object.
https://en.wikipedia.org/wiki/Octree
https://en.wikipedia.org/wiki/Minimum_bounding_box#Axis-aligned_minimum_bounding_box
>>
File: lain.png (982 KB, 1200x700)
982 KB
982 KB PNG
holy fuck got my star. that day 22 wasn't too hard but fuck me reading erics soup is a pain
>>
>>103605941
> can't read
> gets angry
kek
>>
>>103606055
>filtering 90% of people
If you compare Day 21 to Day 1 he is already filtering 96%.
I assume it will be closer to 98% when we approach Day 25.
>>
Holy fuck I can think of like five things to do with xorshift (the simplest would be to raise the limit to 2^64 and let people calculate the 9999999999999th number), but this is the best part 2 he could do?
Eric has given up.
>>
>>103605854
A lot of similar problems this year. Grid on grid on grid.
Still enjoyable being here.
>>
can we improve this /g? i'm not that good with assembly
long get_next_num(long cur_num)
{
cur_num = (((cur_num << 6) ^ cur_num) % (1 << 24));
cur_num = (((cur_num >> 5) ^ cur_num) % (1 << 24));
cur_num = (((cur_num << 11) ^ cur_num) % (1 << 24));

return cur_num;
}


long get_next_num(long cur_num)
{
cur_num = (((cur_num << 6) ^ cur_num) % (1 << 24));
cur_num = (((cur_num >> 5) ^ cur_num) % (1 << 24));
cur_num = (((cur_num << 11) ^ cur_num) % (1 << 24));

return cur_num;
}
>>
What's the smart person way to do part 2 today? I just logged frequencies and threw in the most common patterns until I had a biggy.
>>
>>103606064
Seems promising, thanks anon.
>>
>>103606102
same anon
get_next_num:
mov rax, rdi
sal rax, 6
xor rax, rdi
cqo
shr rdx, 40
add rax, rdx
and eax, 16777215
sub rax, rdx
mov rdx, rax
sar rdx, 5
xor rdx, rax
mov rax, rdx
sar rax, 63
shr rax, 40
add rdx, rax
and edx, 16777215
sub rdx, rax
mov rax, rdx
sal rax, 11
xor rax, rdx
cqo
shr rdx, 40
add rax, rdx
and eax, 16777215
sub rax, rdx
ret
>>
>>103606102
can we improve this /g? i'm not that good with assembly
just pre-generate a big lookup table for all possible input values, its bounded by the module, so it should be fine.
next, you can pre-generate all the 2000 values for each starting value and embed that table in your program.
So any input is just a simple lookup away.
>>
>>103606103
thats it.
well done you are smart.
>>
>>103606103
Pretty much same, for every value I just stored the last 4 diffs into a cache + whatever the value it has was, making sure to only add to the cache if the 4 diff sequence doesn't already exist in it. then after all the sequences are done I just combined the caches together and picked the largest.

I am not fully sure you can get that much faster. because for every sequence of 4, you NEED to check it against all other sequences to determine how many bananas it provides, and there's no way to prune a sequence on an individual basis because like in the example, the solution one had one sequence it didn't even appear in, so just because it's low for the current sequence doesn't mean it will be for the others. If there's a smarter way I certainly can't figure it out
>>
>>103606102
the second modulo is redundant because the first line is selecting the first 23 bits, and then the second line shifts that right by 5 bits before the selection, so it will always be 17 bits long at most meaning doing a modulo for a higher value is always going to return itself so there's no point in doing it
>>
>>103606134
there might be some mathematical way to do it
>>
File: day22.png (66 KB, 830x569)
66 KB
66 KB PNG
BQN day 22
>>
>>103606102
z3 couldn't do anything with it
Mathematica anon should try, I think it's better at that kind of thing
But it also looks like a hash function so probably not much to do
>>
>>103606103
There is a way to prune the search early.
>find all price diff sequences that actually occur
>for each sequence calculate how many monkeys will see it
>process sequences in the order of the number of monkeys who can see it (from max to min)
>the max value for each monkey is 9, so
if (9 * monkeys < maxValue) break
>>
>bruteforce is too broot
>optimised version doesn't work
manifests as an off by one on prices but comparing outputs I'm not sure why the broot solution works because the logic is exactly the same
>>
>>103606117
But you need all the diffs too which makes the table too big
>>
>>103606134
thanks for clarifying that. I was doing it manually but calculating them as you go and throwing in a hashset so you don't over add to the frequency is way nicer code. thanks!
>>
>>103606201
see
>>103606103
>>
>>103606210
how much could it be?
>>
>>103606227
71GB
>>
>>103606210
>>103606227
It's just 10000 Bytes for each monkey and there are less than 2000 monkeys.
Your computer can allocate 20 MB of memory, right?
>>
>>103606238
You don't know which monkeys they are in advance though
There are 2^24 possible monkeys
>>
>p2 works on sample
>too low on input
I don't get it, am I missing some weird edge case? it should just be greatest total and we only count the first instance of a particular sequence per buyer?
>>
>>103606142
well one revelation that is maybe moderately helpful is that for any input number, the output number's final bit will be equal to the 6th bit of the input number
>>
>>103606238
>10000
It's 20^4 = 160000
But the point still stands, 320MB of memory is nothing.
>>
>>103606241
>>103605941
>>
>>103606117
https://github.com/PaigePalisade/AdventOfCode2024/blob/main/Solutions/day22part2.c
>>
>>103606241
the 4 long diff sequence can appear multiple times in a secret sequence, so make sure you only store the first time it appears and not the largest time it appears/any other times
>>
>>103606265
>>103606273
>>103606276
third try's the charm, ey anon?
>>
>>103606276
>>103606273
>>103606265
retard stop
>>
Future GF just asked me how well I place in these competitions.
What is the optimal answer here?
If I say I place it well she'll think I'm autistic and if I say I place it low she'll think I'm dumb.
>>
>The monkey that stole the device seems willing to trade it, but only in exchange for an absurd number of bananas.
>my gold answer is between 2000 and 3000
I don't think we're getting that device back
>>
>>103606236
there are computers with 1TB ram. this seems trivial
>>
>>103606290
just tell xir you use rust and youre in
>>
>>103606258
not sure what I should do with this, but good job.
>>
today would benefit from a big boy
>>
>>103606290
Tell her that you are not really trying to do puzzles asap, but you are staying non-filtered, as a reasonable man should.
>>
>>103606292
Reading a sequence from memory is probably slower than computing it as you go though
>>
>>103606290
just say around 200k people participate you finish around top 2-4k each day.
a top 2%er is good enough for her?
>>
>>103606142
thinking about it more, I'm not fully sure you can, maybe you can prune some earlier. for instance, if you just calculate the absolute diff change over the 4 by adding up all the numbers you can see how likely it is that this diff pattern will produce a high number over the course of all sequences. for example a diff of -9 0 0 0 would definitely not because that's always going to be 0 bananas
of course, I think with my previous response regarding the bits, there is probably a pattern you can observe or predict with sequences and that some sequences will just never appear but I still don't know if there's truly a proper algorithm or if you just can do small improvements to the existing one
>>
>>103606283
>>103606282
>>103606276
>>103606273
>>103606265
what was it, post it again
>>
>>103606198
If you're finding all the price diff sequences that actually occur, you're already finding all the monkeys that actually see them and how much it'll be worth for them.
Then you just have to check the worths of each sequence.
>>
>>103606290
tell her that you're having a blast and you're competing with some of the best people in the world
puffing up competitors is puffing yourself up as one of the competitors
that you're doing well implies that you're doing well
>>
File: img-2024-12-22-08-53-20.png (163 KB, 944x1557)
163 KB
163 KB PNG
>>
>>103606238
>Your computer can allocate 20 MB of memory, right?
My computer can. My GBA can't.
>>
>>103606333
basedboy! show em how its done
>>
Brootbros... I did it
>>
File: c22.gif (65 KB, 1245x955)
65 KB
65 KB GIF
C
>>
File: day22.png (63 KB, 854x558)
63 KB
63 KB PNG
>>103606143
3x speedup by swapping order of XOR and modulus to avoid need for the hacky >32 bit XOR.
>>
>anons actually calculating the second modulo despite it doing nothing due to the previous modulo and bitshift
wasted compute power...
>>
Nobody solved day 21
>>
Day 22 big boy
Monkeys: 1000000
URL: https://files.catbox.moe/v8kxrj.txt
Silver: 8385838872479
Gold: 879695
>>
>>103606399
I'm a complete brainlet when it comes to bit manipulation math.
I just do what what Eric tells me.
>>
File: 24_D22_C#.png (594 KB, 2372x2386)
594 KB
594 KB PNG
Good Morning sirs!
>>
>>103606399
It has no effect on my runtime
>>
>>103606408

See: >>103605190
Copy and paste into the browser console and verify against: >>103603871
>>
File: 1716213502732885.png (37 KB, 1123x559)
37 KB
37 KB PNG
>>103606399
>>
>>103606425
The compiler knows when it can discard such an unnecessary operation.
>>
Calculate the result of multiplying the secret number by 64. Then, mix this result into the secret number. Finally, prune the secret number.
Calculate the result of dividing the secret number by 32. Round the result down to the nearest integer. Then, mix this result into the secret number. Finally, prune the secret number.
Calculate the result of multiplying the secret number by 2048. Then, mix this result into the secret number. Finally, prune the secret number.

ambiguous question, is this the next number or the next 3 numbers?
>>
>>103606433
see? you're wasting the compiler's time on this!
think of the planet!
>>
>>103606441
>After this process completes, the buyer is left with the next secret number in the sequence.
>>
>>103606441
>In particular, each buyer's secret number evolves into the next secret number in the sequence via the following process:
This implies that the whole process is one evolution step, so it's the next number
>>
>>103606430
I "solved" it, but there's an assumption everyone makes that nobody can justify.
>>
File: img-2024-12-22-09-17-22.png (95 KB, 1280x636)
95 KB
95 KB PNG
>>103606433
>>
>keep tweaking code
>can't produce anything but the same wrong answer
going insane
>>103606441
it's three steps to produce one next number
>>
>>103606399
And know the compiler should realize that and now me, right?
>>
>>103606451
>rust
LMAO, so slow.
>>
>>103606450
There are no assumptions, it checks all valid possibilities.
>>
>>103606451
Poast godbolt
>>
>>103606500
https://rust.godbolt.org/z/qvG1d8Yed
>>
>>103606450
what assumption?
>>
>>103606450
If you're not trolling then you truly don't understand the problem
>>
> part 2
words words words arghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
>>
File: carbon.png (760 KB, 1802x3724)
760 KB
760 KB PNG
Washed Java.
>sells at first sequence (not best)
>i.e. computeIfAbsent(), not merge(... Math::max)
Tip: after you read something remember it!
>>
File: file.png (73 KB, 1383x658)
73 KB
73 KB PNG
>>103606504
There's not even any point to being clever, with % you get the 2-mod codegen https://rust.godbolt.org/z/7oh7z4PnM (foo3 collapses into foo2)
>>
File: img-2024-12-22-09-37-32.png (151 KB, 1657x877)
151 KB
151 KB PNG
>>103606543
lmao
>>
File: day22.png (468 KB, 1860x3387)
468 KB
468 KB PNG
Modern C++, been busy last few days couldn't post
>>
File: image.png (321 KB, 846x454)
321 KB
321 KB PNG
my humble BQN solution for day 22

takes like 5 sec to run though. i wonder what the efficiency trick today is. i assume it's cycle detection so that you don't need to calculate all 2000 stream?
>>
>>103606618
there is no cycle. the transform is invertible, so it cycles through all 2**24-1 options
>>
>>103606629
you don't care about the whole output though, only the bottom ~4 bits for gold. it's possible that the bottom bits have lower period than the top bits.
>>
>>103606618
Use a plain array instead a map, it must have the same dimensions independently of the input size or number of secrets generated. Only the array type is affected, 32 bits is enough for the problem but the big boy needs 64 bits.
>>
File: gawk22.jpg (150 KB, 920x1058)
150 KB
150 KB JPG
This is gawk because regular awk doesn't have xor
>>
>>103606643
no mod 10 is not the same as bottom 4 bits..
every bit can have an influence on the mod 10 result. remainders are 1,2,4,8,6,2,4,8,6,....
in theory it's possible for there to be a smaller cycle since 2**24-1 is not prime
>>
>>103606657
>regular awk doesn't have xor
lmao
>>
>>103606663
>>103606643
just checked all divisors and sadly there is no smaller period for the remainders
>>
I am brooting this shit and there is nothing you can do to stop me.
>>
>>103606818
broot on brother. Today is your day.
>>
>>103606818
today is one of the more brootable days of late
>>
To be fair, you have to have a very high IQ to excel at Advent of Code. The later challenges are extremely intricate, and without a solid grasp of advanced algorithms and data structures, most of these puzzles will go over a typical coder's head. There's also the problem-solving outlook, which is deftly woven into each challenge- the complexity draws heavily from computer science literature, for instance. The participants understand this stuff; they have the intellectual capacity to truly appreciate the depths of these puzzles, to realize that they're not just trivial grid exercises- they say something deep about LOGIC and CREATIVITY. As a consequence, people who dislike Advent of Code truly ARE missing out- of course they wouldn't appreciate, for instance, the elegance in a dynamic programming solution, which itself is a cryptic reference to foundational principles in computer science, nor the engaging story that ties all the puzzles together. I'm smirking right now just imagining one of those addlepated simpletons scratching their heads in 'filtered' confusion as Eric Wastl's genius unfolds itself on their screens. What fools... how I pity them.
>>
>>103606869
all of the CS-theory in the world can't prepare retards from not reading the problems correctly
>>
Hmm, I've got it working on the examples for Part 2 but not on the input
What could I be missing?

What I've done is for each secret, created a map of each sequence of price changes, then taken the best possible value (for that secret)
Then, I add all the best possible sequences together in another map, which should have the max value of bananas I could get total for a given sequence for all secrets

[spoiler]Nevermind I figured it out while writing this, I was taking the best sequence from each secret, but the monkey sells the first time it sees the sequence so I should only store the first value of each sequence I see[/spoiler]
>>
>>103606884
case and point
>>103606908
(but good job for spotting it yourself)
>>
>>103606818
godspeed
>>
File: Day-22.png (1.92 MB, 3368x6480)
1.92 MB
1.92 MB PNG
Finally a simple day that result in relatively low number of lines that can be shown here.
>>
>>103607086
>Finally a simple day
Makes it sound like it hasn't been mostly simple days so far.
>>
>>103606498
You can't solve 21 without assuming properties of how low level moves affect higher level moves.
>>
>>103607105
you can. I did. You just encode all char to char moves and top down DP to get the shortest sequence.
>>
>>103607105
That's incorrect. If you break down the problem correctly you don't need any assumptions to the DFS the values.
>>
File: Day22.png (132 KB, 976x1159)
132 KB
132 KB PNG
C#. Bit slow, but gets the right answer so I'm not complaining.
>>
only three more puzzles /aocg/
I'm not ready to say goodbye...
>>
>>103607105
If you group the moves up to an A, you break the problem into subgroups which do not interfere with each other in their expansion.
>>
idiomatic solution

let MASK = 2**24 - 1

function step(k) {
k = (k ^ (k << 6)) & MASK
k = (k ^ (k >> 5)) & MASK
k = (k ^ (k << 11)) & MASK
}

let totals = %{}

for k in slurp().words().map(int) {
let prices = [k, *step.iter(k).take(2000)].map(${it % 10})
let deltas = prices.window(2, [-])
let yields = %{}

for sequence, i in deltas.window(4) {
yields[tuple(*sequence)] ?= prices[i + 4]
}

totals.update(yields, [+])
}

print(totals.values().max())
>>
File: Day22.png (163 KB, 858x1385)
163 KB
163 KB PNG
>>103606424
>>103607139
How fast is your solutions, saars?

Task 1: 14869099597
Task 2: 1717
Day 22 finished in 00:00:01.0640586
>>
>>103607222
Nearly 10 minutes lol. I don't really care though. I got the right answer and it's too close to the end for me to care about optimizations and proper CS concepts anymore.
>>
>>103607195
this is not rust?
>>
>>103607195
based and idiomatic
>>
>>103607195
kino
>>
>>103607195
>
*step.iter(k)

That's a pretty neat feature.
>>
>>103607222
Mine (>>103607139) coughs up the answer for part two in about 30 seconds.
>>
Any hints on Day 21? I tried a table driven approach, but apparently the way you choose to move across the keys does actually matter. I though you could just move in any way and it would generate a best string of moves.
>>
>>103607287
its like the blinking stone problem, but you dont get the 'moves' between each state. you have to figure them out.
>>
>>103607287
Filtered
>>
>>103607222
Go

$ time go run main.go input 
19822877190
2277

real 0m0.761s
user 0m0.822s
sys 0m0.128s
>>
I know it is a meme at this point, but it is insane to me how many people just can't read the problem.
> been struggling for 2 hours
> *copy and paste text from the problem*
> oh I missed that part

lol wtf.
like 80% of all posts for the day on the aoc subreddit is just people that are asking for help because they can't read.

and for those people, I got you senpai
> go back to plebbit
>>
>>103607363
Visiting reddit as a source of comedy is more than acceptable; even better if you can mine some salt.
>>
File: You may not parse.png (102 KB, 1309x572)
102 KB
102 KB PNG
>Filtered by parsing.
>>
>>103607340
Yeah, pretty much. Still want to try to get the stars though.
>>
File: Capture.png (57 KB, 1101x722)
57 KB
57 KB PNG
>>103607366
This was quite funny today.
I had a co-worker that on the first sign of a bug in his code his first suggestion is something is wrong with the linux kernel and he should start debugging it.
99.99% of the time he just misread the documentation and it was like a one/two line fix.
>>
>>103607377
there hasn't been a single difficult parsing day this year
>>
>>103607401
agreed.
>>
>>103607401
there has been like one parsing day at all this year that wasn't just split newlines/commas
>>
File: xarbon.png (10 KB, 716x388)
10 KB
10 KB PNG
compact python
Another shitty day, only good problems until now were d14 p2 and d21
>>
>>103607377
>input.txt
>manually copies the other half into input2.txt
Heh nothing personal eric
>>
>>103607401
it's easy to blow a lot of time depending on your tools and how you use them. People who try to maintain good programming practices and reusable code can especially get hit hard. One year I did Ada and every input I massaged into Ada code that I compiled in directly, Advent of Never Ever Parsing.
>>
>>103607413
that one was easily solved by split functions though lol
>>
>>103607433
I've used Ada for a few years, but for convenience I built a simple parsing library around their standard library. IIRC it was a File_Stream object I could request Next_Integer, Next_Line etc.
>>
File: Ada.png (95 KB, 963x593)
95 KB
95 KB PNG
>>103607471
For example.

I like Ada a lot, but it's strengths are not terribly useful for these types of problem.
>>
File: file.png (635 KB, 1988x2496)
635 KB
635 KB PNG
>went back and finished day 21
man it really wasnt as bad as it seemed, i was so close to doing it properly yesterday but had subtle errors then just massively overthought it and choked
>>
>>103607513
it's strangely decent at grid hardcoded-input grid problems as you can use ranged types that exactly fit the grid, and your characters can be enums instead of bytes.
>>
>>103607557
True, and such types are very good for a lookup table without resorting to something like a hashtable. The problem is that I feel like I'm "software engineering" in Ada, whereas in a faster "prototyping" language I can do everything you see in that image in one line. Perhaps Ada is more fun as a second language to solve things in, after working them out in another. I plan to make a graphing library with it at some point.
>>
File: cga_pepe.gif (2 KB, 320x200)
2 KB
2 KB GIF
>>103607377
100% laziness. One only needs a few helper functions and parsing become one liners, specially in C++ that allows to overload operators.
>>
File: file.png (182 KB, 1600x900)
182 KB
182 KB PNG
Now back to yesterday's puzzle
>>
>>103607665
>helperfunctions
Its like 4-10 (maybe) lines each day. How lazy can one be?

Lets face it, even if there is NO 'parsing' necessary, there WILL be another excuse
>>
File: image.png (215 KB, 800x287)
215 KB
215 KB PNG
>>103606618
golfed down my humble BQN solution quite a bit.

also made it much faster (5s -> 0.7s) by just doing the xor on arrays instead of scalers. i suppose scaler xor just has too much interpreter overhead (?)

>>103606647
> Use a plain array instead a map
which one? i got rid of the seen map. but i still keep the prices/scores map to track the score of each delta sets.
>>
>>103607686
mis ojos
>>
File: 1718197147229076.jpg (32 KB, 657x527)
32 KB
32 KB JPG
>>103606414
Silver: 8385838872479
Gold: 879695
default: 11452441.970214844ms
default: 3:10:52.446 (h:mm:ss.mmm)
>>
File: aoc24_22.png (242 KB, 718x1826)
242 KB
242 KB PNG
Odin
Got the answer doing a semi-broot which took 60 seconds, but this version runs in 923 ms
>>
File: carbon.png (423 KB, 1584x2116)
423 KB
423 KB PNG
>>103606414
Took 9.5s, the regular input takes ~19ms.
I'm getting 8385838872479 and 879232. Are you checking if it's the first occurrence of the pattern?
>>103607873
Based, I wanted to double check with python but it took 40 minutes and ~50GB ram and I put it down.
>>
>>103606399
I hope you realize local pod variables are cheap.
Each step goes into a separate variable. This will actually help you while debugging. And with -O2 it's gone, optimized out.
You don't have to be a tryhard with quirky oneliners.
https://lapcatsoftware.com/blog/2009/12/19/local-variables-are-free/
>>
>126384
>154154076501218
I am stupid close to result for day 21 now.
>>
>>103606414
using >>103605414 I get the same answers as>>103608114 in about 20 seconds.
for the bigboy precomputing the whole 16 million element cycle would probably be wort it...
>>
I get the bigoy anon's answers with >>103605722
>>
>>103606414
>>103607873
>>103608114
>>103608199
>>103608228
oh boy, this is another 0 length file situation, isn't it?
>>
>>103605722
What is FastHashMap?
>>
>>103608242
Just std HashMap with a faster hasher
>>
>>103607287
See >>103604194
In short, the optimal path involves grouping together the same key presses, and the order in which you perform the moves depends on how expensive it is to move in that direction on the keypad at higher levels (with the most expensive keys being pressed first). The only exceptions will be when travelling the optimal path results in you going off the keypad, in which case you need to do the horizontal and vertical moves in the opposite order to stay on the keypad.
>>
File: d21.png (883 KB, 2430x4674)
883 KB
883 KB PNG
I'm free.
>>
>>103608232
okay now i >>103608199 also get 879695 for part 2 . turns out I only did 1999 iterations...
>>
File: retvrn_to_monke.png (549 KB, 2048x2420)
549 KB
549 KB PNG
I return to monke
>>
>>103608354
Makes sense, I've done the same.
>>103606414
I'm now getting 879695 as well after I've moved stuff around
        for _ in 0..3 {
prev = num % 10;
num = next_num(num);
(a, b, c, d) = (b, c, d, 9 + (num % 10) - prev);
}

for _ in 3..2000 {
prev = num % 10;
num = next_num(num);
(a, b, c, d) = (b, c, d, 9 + (num % 10) - prev);
let i = 19 * (a * 361 + b * 19 + c) + d;
if totals[i].1 <= monkey {
totals[i].0 += num % 10;
totals[i].1 = monkey + 1;
}
}
>>
>read part 2
>makes no sense
>AI cucks solved it in rougly 40 seconds.
ffs.
>>
Page ten emergency bump!
>>
>>103608593
based thread saver
>>
new thread
>>103608634
>>103608634
>>103608634
>>
last for dijkstra day 23 and dijkstra day 24

and also dijkstra day 25



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