Count balanced lines without triples

An eight-cell row has 256 possible binary strings. Choosing the four positions occupied by ones leaves 70 balanced strings. Rejecting those containing 000 or 111 leaves 34. The table records how many binary puzzle row combinations survive each check for all three lengths.

We built the lists in two ways. One selected every combination of positions for the ones and checked for forbidden substrings. The other visited every binary string and compared adjacent cells directly. Both produced identical sorted lists, so we compared every entry as well as the totals.

OEIS A177790 counts arrangements with n zeros and n ones and runs of at most two. Its index n is half the line length, so eight cells use n = 4. The values for n = 4, 5 and 6 agree with our results. These counts apply before any puzzle-specific clues are considered.

Complete enumeration of individual lines
CellsAll strings / balanced stringsBalanced without triples
8256 / 7034
101,024 / 25284
124,096 / 924208

Use the complete eight-cell reference

The table groups all 34 strings into 17 pairs. Each right-hand pattern swaps every 0 and 1 in its left-hand partner. Swapping the digits preserves balance and the absence of triples. Each left entry starts with zero, and each right entry starts with one.

Both partners remain separate choices because their digits occupy different cells. Reversing a legal string also gives a legal string. The table includes each reversed entry wherever it belongs, and counts a palindrome only once. The downloads keep all distinct strings, including complements and reversals.

Read row positions from left to right, starting at C1. For a column, read the same strings from top to bottom. Pair numbers help you locate an entry in the table.

All 34 legal eight-cell patterns in 17 complementary pairs
PairStarts with 0Complement starting with 1
10010101111010100
20010110111010010
30011001111001100
40011010111001010
50011011011001001
60100101110110100
70100110110110010
80101001110101100
90101010110101010
100101011010101001
110101100110100110
120101101010100101
130110010110011010
140110011010011001
150110100110010110
160110101010010101
170110110010010011

Match the reference to your clues

For the partial line 00____11, keep entries beginning with 00 and ending with 11. Exactly two remain, 00101011 and 00110011. The underscores are unknown cells. A zero is a known digit and must stay in its original position.

Repeat this lookup for any partial line of the matching length. Compare each known position with every entry and discard a string as soon as it disagrees. Retain all entries that match. Searching only for a prefix misses clues elsewhere in the row, and copying only one side of the paired table misses half the patterns.

An empty result means the current digits have no legal completion under the two line rules. Check the copied positions and your earlier entries. Several matches leave several possibilities for that line. Our candidate-elimination guide explains how to use the surviving set to prove a move and apply the surrounding board constraints.

Download longer-line lists and verify the count

Each text file contains one pattern per line, ordered from smallest to largest binary value. The files contain only digits and line breaks, with no heading to remove before counting. Preserve each entry as text. A spreadsheet can turn 00101011 into 101011 by dropping its leading zeros, which loses two cell positions.

Check an entry by counting its zeros and ones, then looking for 000 and 111. Check that its length matches the file and that no entry appears twice. Those checks establish that the entries are legal and distinct. To check completeness, compare the whole file with an exhaustive list. A file of valid rows can still omit a valid row.

The downloadable verifier needs Python 3 and uses only its standard library. Save it beside all three text files and run python3 verify-binary-puzzle-row-patterns.py. It rebuilds each list twice, compares every row with the downloaded file, and prints PASS for each size. A missing, altered, repeated or reordered entry makes the check fail.

Keep row counts separate from board counts

Thirty-four patterns do not give you 34 independent choices for each row of an 8x8 grid. Repeating a row breaks uniqueness, and separately chosen rows can make a column unbalanced or create a vertical triple. Counting complete boards requires enforcing all those constraints together. Use these lists to inspect a line or help construct a grid.

If you are making a puzzle, start with our construction guide. It explains how to check the completed board and keep a unique solution as you remove clues.

Sources and verification

OEIS A177790 provides the line counts. A398298 lists the patterns as binary integers, which need leading zeros restored to their full width. BinaryPuzzle.com's rules explain the additional uniqueness checks for whole boards. We generated the downloadable strings and verifier independently for this reference.