Toot

Written by Walker Boh🛡 on 2024-12-22 at 15:34

Day 22 #adventofcode in the books.

Part 1 was to apply a convoluted mutator function to a (large) set of given numbers 2000 times and then sum the results.

My first thoughts on seeing this were "thats a lot of compute" and "looks like a factorial again...", so I memoized the mutator function. Memoization is just a fancy way of saying "cache previous results".

This worked.

Part 2 was to then extract the last digit (the 'price') of each of the 2000 generated codes for each of the initial codes, and then extract the changes in price between each set of prices.

Finally you had to find the four consecutive changes that preceed the maximum you could extract from the price matrix based on it.

Again this sounded like a lot of repetitive compute, so I memoized the summing function.

Even memoized it took 3 minutes to run, but worked.

As I was working with #typescript and the initial codes were already large, I preemptively went bigint. Not 100% sure it needed it, but I didn't want to find out the hard way I was wrong.

=> View attached media

=> More informations about this toot | View the thread | More toots from walkerb@infosec.exchange

Mentions

Tags

=> View adventofcode tag | View typescript tag

Proxy Information
Original URL
gemini://mastogem.picasoft.net/toot/113697205844533974
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
226.46718 milliseconds
Gemini-to-HTML Time
0.454329 milliseconds

This content has been proxied by September (ba2dc).