Skip to content

Instantly share code, notes, and snippets.

View bjornedstrom's full-sized avatar

Björn Edström bjornedstrom

View GitHub Profile
"""
The names of 100 prisoners are placed in 100 wooden boxes, one name to a box, and the boxes are
lined up on a table in a room. One by one, the prisoners are led into the room; each may look
in at most 50 boxes, but must leave the room exactly as he found it and is permitted no further
communication with the others.
The prisoners have a chance to plot their strategy in advance, and they are going to need it,
because unless every single prisoner finds his own name all will subsequently be executed.
Find a strategy for them which which has probability of success exceeding 30%.
"""
@bjornedstrom
bjornedstrom / gist:9768526
Last active August 29, 2015 13:57
Peg game solver
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Bjorn Edstrom 2014 <be@bjrn.se>
# weather break...
import sys
"""
peg game. board representation: