Block Walk Method
1. Introduction
Many olympiad combinatorics problems ask you to count or reason about sequences. This could be strings of 0s and 1s, sequences of positive and negative numbers, alternating colorings, or lattice paths. A direct element-by-element analysis often bogs down in casework. The Block Walk method gives you a cleaner lens: instead of staring at individual elements, you partition the sequence into consecutive blocks of identical (or same-type) elements and reason about the transitions between them.
The core philosophy is a shift of attention. If you have a binary string like
the sequence has 13 characters. But it has only 6 runs (maximal consecutive blocks of the same digit): , , , , , . The number of runs, the lengths of runs, and the positions of the boundaries between runs often encode everything you need, and they are far easier to count.
Why we should care Block walks appear explicitly or implicitly in problems involving:
- Counting binary strings with constraints on run lengths.
- Counting sign changes in integer sequences.
- Proving properties of alternating sequences.
- Lattice paths and boundary-crossing arguments.
- Problems where "how many times does something change?" matters more than "what is each value?"
The technique converts a question about a long sequence into a question about a short list of blocks and boundaries, which is a drastic compression that makes counting, bounding, and proof by induction all more tractable.

Illustration: A row of 13 colored squares (three white, two black, one white, three black, two white, two black) separated by vertical dividers at each color change. Each maximal consecutive run of the same color is labeled as a block (Block 1, Block 2, …, Block 6). Arrows point to the five dividers and label them as boundaries. The diagram should make visually clear that the number of boundaries is always one less than the number of blocks.
2. Core Idea
Definitions
Definition (Block). Given a sequence , a block is a maximal consecutive subsequence such that all elements in that subsequence share a common property (e.g., all equal, all positive, all the same color, all even). "Maximal" means (if it exists) and (if it exists) do not share property .
Definition (Boundary). A boundary is a pair of consecutive indices where the block containing differs from the block containing . Equivalently, a boundary is a position where a transition occurs.
Definition (Transition). A transition at position is the event that and belong to different blocks. The total number of transitions equals the number of boundaries, which equals one less than the number of blocks.
Definition (Block Walk). A block walk is a conceptual traversal of a sequence in which you move from block to block rather than element to element. At each step you record the block's type and length, and whether you are crossing a boundary.
Key Structural Facts
Let denote the number of blocks in a sequence. Then:
- Number of boundaries .
- The sequence starts at the left endpoint of Block 1 and ends at the right endpoint of Block .
- The two endpoints of the sequence (positions 1 and ) each belong to exactly one block.
Why transitions matter more than elements. In many counting problems the constraint is not on element values individually but on how many times a value changes. A binary string of length with exactly transitions is determined by: (a) its first element (2 choices), and (b) the positions of the transitions ( choices). That is a far cleaner description than specifying all bits directly.
Why endpoints are often important. The first and last blocks are the only blocks that touch the boundary of the sequence. Parity arguments, inductive steps, and extremal arguments frequently hinge on the type of the first or last block.

Illustration: A horizontal strip representing the binary string . Blocks are shaded in alternating light/dark bands. Vertical tick marks at each boundary are labeled . The leftmost position is labeled "left endpoint" and the rightmost "right endpoint." A small table below maps: number of blocks , number of boundaries , number of transitions . This should clearly distinguish blocks (regions) from boundaries (dividers) from transitions (events).
3. Simple Motivating Example
Problem
How many binary strings of length 8 contain exactly 3 runs of consecutive 1s (a run of 1s is a maximal block of 1s)?
Naive Approach (Why It's Hard)
You might try to count directly: place three groups of 1s somewhere in the string, separated by at least one 0, with 0s possibly at the start and end. But deciding how to distribute the 0s in the gaps without merging two groups of 1s leads to a case analysis with many sub-cases.
Block Walk Solution
Reframe: a string with exactly 3 runs of 1s has a block structure of the form
where each (since each is a run of 1s), and each with the constraint that the 0-runs between 1-runs satisfy (to prevent two 1-runs from merging). The leading and trailing 0-runs .
Setting up the count. The total length constraint is:
with , , and .
Substitute and for :
The number of non-negative integer solutions is .
The block walk formulation made it immediately clear what variables to introduce and what constraints to impose.
Answer: There are binary strings of length 8 with exactly 3 runs of 1s.
4. General Block Walk Principle
General Principle. If a problem involves a sequence where the relevant structure is determined by how many times the sequence changes type, not by the exact values, then compress the sequence into its block walk and count or reason about blocks and transitions instead.
When to Use Block Walks
| Setting | What a block is | What a transition is |
|---|---|---|
| Binary strings | Maximal run of 0s or 1s | A position where |
| Alternating sequences | Single element (blocks have length 1) | Every adjacent pair (transitions everywhere) |
| Sign changes | Maximal run of positive or negative terms | Position where sign flips |
| Parity changes | Maximal run of even or odd integers | Position where parity flips |
| Consecutive equal runs | Maximal run of equal values | Position where value changes |
| Lattice paths (E/N steps) | Maximal run of same direction | Direction change |
| Sequence compression | Any run-length encoded structure | Transition in the encoding |
| State transitions | Maximal time in one state | State change event |
Intuition Behind Each Setting
Binary strings and consecutive runs. This is the most direct application. The number of runs and the lengths of each run together fully determine the string. Constraints on individual elements translate to constraints on block lengths.
Sign changes. A sequence of real numbers has sign changes if and only if the sign sequence has exactly transitions. This is the basis of Descartes' Rule of Signs.
Parity changes. A sequence of integers has exactly parity changes if and only if there are exactly indices where . Parity-change counting is a standard technique in olympiad problems about integer sequences.
Lattice paths. A path from to using East (E) and North (N) steps can be encoded as a binary string. A block walk on this string corresponds to alternating runs of E-steps and N-steps; the number of direction changes equals where is the number of runs.
5. Worked Example 1: Binary Strings
Problem
Problem (AIME-style). How many binary strings of length 12 have an odd number of runs?
Thought Process
A binary string of length has runs, where . Runs alternate between 0-runs and 1-runs. We want to count strings where is odd.
Step 1: Parameterize by block structure. A string with runs is determined by:
- Its first bit (2 choices).
- The lengths of the blocks with and .
The number of strings with blocks is (choose the first bit, then choose the boundary positions among the gaps).
Step 2: Sum over odd . We want:
Step 3: Use the identity. The sum of binomial coefficients over all even equals , giving:
So the total is .
Solution
Key Takeaway
By thinking of a binary string as a sequence of blocks determined by choosing boundary positions among the gaps, the sum over strings with a parity constraint on becomes a sum of binomial coefficients, which can be handled with standard identities.

Illustration: A binary string of length 12, displayed as a row of squares labeled 0 or 1. Alternating runs are shaded light (0-runs) and dark (1-runs). Below the string, the 11 gaps between adjacent positions are shown as tick marks, and the gaps chosen as boundaries (for an example with 5 runs) are marked with vertical bars. A label reads: "Choosing boundary positions from 11 gaps gives strings with 5 runs starting with 0." A second row shows the same string starting with 1.
6. Worked Example 2: Parity Changes
Problem
Problem. A sequence of integers has parity changes. Prove that and have the same parity if and only if is even.
Solution
Setup. Partition the sequence into maximal same-parity blocks. Let be the number of blocks. Each block consists entirely of even integers or entirely of odd integers, and the parity alternates between consecutive blocks.
Counting transitions. The number of parity changes equals the number of boundaries, so
Endpoint parity. Since block parities alternate, the final block has the same parity as the first block exactly when the number of blocks is odd. Therefore
This proves the claim.
Commentary
This is a clean example of a block walk argument: by compressing the sequence into its parity blocks, the relationship between , , and the number of parity changes becomes transparent. The key step is recognizing that block parities alternate, so the parities of the first and last elements are determined solely by the parity of the number of blocks.

Illustration: A sequence of 10 integers, some even (shaded blue) and some odd (shaded orange), arranged in a row. Vertical dividers mark parity transitions. Below each block, the block's parity (E or O) is labeled. An arrow from the first block's parity label to the last block's parity label is annotated: "Same parity iff is odd iff is even." A small 2-row table shows: (odd) endpoints have different parity; (even) endpoints have same parity.
7. Worked Example 3: USAMO-Style Proof Problem
Problem
Problem. Let be a positive integer. A sequence of integers, each equal to or , is called balanced if no contiguous subsequence (with ) has a sum strictly greater than 1 in absolute value, i.e., for all . Prove that every balanced sequence must alternate signs, i.e., for all .
Strategic Observations
Before proving, let us observe:
- If two consecutive terms are equal, say , then , violating the condition with , .
- Similarly, gives sum , violating .
- Therefore, any balanced sequence must satisfy for all , which means every adjacent pair is a transition.
This is a block walk argument: in a balanced sequence, every block has length exactly 1.
Full Proof
Claim. If is balanced, then for all .
Proof. Suppose for contradiction that for some index . Then . In either case, , contradicting the balanced condition with and . Therefore no two consecutive terms can be equal. Since each and , we conclude for all .
Commentary
The block walk perspective makes this almost immediate: a block walk on the sequence reveals that every "block" (maximal run of equal values) has length exactly 1, because a run of length of equal values would have absolute sum , violating the hypothesis. The proof reduces to a single-step contradiction, but the key conceptual move is recognizing that the balanced condition is precisely the condition that all blocks have length 1.
This is a common olympiad pattern: a condition on contiguous sums forces the block structure of the sequence, and the block walk perspective makes the proof clean.
Extended Problem
Extension. Prove conversely that every alternating sequence is balanced.
Proof. Let be alternating with . For any contiguous subsequence : if (the length) is even, paired terms cancel and the sum is 0. If is odd, all but one paired terms cancel and the sum is . In both cases .

Illustration: Two side-by-side sequences of length 6. Left: a non-alternating sequence with highlighted in red, with a bracket below showing , labeled "NOT balanced." Right: a fully alternating sequence with all adjacent pairs connected by arrows labeled "", labeled "Balanced." Below each, the block walk is shown: the left has a block of length 2 highlighted; the right has all blocks of length 1.
8. Common Patterns
Pattern 1: Count Transitions Instead of Objects
When a problem asks "how many sequences of length with property ?", ask first: does property depend only on the number and arrangement of transitions? If so, count pairs , where is the number of blocks and is the starting block type, and use the stars-and-bars formula for block lengths.
Example. Sequences of length with exactly parity changes: parameterize by block lengths summing to , with each block length . Count = .
Pattern 2: Compress Runs into Blocks
Instead of working with the raw sequence , work with the compressed sequence where is the block type and is its length. Constraints on the original sequence often translate to simpler constraints on the .
Pattern 3: Alternate Block Types
In binary sequences, block types strictly alternate: or . This means the type of every block is determined by the type of the first block and its index. Exploit this when counting or proving properties.
Consequence. The type of the last block is determined by and the type of the first block. This links endpoint values to the global block count.
Pattern 4: Endpoint Arguments
The first and last elements of a sequence each belong to exactly one block: the first and last blocks. Parity arguments, inductions, and extremal arguments often fix these endpoints and then count the interior structure.
Example. If a sequence starts and ends with 1 and has blocks, then must be odd (since block types alternate and both endpoints are 1-blocks).
Pattern 5: Double-Counting Boundaries
Each boundary corresponds to a unique pair of adjacent elements that differ. Double-counting the pair (boundary, block it separates) gives useful equalities.
Example. In a sequence of 0s and 1s, the number of boundaries between a 0-block and a 1-block equals the number of or adjacent pairs, which equals the number of transitions. This is trivially true but becomes useful when boundaries carry additional structure.
Pattern 6: Parity of the Number of Blocks
Whether is odd or even controls the relationship between the first and last blocks. This is a common invariant:
- odd first and last block have the same type.
- even first and last block have different types.
Parity of is often an invariant under certain operations (e.g., appending a same-type element doesn't change ; appending a different-type element changes by 1).
Pattern 7: Invariants During Block Walks
When a sequence is modified by an operation (e.g., inserting an element, flipping a bit), track how changes:
- Insert an element equal to its neighbor: unchanged.
- Insert an element different from both neighbors (or at an endpoint): increases by 1 or 2.
- Remove an element at a boundary: may decrease.
Invariant arguments about modulo some number are common in olympiad problems about sequence operations.
9. Common Mistakes
Mistake 1: Forgetting Endpoints
What goes wrong. A student counts boundary positions among the interior gaps, forgetting that the sequence also starts at position 1 and ends at position . This leads to off-by-one errors.
Example. Counting binary strings of length with blocks: the correct count is (choose boundaries from the gaps), not .
Fix. Always identify: where are the gaps? Between adjacent elements, there are gaps. The endpoints of the sequence are not gaps.
Mistake 2: Counting Boundaries Incorrectly
What goes wrong. A student counts the number of places where using an off-by-one or double-counts a boundary shared by two blocks.
Fix. A boundary is uniquely associated with a gap , not with an element. Count gaps where a change occurs, not elements that change.
Mistake 3: Confusing Blocks with Boundaries
What goes wrong. blocks have boundaries, but students sometimes write " blocks, boundaries." This is wrong by exactly 1.
Fix. Memorize: blocks boundaries, just as fence posts gaps.
Mistake 4: Double-Counting Transitions
What goes wrong. When counting "the number of pairs plus the number of pairs," a student may think each boundary is counted twice. In fact, each boundary is a single directed pair (either or ), not both.
Fix. Each boundary is a -pair OR a -pair, not both. If you count all adjacent unordered pairs that differ, you get the number of boundaries exactly once.
Mistake 5: Assuming Alternation Without Proof
What goes wrong. A student assumes that the block walk of a specific sequence must alternate between two types without verifying the conditions. This is only valid for binary-type sequences with strict alternation.
Example. A sequence of integers partitioned into "positive blocks" and "negative blocks" does alternate block signs. But a sequence of integers partitioned into "blocks where " and "blocks where " also strictly alternates block types by definition of a block. The mistake is assuming something additional about the alternation that was not proven.
Fix. Explicitly verify that your block definition implies strict alternation. Usually this is true by the maximality condition in the definition of a block.
Mistake 6: Defining Blocks Inconsistently
What goes wrong. Switching between block definitions mid-solution. For example, defining blocks as "runs of equal values" in one step and then treating consecutive odd numbers as one block in the next step.
Fix. State your block definition precisely at the start of the solution and use it consistently throughout.
10. Practice Problems
Easy
Problem 1. How many binary strings of length 9 have exactly 4 blocks of 0s?
Problem 2. A sequence consists of s and s. Let be the number of indices such that . Prove that is even if and only if , and is odd if and only if .
Medium
Problem 3. How many binary strings of length 14 satisfy the following: every block of 0s has length at most 2, and every block of 1s has length at least 2?
Problem 4. How many binary strings of length 14 start and end with 1 and have exactly 4 blocks of 1s?
Hard
Problem 5 (USAMO-style). Let be a positive integer. A sequence , each term equal to or , is called good if
Prove that in every good sequence, the number of -blocks equals the number of -blocks. Also prove that this common number is equal to the number of peaks of the partial-sum path, where a peak is an index such that and .
11. Hints
Hint for Problem 1. A string with exactly 4 blocks of 0s has either 3, 4, or 5 blocks of 1s depending on whether the string starts and ends with 0 or 1. Count each endpoint case separately.
Hint for Problem 2. Compress the sequence into blocks of equal signs. The number of sign changes is one less than the number of blocks.
Hint for Problem 3. Let be the number of 0-blocks and the number of 1-blocks. Since blocks alternate, . Count each possible start/end pattern and assign block lengths.
Hint for Problem 4. Since the string starts and ends with 1 and has exactly 4 1-blocks, it must have exactly 3 0-blocks. Write the block structure explicitly, then use stars and bars.
Hint for Problem 5. A good sequence must start with and end with . Then use the fact that blocks alternate. A peak occurs exactly at the end of a -block.
12. Solutions
Solution to Problem 1
We count binary strings of length 9 with exactly 4 blocks of 0s.
Block structure. Such a string has 4 blocks of 0s and some number of blocks of 1s. Since blocks alternate, the number of 1-blocks is either 3, 4, or 5, depending on the starting and ending block:
- Starts with 0, ends with 0: 4 zero-blocks and 3 one-blocks, for 7 total blocks.
- Starts with 0, ends with 1: 4 zero-blocks and 4 one-blocks, for 8 total blocks.
- Starts with 1, ends with 0: 4 zero-blocks and 4 one-blocks, for 8 total blocks.
- Starts with 1, ends with 1: 4 zero-blocks and 5 one-blocks, for 9 total blocks.
For total blocks, the number of ways to choose positive block lengths summing to 9 is .
Thus the total is
Solution to Problem 2
Let be the number of blocks of equal signs. Then the number of sign changes is
Because the sequence contains only and , the signs of the blocks alternate. If is odd, the first and last blocks have the same sign, so . If is even, the first and last blocks have opposite signs, so .
Since , is even exactly when is odd, and is odd exactly when is even. Therefore is even iff , and is odd iff .
Solution to Problem 3
Let be the number of 0-blocks and the number of 1-blocks. Blocks alternate, so . We count four endpoint cases.
Case 1: starts and ends with 0. Let and . Every 0-block has length 1 or 2, and every 1-block has length at least 2.
The block structure is
where
Let and . The minimum total length is
So we need
with each .
Now check possible :
: need sum , impossible because there are only bounded variables and one unbounded variable , but the total length structure has only 3 blocks and forces the single 1-block to absorb the rest. The count is . : count is . : count is . : count is .
So Case 1 contributes
Case 2: starts and ends with 1. Let and . The block structure is
where
Using the same block-length count, the contributions are
So Case 2 contributes strings.
Case 3: starts with 0 and ends with 1. Here . The block structure is
where
The block-length count gives
So Case 3 contributes strings.
Case 4: starts with 1 and ends with 0. By symmetry with Case 3, this also contributes strings.
Therefore the total number of binary strings is
Solution to Problem 4
If the string starts and ends with 1 and has exactly 4 blocks of 1s, then its block structure must be
where all seven block lengths are positive integers. The total length is 14, so
The number of positive integer solutions is
Thus there are
such strings.
Solution to Problem 5
Let
The condition says for every and .
First, the sequence must start with , because otherwise . It must end with , because if the last term were , then , contradicting non-negativity.
Now compress the sequence into blocks of consecutive equal signs. Since the sequence starts with a -block and ends with a -block, and since block signs alternate, the number of -blocks equals the number of -blocks.
Finally, a peak of the partial-sum path occurs exactly when the path takes a step followed immediately by a step. In the original sequence, that is exactly a transition from a -block to the next
