The stolen necklace problem presents itself as a simple problem: given a necklace with n beads, each of which can be one of k colors, how many distinct necklaces can be formed?

I found out about this problem while watching a video from 3blue1brown on the Borsuk-Ulam theorem. The problem is a classic example of how topology can be applied to discrete problems, and it has a surprisingly elegant solution.


In Layman’s Terms

Given what we said above using the variables and , the number of distinct necklaces can be calculated using the formula:

Computationally, we can implement this using the following steps:

quite a long script, so I don’t expect you to read it all, but I will explain the main parts below

Python
Output

How it Works

  • Sanity check: every color shows up an even number of times, otherwise a perfect split is impossible.
  • Quick win: try a two‑cut solution by sliding an arc around the circle; if an arc contains exactly half of each color, we’re done.
  • If that fails: run a bounded backtracking search that alternates ownership across segments and prunes branches that can’t possibly hit the half‑counts, increasing the cut budget until something fits.
  • Output: cut indices (between i and i+1 mod n), method used, and a tiny verification that simulates a lap around the necklace.

But this computation isnt really following the Borsuk-Ulam theorem, which states that any continuous function from an n-sphere to R^n must have a pair of antipodal points that map to the same value. The necklace problem is a discrete version of this, where we are looking for pairs of points (cuts) that yield the same color distribution.


The Full Explanation

todo… will reference video and minimizing function… Borsuk-Ulam Theorem