100 Prisoners Problem
en.wikipedia.org
en.wikipedia.org
By swapping two items, the spy can break any cycle longer than 50 into two smaller cycles. Since every prisoner is then guaranteed to be on a loop of length 50 or less, everyone is mathematically certain to find their number.