# Word length 87 is the first where a fifth letter lets one more position stay blank

How much of a word can you erase and still tell its beginning from its end? Compare the first letter with the last, the first two with the last two, and so on, stopping short of the whole word. An erased position, or *hole*, can match any letter. To tell the two ends apart, each comparison must therefore line up at least one pair of different letters. With a large alphabet, every surviving letter can be different. With a small alphabet, letters may have to repeat. The question is whether those repeats ever force us to erase less.

The first length where a four-letter alphabet makes a difference is 87. Five letters allow 71 holes, the most possible with any alphabet. Four allow exactly 70. Up to reading the word backwards, there are only two ways to place the 16 surviving letters that could give 71 holes. Each placement requires a fifth letter, for a different reason.

## How the positions of the letters constrain the overlaps

Mathematicians call a sequence of letters and holes a *partial word*. Its *prefix* is a segment starting at the beginning; its *suffix* is a segment ending at the end. If the prefix and suffix disagree at every length from one up to one less than the word's length, the word is *unbordered*. For example, in A·BC the dot is a hole at position 1, counting from 0. The one-letter ends disagree (A versus C). Comparing A· with BC gives A versus B, and comparing A·B with ·BC gives B versus C. Thus A·BC is unbordered.

Number the positions from 0 to \(L\), so the word has length \(n=L+1\). Shift one copy of the word by \(d\) positions along another. In the resulting overlap, we compare the prefix and suffix of length \(n-d\). Every aligned pair of positions is a distance \(d\) apart. To distinguish the ends at this overlap, we need a pair of different letters at that distance. Now imagine marking just the surviving positions on a ruler. For the word to be unbordered, the marks must measure every integer distance from 1 to \(L\). Such a layout is called a *complete ruler*.

With unlimited letters, a complete ruler is enough: give each mark its own letter. The maximum number of holes is then the word length minus the fewest marks on a complete ruler. [Blanchet-Sadri and colleagues (2009)](https://doi.org/10.1007/978-3-642-00982-2_15) conjectured that four letters always attain this maximum. [Saarela and Vanhatalo (2026)](https://doi.org/10.37236/13806) showed how to label an entire family of complete rulers, called Wichmann rulers, with four letters so that every distance has a mismatch. This settles the question wherever a Wichmann ruler uses the fewest possible marks. But a layout outside that family can use fewer marks. The conjecture, restated by Saarela and Vanhatalo as Conjecture 31, requires only that *one* minimum layout at each length work with four letters. To disprove it takes a length where *every* minimum layout fails.

## The first length where four letters fall short

[Ed Pegg's archive](https://mathpuzzle.com/bigsparse.zip) lists rulers by the gaps between successive marks. We tested 330,161 minimum-size layouts at ruler lengths 1 through 213, counting a layout and its reversal once. Of these layouts, 55,366 required five letters and 71 required six. At every length where a layout needed six letters, another minimum layout worked with fewer. At just eight word lengths in the scan, none of the minimum layouts worked with four letters. The smallest such word length was 87.

To verify that 87 comes first without assuming the archive is complete, we checked both the letters and the number of marks. For every word length from 2 through 86, we found a word using at most four letters and checked that its ends disagreed at every overlap. These [85 words, in order of length](results/words.txt), are the first 85 lines of the list. At length two both endpoints must carry letters. At each subsequent length, an exhaustive search found no complete ruler with one fewer mark than our word used. That also rules out every smaller layout: we could always add marks to one without losing a distance. A word of length one has no overlap to test.

At word length 87, the search found no complete ruler with 15 marks and exactly four with 16 marks. Two are reversals of the other two. Reading a word backwards preserves every mismatch, leaving just the two cases in Table 1.

Table 1. All minimum complete rulers of length 86, up to reversal. The endpoints are 86 positions apart in a word of length 87.

| Layout | Positions counted from 0 |
|:--|:--|
| A | 0, 1, 2, 8, 15, 18, 29, 40, 51, 62, 73, 77, 81, 82, 85, 86 |
| B | 0, 1, 2, 9, 13, 14, 21, 44, 51, 55, 59, 61, 77, 80, 83, 86 |

## Why neither layout admits four letters

Layout B contains five marks that must all carry different letters. If a pair of marks is the only pair at its distance, its letters must differ; call this a *forced pair*. Take the marks 1, 21, 44, 61 and 77 in B. Their ten pairwise distances are 16, 17, 20, 23, 33, 40, 43, 56, 60 and 76. Each occurs only once in the entire layout. Any two of these five marks sharing a letter would leave their distance without a mismatch.

On layout A, the forced pairs alone allow 34 assignments if we count assignments that differ only in the names of the letters as one. To rule them out, we also need distances measured by more than one pair. At each such distance, at least one pair must disagree.

Each of the marks 2, 8 and 77 forms a forced pair with the other two. Name their letters \(a,b,c\), respectively. The letters at 18 and 40 must each differ from all three, so both marks carry the fourth letter, \(d\). Write \(w_i\) for the letter at position \(i\). The table shows what these five letters imply for six other marks. In particular, there are only three choices for the letter at mark 15.

| Mark | Must differ from marks | Possible letters |
|---:|:---|:---|
| 0 | 2, 18 | b, c |
| 1 | 18, 77 | a, b |
| 15 | 40 | a, b, c |
| 73 | 8, 18 | a, c |
| 85 | 2, 40 | b, c |
| 86 | 8, 18 | a, c |

Suppose first that \(w_{15}=a\). The forced pairs (15,73) and (73,85) give \(w_{73}=c\) and \(w_{85}=b\). At distance 13, (2,15) matches, so the only other pair, (73,86), must differ: \(w_{86}=a\). At distance 84, (2,86) now matches, so (1,85) must differ and \(w_1=a\). At distance 77, (8,85) matches, so (0,77) must differ and \(w_0=b\). Both pairs at distance 85 now match: (0,85) carries two copies of \(b\) and (1,86) two copies of \(a\).

If \(w_{15}=b\), then (8,15) matches. The only other pair at distance 7 is (1,8), so \(w_1=a\). The forced pairs (15,85) and (85,73) give \(w_{85}=c\) and \(w_{73}=a\). But (1,73), the only pair at distance 72, now matches.

If \(w_{15}=c\), the forced pairs (15,73) and (15,85) give \(w_{73}=a\) and \(w_{85}=b\). The forced pair (1,73) gives \(w_1=b\). At distance 84, (1,85) matches, so (2,86) must differ and \(w_{86}=c\). Both pairs at distance 71 now match: (2,73) and (15,86). This exhausts the choices at mark 15.

## The words with 71 and 70 holes

A single assignment on layout A shows exactly what the fifth letter buys. Put the letters BAABACCCCCDDDABD on its 16 marks in increasing order. There is a mismatch at 85 of the 86 distances. The exception is distance 13: the pair (2,15) carries A twice and (73,86) carries D twice. The prefix and suffix of length 74 can therefore match.

![Three assignments on layout A. The second changes A at position 2 to E. The third instead adds A at position 13.](results/repairs.png)

Figure 1. Two ways to break the sole matching overlap in the top word. Each letter is shown at its position; unlettered positions are holes. Brackets span 13 positions: the top pairs match, while each lower pair disagrees. The highlighted letter is the only change in each repair.

Give position 2 a new letter, E. Now (2,15) disagrees, and changing to a previously unused letter preserves all earlier mismatches. Alternatively, keep the four letters and fill the hole at position 13 with A. The new pair (0,13) disagrees, B versus A, and no old pair has changed. The first repair leaves 71 holes and the second leaves 70. Since every 16-mark layout rules out four letters and no 15-mark layout measures all distances, both repairs attain their respective maxima.

## Computational methods

For the catalogue scan, we recovered the positions of the marks by starting at zero and adding each successive gap in Pegg's list. The On-Line Encyclopedia of Integer Sequences (OEIS) tabulates the minimum number of marks at each ruler length in [sequence A046693](https://oeis.org/A046693). We retained layouts of that size. Counting a reversal separately when it gave a distinct layout reproduced the minimum-layout counts in [sequence A103300](https://oeis.org/A103300) at all shared ruler lengths (1–208). To test an alphabet size, we assigned letters one mark at a time, introducing new letters in a fixed order to avoid copies that differ only by name. We rejected an assignment as soon as all pairs at some distance had matching letters already assigned. For each successful word used to establish the threshold, a separate check compared prefixes and suffixes directly, ignoring any comparison involving a hole.

For the exhaustive layout search, fix the ruler length \(L\) and the target number \(K\) of marks. Start with both endpoints, the only pair at distance \(L\). At step \(t=1,2,\ldots\), consider positions \(t\) and \(L-t\), trying neither, either, or both without exceeding \(K\); at the center there is just one position to decide. Record all new distances to old marks and, when adding two marks, the distance between them. On reaching \(K\) marks, keep the layout if it measures all distances. These choices visit each eligible layout once unless an impossibility test rules it out earlier.

We stopped exploring a partial layout as soon as it could no longer succeed. There must be enough unused positions left to reach \(K\). Before step \(t\), no undecided position can contribute a distance greater than \(L-t\), so all larger distances must already be present. Finally, if \(k\) marks have been placed, at most \(\binom K2-\binom k2\) new pairs remain to cover the missing distances: the total number of pairs in the finished ruler minus the number already present. At \(L=86\) the search visited 3,536,493 nodes (layouts at successive steps) for 15 marks and 855,799,471 for 16. The four resulting layouts agreed with the catalogue.

To check the two proofs, we also grouped the marks of each layout in every possible way using at most four groups, one per letter, with the members of each forced pair in different groups. Comparing prefixes and suffixes directly found a matching overlap in all 34 groupings on A. On B the forced pairs left no grouping to test.

The example at length 87 settles the conjecture for four letters. Whether five letters attain the maximum number of holes at every word length remains open.

## References

Blanchet-Sadri, F., Allen, E., Byrum, C. and Mercaş, R. (2009). [How Many Holes Can an Unbordered Partial Word Contain?](https://doi.org/10.1007/978-3-642-00982-2_15) *Language and Automata Theory and Applications*, 176–187.

Saarela, A. and Vanhatalo, A. (2026). [A Connection Between Unbordered Partial Words and Sparse Rulers](https://doi.org/10.37236/13806). *Electronic Journal of Combinatorics* 33(1), P1.40.

Pegg, E. (2022). [Sparse ruler data](https://community.wolfram.com/groups/-/m/t/2663076). Wolfram Community; [full gap-run archive](https://mathpuzzle.com/bigsparse.zip).
