Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The three-colour Tantrix loop puzzle: maximum = 25 (proven)

This repository resolves a small open problem stated on Jaap Scherphuis's Tantrix page (section "Unsolved Puzzles" → three-colour variants):

"… make a shape with the longest three loops. Only the longest loop of each colour counts … My best solution had total length 8+8+7=23, but I received a solution by Neil O'Rourke with length 12+9+4=25. I don't know what the highest possible total is."

Result: the highest possible total is exactly 25. It is achievable (explicit arrangements are given) and optimal (an exhaustive search proves nothing does better).

The 25 arrangement

The puzzle

Take the 14 distinct Tantrix tiles that share one colour group (e.g. the tiles missing green, whose lines are red/blue/yellow). Lay them so touching edges match colour, forming a connected blob with no holes. Each colour's lines form some closed loops; score = sum of the longest loop of each colour. Maximise the score.

The argument

1. Upper bound score ≤ 42 − P/2. The 14 tiles have 3 arcs each = 42 arcs = 84 tile-edges. For any colour, arcs join into paths and loops; since adjacent edges must match colour, a path can only end on the outer boundary. So with perimeter P (boundary edges) there are exactly P/2 open paths, each ≥ 1 tile, hence total loop length = 42 − (total path length) ≤ 42 − P/2, and the score is at most the total loop length. (The puzzle requires a single connected cluster with no holes; a hole would only add boundary, so assuming hole-free costs nothing for the bound.) For the line variant the count differs slightly: the P/2 paths carry the length, but only the longest of each colour is scored, so the other P/2 − 3 paths are wasted (≥ 1 tile each), giving line score ≤ (total path length) − (P/2 − 3) ≤ 45 − P/2, which is 32 at P = 26 — matching Jaap's stated line maximum, a sanity check.

2. Finite reduction to 670 shapes. A score of 26 needs 42 − P/2 ≥ 26, i.e. P ≤ 32. The minimum perimeter of a 14-cell polyhex is 26 (for k hexes P = 6k − 2·(shared edges), so the densest packing wins: 84 − 2·29 = 26, matching P_min(n) = 2⌈√(12n−3)⌉, Harary & Harborth 1976; src/bound14.py verifies this by direct enumeration up to n = 14). As P is always even, the only candidates are P ∈ {26, 28, 30, 32}, exactly 670 shapes up to the 12 hex symmetries (1, 16, 120, 533).

3. Exhaustive search. Every edge-legal tiling of all 670 shapes was generated (all tile rotations, colour symmetry broken at the first cell). Best score by group:

perimeter shapes max score
26 1 23
28 16 25
30 120 24
32 533 22

No shape exceeds 25, so the maximum is 25, attained only on perimeter-28 shapes.

Do we have to use all 14 tiles? The stated puzzle uses all 14, but the result is robust to allowing unused tiles. By the same bound, any arrangement of k tiles scores ≤ 3k − P_min(k)/2: this is ≤24 for every k ≤ 12, leaving only k = 13 on a perimeter-26 shape as a possible improver. There are exactly four such shapes; exhaustively tiling each with any 13 of the 14 tiles (src/search13.py) tops out at 24. So 25 is maximal even with unused tiles allowed.

The solutions

Every optimal arrangement using all 14 tiles was enumerated, not just one. There are exactly five, up to the 12 hex symmetries and the 6 colour permutations, and they occupy only 2 of the 16 perimeter-28 shapes: see solution/all_25_solutions.txt (readable) and solution/all_25_solutions.json.

# split (longest loop per colour)
1 9 + 8 + 8
2–5 12 + 9 + 4

Four of the five have the split 12 + 9 + 4, exactly the breakdown reported for Neil O'Rourke's solution, so the search independently rediscovers it. The fifth, 9 + 8 + 8, appears not to have been reported before. These five are provably the complete set.

All five are drawn with oriented tile numbers: 1 · 2 · 3 · 4 · 5, and written out tile-by-tile in solution/all_25_solutions.txt using Jaap's own tile numbers. Open solution/tantrix_view.html in a browser to see every arrangement on one page.

In the drawings the tile number is printed at that tile's own orientation, so a physical set can be laid out by hand just by matching the pictures, and 6 and 9 are underlined (as on real tiles) so they can be told apart when turned.

Each tile is listed as: Jaap's number, its reference pattern, the number of 60° clockwise turns to apply, and the resulting colour on edges 0–5. Since the number printed on a physical tile turns with the tile, which is why Tantrix underlines 6 and 9 to tell them apart, the edge colours are given explicitly, so a tile can always be oriented from those alone, ignoring the number.

Bonus: the line version

The same page poses a line variant: "using the 14 tiles with only three of the colours make a shape with the longest three lines", of which Jaap writes "The highest possible total length is 32, and I have two solutions to it." That maximum was already known, so it was not the target here, but the same bound settles a question he does not answer: how many optimal arrangements exist.

The analogous bound is line score ≤ 45 − P/2, so a score of 32 forces P ≤ 26, i.e. only the single perimeter-26 shape can reach it. Enumerating that shape in full (src/find_all_32_lines.py) gives 112 tilings scoring 32, which reduce to exactly 28 distinct solutions up to the 12 hex symmetries and the 6 colour permutations.

All 28 are written out tile-by-tile, with Jaap's tile numbers and the turn for each tile, in solution/all_32_lines.txt, and each is drawn with oriented tile numbers: 1 · 2 · 3 · 4 · 5 · 6 · 7 · 8 · 9 · 10 · 11 · 12 · 13 · 14 · 15 · 16 · 17 · 18 · 19 · 20 · 21 · 22 · 23 · 24 · 25 · 26 · 27 · 28

A line solution

Reproduce / verify

Requires Python 3 with numpy and numba.

python verify_independent.py       # standalone re-check of the explicit solution

cd src
python tiles.py                    # generate the 56 tiles from first principles
python test_engine.py              # engine unit tests
python bound14.py                  # verify the min-perimeter fact (to n=14) + bound
# python validate_tiles.py         # optional: cross-check tiles vs the source page
#                                    (needs data/tantrix.txt; see the script header)
python census.py                   # enumerate all 670 candidate shapes
python sweep.py 8 26               # exhaustive search over every group (resumable)
python search13.py                 # the 13-of-14 subset check
python find_all_25.py              # every optimal loop arrangement
python find_all_32_lines.py        # every optimal line arrangement
python gen_all_svg.py loops        # draw them (also: gen_all_svg.py lines)
python make_viewer.py              # build the browser page

verify_independent.py shares no code with the solver: it re-checks the arrangement's legality, independently traces the loops to 25, re-derives the perimeter bound, and brute-force-confirms the minimum-perimeter formula. Per-shape search results are in results/ (<perimeter>_<index>.done).

Repository layout

path contents
src/ the solver: tile generation, engine, census, exhaustive search
verify_independent.py standalone verifier (shares no code with src/)
solution/ the optimal arrangements, the picture, the browser viewer
results/ per-shape exhaustive results for all 670 shapes
data/ shape census and the tile-numbering table, derived from jaapsch.net/puzzles/tantrix.htm
docs/ FINDINGS.md: fuller writeup and notes
exploration/ earlier / superseded experiments, kept for transparency

Credit

The value 25 was first found by Neil O'Rourke (reported on Jaap Scherphuis's site). The puzzle, the complete tile data and the open question itself all come from Jaap Scherphuis's excellent Tantrix page:

https://www.jaapsch.net/puzzles/tantrix.htm

which is the source of every tile pattern and tile number used here. This repository adds the proof of optimality and explicit, independently-verified constructions.

The code and much of the analysis were developed with Claude Code (Anthropic), used both to write the solver and as a thinking partner on the perimeter-bound argument and the search design.

License

MIT: see LICENSE.

About

Proof that the three-colour Tantrix loop puzzle has maximum score exactly 25, an open question from jaapsch.net, with an explicit arrangement and an exhaustive search.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages