In binary puzzles , a grid must be filled with ones and zeroes. Each column and row must be a sequence following these rules:
For instance, is a valid sequence; is invalid because there are three zeroes in a row; is invalid because there are more ones than zeroes.
How many valid sequences of length ten are possible?
Want more of a challenge? Try this one . It is marked for Computer Science, but perhaps you can solve it "by hand"...
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
We will only count the sequences starting in zero; the answer is then found by doubling, because inverting the digits gives all valid sequences starting in one.
To describe a sequence, we only have to state whether digits are used once or twice in succession (in pairs).
First, there is 1 sequence without pairs: 0 1 0 1 0 1 0 1 0 1 .
Patterns with one pair must start and end in the same digit (zero); therefore the pair must consist of two ones. There are four possible positions for the pair, from 0 1 1 0 1 0 1 0 1 0 to 0 1 0 1 0 1 0 1 1 0 . Thus we have 4 sequences of this kind.
Patterns with two pairs are possible if the pairs have opposite values (a pair of zeroes and a pair of ones). There are four positions for the zeroes and four positions for the ones, e.g. 0 0 1 0 1 1 0 1 0 1 . This results in 4 × 4 or 16 sequences.
Patterns with three pairs require two double ones and one double zero, e.g. 0 1 1 0 1 1 0 1 0 0 . There are four positions for the double zero and three positions for the single one, giving a total of 12 sequences.
Patterns with four pairs require two of each, e.g. 0 0 1 1 0 1 1 0 0 1 . There are three positions for the single zero and three for the single one. That adds up to 9 possibilities.
There are no sequences with five pairs.
In total, we have 1 + 4 + 1 6 + 1 2 + 9 = 4 2 sequences starting in zero; and 2 × 4 2 = 8 4 in total.
Generalization :
Note that this calculation can be summarized as 2 ⋅ ( 1 ⋅ 1 + 1 ⋅ 4 + 4 ⋅ 4 + 4 ⋅ 3 + 3 ⋅ 3 + 3 ⋅ 0 ) = 2 ⋅ [ ( 5 0 ) ( 5 0 ) + ( 5 0 ) ( 4 1 ) + ( 4 1 ) ( 4 1 ) + ( 4 1 ) ( 3 2 ) + ( 3 2 ) ( 3 2 ) + ( 3 2 ) ( 2 3 ) ] = 2 ⋅ k = 0 ∑ 5 ( 5 − ⌊ k / 2 ⌋ ⌊ k / 2 ⌋ ) ⋅ ( 5 − ⌈ k / 2 ⌉ ⌈ k / 2 ⌉ ) , which generalizes for sequences of length 2 n as 2 ⋅ k = 0 ∑ n ( n − ⌊ k / 2 ⌋ ⌊ k / 2 ⌋ ) ⋅ ( n − ⌈ k / 2 ⌉ ⌈ k / 2 ⌉ ) .