CayleyR Package Solves TopSpin Puzzle Using Cycle Intersection

Yuri Baramykov· July 16, 2026 View original

Summary

CayleyR is an R package designed to solve permutation puzzles like TopSpin(n,k) by detecting cycle intersections in Cayley graphs. It employs an iterative bidirectional search, generating cycles from both initial and target states to find a connecting path.

Solving complex permutation puzzles, such as the TopSpin(n,k), can be approached using graph theory. The CayleyR R package offers a novel method to tackle these challenges by identifying cycle intersections within Cayley graphs. This package is built upon an iterative bidirectional search algorithm. The core of the algorithm involves generating random operation sequences from both the starting and desired permutation states, which in turn create cycles within the Cayley graph of the symmetric group Sn. If these cycles intersect, a direct solution path is found. If not, a distance-guided bridge selection strategy is used to narrow the gap, and the process is repeated. The CayleyR implementation combines a C++ hash-indexed state store with optional Vulkan GPU acceleration, making it an efficient tool for combinatorial problem-solving.

Why it matters

Professionals in fields requiring combinatorial optimization or complex state-space search can leverage such algorithmic approaches to solve intricate problems more efficiently, potentially extending to areas beyond puzzles.

How to implement this in your domain

  1. 1Install the CayleyR package in an R environment.
  2. 2Familiarize with the package's functions for defining puzzle states and operations.
  3. 3Apply the cycle intersection algorithm to solve instances of the TopSpin puzzle.
  4. 4Explore adapting the underlying mathematical framework to other permutation-based or combinatorial problems.
  5. 5Utilize the optional Vulkan GPU acceleration for performance optimization on larger problem instances.

Who benefits

LogisticsOperations ResearchSoftware DevelopmentAcademia

Key takeaways

  • CayleyR is an R package for solving permutation puzzles using Cayley graph cycle intersections.
  • It employs an iterative bidirectional search from initial and target states.
  • The algorithm generates cycles and seeks their intersection to find solutions.
  • The implementation uses C++ and optional Vulkan GPU acceleration for efficiency.

Original post by Yuri Baramykov

"arXiv:2607.13219v1 Announce Type: new Abstract: 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,…"

View on X

Originally posted by Yuri Baramykov on X · view source

Want to go deeper?

Turn these trends into skills with Learnijoy's hands-on AI & tech courses.

Explore courses