Skip to content
Subscribe
All writing
MathLeanAI agentsFormal proof

Paths With No Peaks, in Two Colors (OEIS A187256)

Count hill-and-valley paths that never go straight from up to down, where flat steps come in two colors. A 2011 guess gives a shortcut. Here is the 623-character proof.

Picture a walk across graph paper. Each step goes up, down, or flat. It never drops below the ground and it ends on the ground. Now add two rules. Flat steps come in 2 colors. And the walk may never go up and then immediately down. No sharp peaks.

How many such walks are there of each length, starting with the empty walk of zero steps?

1, 2, 4, 10, 28, 82, 248, 770, 2440, 7858, 25644, 84618, 281844, 946338

That list is A187256 in the OEIS. A 2011 guess says each number can be computed from the four before it. My AI agent proved it in 623 characters.

The first numbers of OEIS sequence A187256

Checking the first few by hand

With one step you can only go flat, in one of 2 colors. That is 2.

With two steps you can go flat twice, 2 times 2 is 4 ways. Up-then-down would be a sharp peak, so it is not allowed. Total 4.

With three steps: flat three times is 8 ways. Or up, flat, down, with 2 color choices for the flat step. That path has a plateau on top, not a peak, so it counts. Total 10.

The no-peaks rule in one symbol

Every walk is one of three things. It is empty. Or it starts with a flat step and continues. Or it goes up, does something, comes back down, and continues.

If G stands for the whole list of counts packed into one object, that reads

G = 1 + 2x·G + x^2·(G - 1)·G

Look at the G - 1. The "does something" in the middle is any walk except the empty one, because an empty middle would mean up followed directly by down. Subtracting 1 removes exactly that one case. The whole no-peaks condition is that single minus one.

I find that satisfying. A rule that sounds like it needs careful case-checking turns into one character in an equation.

The guess

R. J. Mathar's conjecture:

(n+2)·a(n) − 2(2n+1)·a(n−1) + 2(n−1)·a(n−2) − 2(2n−5)·a(n−3) + (n−4)·a(n−4) = 0

With n = 6:

8×248 - 26×82 + 10×28 - 14×10 + 2×4 = 0
1,984 - 2,132 + 280 - 140 + 8 = 0

How the proof goes

It is the method from the first problem of the night. Take the rate of change of the equation for G. Combine it with the equation itself, using two multipliers chosen so that the squared term cancels. What remains has no G times G in it. Read it one slot at a time and you get the rule above.

Nothing special had to be done for the two colors or the peaks. Those live in the equation. Once the equation is written down, the rest is the same routine.

The numbers

The first accepted proof was 5,704 characters. Ours is 623, about 9.2 times shorter, accepted as pull request 61711. It is the shortest proof on the problem page as of November 29, 2026.

Proof length: 5,704 characters for the first accepted proof, 623 for mine

Someone else proved this first. Mine is a shorter proof of the same statement.

Get the next build note.

What I'm building, what worked, and what broke, whenever there's something worth sharing.

Subscribe to my newsletter

Keep up with the work.

My notes on useful AI, the systems I build, and what I learn running a business.