# Prolog Solver Finds 14 Billion Valid Rail Cube Layouts and a 47-Point Track

Original title: Rail Cube in Prolog

> Hacker News story 50686625 · language: en · submitted 2026-11-29
> Web version: https://zeli.app/story/50686625
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 30 · by [triska](<https://news.ycombinator.com/user?id=triska>) · 💬 0
[original](<https://chen.cat/prolog/railcube/>) · [HN discussion](<https://news.ycombinator.com/item?id=50686625>)

## Summary

Inspired by Owen Lacey's Rail Cube optimization, I built a Prolog solver for the toy train set whose tracks run along walls and upside down. Using backtracking with early cuts, it found a 47-point layout—beating the previous 42—and an exhaustive count of 14,137,062,002 distinct circuits. The solver runs under Scryer Prolog and Trealla without a constraint library, and the full enumeration was verified by a second independent run.

## Key quote

> The Prolog search prints improvements and distinct ties, and saves them in rail-cube2-solutions.pl.

---

## Cite

- Page: https://zeli.app/story/50686625
- Date: 2026-11-29
- Source: chen.cat (https://chen.cat/prolog/railcube/)
- Hacker News: https://news.ycombinator.com/item?id=50686625

## Other languages

- zh: https://zeli.app/zh/story/50686625 · markdown: https://zeli.app/zh/story/50686625.md
- ja: https://zeli.app/ja/story/50686625 · markdown: https://zeli.app/ja/story/50686625.md
- ko: https://zeli.app/ko/story/50686625 · markdown: https://zeli.app/ko/story/50686625.md
- de: https://zeli.app/de/story/50686625 · markdown: https://zeli.app/de/story/50686625.md
- es: https://zeli.app/es/story/50686625 · markdown: https://zeli.app/es/story/50686625.md
- ru: https://zeli.app/ru/story/50686625 · markdown: https://zeli.app/ru/story/50686625.md
