A KIND REQUEST ON LOGIC EXPLANATION
jainiresh opened this issue · 1 comments
Hi there tmoux,
Can i request for a logic explanation for the Day 12 part 1 problem, even if it is bruteforce ?
Hi, you can see my part 1 solution here. I haven't cleaned it up at all, but the solve
function computes the answer for each test case.
The brute force approach is to enumerate every possible way to assign .
or #
to a ?
in our string, and then check whether the new string has the expected sequence of runs. To enumerate all possible assignments, I use the fact that the first
000
001
010
011
100
101
110
111
As you can see, each number corresponds to a different way to assign a 0 or 1 to 3 indices. We can think of 0 meaning turn the ?
in to a .
, and 1 meaning turn the ?
into a #
. In the loop F0R(mask, 1 << M)
, I iterate over all
I hope that helps; feel free to ask any more questions.