Skip to content

Python

Top Spin (revisited)

top spin

In a (much) earlier post of mine, I discussed a puzzle called Top Spin (once made by Binary Arts), in which 20 beads were placed on an oval track with a turntable that could flip the four beads that occupy it. I showed that it was possible to reverse the order of the beads, from [1, 2, 3, ..., 19, 20] to [20, 19, ..., 2, 1], even if the beads were placed on a straight track instead of an oval one.

However, recently I wanted to find create a more general solver that could correctly orient any permutation of the beads, not just the reversed order. Obviously, relying on the circular nature of the actual Top Spin puzzle would be required. Furthermore, while I doubt a perfect solver that always solved each permutation of the puzzle would be achievable, I still wanted to make something that was reasonably efficient.

More Thoughts on CodeCrafters

Im my previous post, I shared some of my thoughts on the CodeCrafters website and the coding challenges it offers. In particular, I had completed the HTTP server challenge in Rust and Claude Code challenge beta (notably, the number of available stages, and the feature set of the “completed” code, are quite limited) in Python and was working on the Interpreter challenge in Rust. I have since completed the Interpreter challenge, and decided to share some more thoughts on the experience.

Thoughts on CodeCrafters

CodeCrafters is a site where one can complete a number of programming challenges. Challenges include:

  • Build your own HTTP server
  • Build your own Interpreter
  • Build your own Shell
  • Build your own Claude Code (still in beta)

Each challenge is broken into a number of steps, with an extensive test suite triggered by the command codecrafters submit which:

A flip puzzle

Top Spin was a puzzle in which 20 beads were placed on an oval track with a turntable, such that any four consecutive beads could be flipped. Naturally, I wondered whether it was possible to reverse the order of the beads, from [0, 1, ..., 19] to [19, 18, ..., 0].

As it turns out, this is possible even if the beads are placed on a straight track instead of an oval one.