Again, I really just want a nudge in the right direction. Possibly a large nudge, but not the straight forward answer.
I am trying to figure out how to solve Project Euler Problem 191.
I believe I have most of it figured out, but I cannot come up with an algorithm or pattern for the 3-consecutive-Absent days part. I can even find the number of permutations of the strings holding the total number of A-days constant (i.e. how many permutations with only 1 A-day, only 2 A-days, only 3 A-days, etc.), but I cannot figure out how many permutations have 3 consecutive A-days.
So, is there a mathematical formula for this? Is there a way to break this up so that I have "(some # permutations) +/- (another # of permutations) = (# of consecutive A-days)"? I believe this is a combinatorial problem, but maybe it falls under a different category.
Any help is appreciated. Thanks.
For each string length $n$, you want to keep track of six quantities: the number of ``good'' (i. e. prize-winning) strings of length $n$ which end in $i$ $A$s ($i = 0, 1, 2$) and contain $j$ $L$s ($j = 0, 1$). These six quantities for strings of length $n+1$ can be simply written in terms of those for length $n$.