Implementation of a solution to the 100 prisoners and the lightbulb problem, with stages