# CayleyR: Solving the TopSpin puzzle via cycle intersection

arXiv: https://arxiv.org/abs/2607.13219 · HTML: https://mlsanity.com/paper/2607.13219/

## Key facts

- No citing papers in the map yet (data through 14 Oct 2026).
- Builds on 2 of its 13 references that are in the map.
- First posted on arXiv 14 Jul 2026.

## Builds on (most cited first, 2 of 2)

- [CayleyPy RL: Pathfinding and Reinforcement Learning on Cayley Graphs](https://mlsanity.com/paper/2502.18663/) (2025)
- [CayleyPy-4: AI-Holography. Towards analogs of holographic string dualities for AI tasks](https://mlsanity.com/paper/2603.22195/) (2026)

## Abstract (arXiv)

We present cayleyR, an R package for solving permutation puzzles by detecting cycle intersections in Cayley graphs. The core algorithm performs an iterative bidirectional search: from both the initial and target permutation states, random operation sequences generate cycles in the Cayley graph of the symmetric group Sn; their intersection yields a connecting path. When no direct intersection is found, a distance-guided bridge selection narrows the gap, and the process repeats. The package targets the TopSpin(n,k) puzzle, whose state space is a Cayley graph of Sn generated by a cyclic shift and a prefix reversal. We describe the mathematical framework, the algorithm, and its implementation, which combines a C++ hash-indexed state store with optional Vulkan GPU acceleration. The software is publicly available on CRAN.
