Balanced runs without four
Combinatorial Counting
Count binary strings of length 35 containing exactly seventeen 1s, with no occurrence of 0000 or 1111. Strings may begin with 0.
Solve using mathematics, algorithms, or your own code offline. Submit only the final integer here—no program, expression, graph, or written proof.
Check your answer without signing in. Sign in to save your progress.
How to approach this problem
Track total length, number of ones, last bit and current run length. Switching bits resets the run to one; repeating a bit is allowed only within the run limit.
Worked example with different values
With length 3 and two ones, the strings 011, 101 and 110 all satisfy a maximum run length of two. Under a maximum of one, only 101 survives.
Apply the same reasoning to the challenge. This example is a separate practice problem.
Learn the technique: Dynamic programming and grid paths