Ancestors

Toot

Written by Walker Boh🛡 on 2024-12-19 at 15:00

Day 19 #adventofcode in the books.

You were given a set of strings and tokens and you had to find out which of the strings could be made from the tokens.

Sounds simple right ? Except the tokens are variable lengths and some of the longer tokens can be contained in constructs of the shorter ones, so simple check/replace is out...

Tried a few different things before I came to a recursive solution, that worked but was too slow for the real data.

So it was time to break out DP.

Converted the algo from recursive to DP and it worked.

Part 2 was counting the variations of tokens that could make the strings up.

This was a simple modification to my existing code.

[#]typescript performed admirably for this.

=> View attached media

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

Descendants

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113680085753444180
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
241.132999 milliseconds
Gemini-to-HTML Time
0.569865 milliseconds

This content has been proxied by September (ba2dc).