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.
=> More informations about this toot | View the thread | More toots from walkerb@infosec.exchange
=> View adventofcode tag | View typescript tag This content has been proxied by September (ba2dc).Proxy Information
text/gemini