Thank you for your video! I had the right idea, but the wrong implementation, and your explanation showed me what I was doing wrong and helped me finish my own video. If you want a good laugh, take a look at the length of your code versus what I had written... Good luck hitting sub 100 :D
“Brrwbw” wasn’t in your cache because none of the designs you have happen to end in that string. Only strings you attempt to find end up in the cache. By the way, I solved part 1 differently, by realizing I didn’t need the whole set of 300+ patterns, I could get rid of any pattern that was buildable from other patterns. That brought my set down to a dozen or so. But it didn’t help me solve part 2 😂
My bug was that I thought you couldn't reuse towels. The input was constructed in a way that this rendered a correct answer for part 1, but obviously not for part 2.
Interesting bug there. I was too lazy for part1, so I just used regex matching. "^(" + patterns.join('|') + ")*$" does the trick. Ocf I had to implement the counting for part2 anyways. First I just did it recursively, then quickly realized, that it won't finish, so I threw my caching wrapper on it.
@@n0ne0ne I did it in JavaScript. inp is an array of the input lines: function solve1(inp){ let c = 0; const patterns = inp.shift().split(', ') inp.shift() const regex = new RegExp("^("+patterns.join('|')+")*$") for (const r of inp) { if(r.match(regex)) c++ } return c }
“Brrwbw” wasn’t in your cache because none of the designs you have happen to end in that string. Only strings you attempt to find end up in the cache. By the way, I solved part 1 differently, by realizing I didn’t need the whole set of 300+ patterns, I could get rid of any pattern that was buildable from other patterns. That brought my set down to a dozen or so. But it didn’t help me solve part 2 😂
Thank you for your video! I had the right idea, but the wrong implementation, and your explanation showed me what I was doing wrong and helped me finish my own video. If you want a good laugh, take a look at the length of your code versus what I had written... Good luck hitting sub 100 :D
my solution for today was insanely similar to yours, im proud of myself now
omg youre back!!!!!!!!!!
“Brrwbw” wasn’t in your cache because none of the designs you have happen to end in that string. Only strings you attempt to find end up in the cache. By the way, I solved part 1 differently, by realizing I didn’t need the whole set of 300+ patterns, I could get rid of any pattern that was buildable from other patterns. That brought my set down to a dozen or so. But it didn’t help me solve part 2 😂
My bug was that I thought you couldn't reuse towels. The input was constructed in a way that this rendered a correct answer for part 1, but obviously not for part 2.
i have solved it in a completely different way. but this solution is better. glad that i have found the video
i never understood why its called dynamic programming
nice guess, but that was crazy bug, good luck in next days
That was an unfortunate bug. You would've surely gotten top 100 for p2
When will the Tower of Hanoi stop haunting meee
Interesting bug there.
I was too lazy for part1, so I just used regex matching. "^(" + patterns.join('|') + ")*$" does the trick.
Ocf I had to implement the counting for part2 anyways. First I just did it recursively, then quickly realized, that it won't finish, so I threw my caching wrapper on it.
can you share your code for p1?
@@n0ne0ne I did it in JavaScript. inp is an array of the input lines:
function solve1(inp){
let c = 0;
const patterns = inp.shift().split(', ')
inp.shift()
const regex = new RegExp("^("+patterns.join('|')+")*$")
for (const r of inp) {
if(r.match(regex)) c++
}
return c
}
@@Bundas102 Thanks
“Brrwbw” wasn’t in your cache because none of the designs you have happen to end in that string. Only strings you attempt to find end up in the cache. By the way, I solved part 1 differently, by realizing I didn’t need the whole set of 300+ patterns, I could get rid of any pattern that was buildable from other patterns. That brought my set down to a dozen or so. But it didn’t help me solve part 2 😂