The piece models the Rail Cube toy-train puzzle in Prolog: use all 35 physical track pieces to make a closed circuit, passing through the special crosspiece twice. The solver represents the train’s position, floor direction, and heading, giving 24 possible orientations, and applies each piece as a move while tracking collisions and remaining inventory. It uses backtracking, but prunes branches early when they cannot close, violate clearance or parity constraints, or fail to reach the required finishing pose. The scoring combines close calls and distinct train orientations with penalties for the track’s longest bounding-box side and repeated pieces, plus a bonus for a knot. The best layout found scores 47: it forms a trefoil knot in a 9-by-7-by-6 box and earns 32 close-call points, 15 orientation points, and 10 knot points, offset by a nine-point size penalty and one repeat. The knot test follows an Alexander-polynomial method and can miss some nontrivial knots.
A separate exhaustive search, organized around the two loops that meet at the crosspiece, counted 14,137,062,002 distinct layouts. “Distinct” ignores whole-assembly position or rotation, the starting point, and travel direction, but counts mirror images separately. Under this inventory, each layout yields 72 track strings, or just over 1.017 trillion strings overall; a canonical form identifies each layout consistently. The canonical-string export occupies about 487 GiB. The count was repeated with different batch sizes and checked against small independent searches, archive totals, and geometry checks of 11,506 sampled layouts. The author notes that the full runs share parts of their model and implementation, so agreement supports the result but is not a proof. The counting search does not calculate scores, leaving 47 as the best known rather than a proven maximum. The Prolog code can evaluate the example or launch a score search.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.