In [2]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [66]:
nDoors = 3
doors = range(0, nDoors)
nCar = np.random.randint(0, nDoors)
print nCar


1

In [312]:
def reveal_door(nDoors, nCar, nChoice):
    _doors = range(0, nDoors)
    _doors.pop(_doors.index(n1Choice))
    if nCar in _doors:
        _doors.pop(_doors.index(nCar))
    # Remove the door that is to be revealed.
    _doors.pop(np.random.randint(0, len(_doors)))
    return _doors[0] if len(_doors) != 0 else nCar

In [353]:
# Choose a door.
n1Choice = np.random.randint(0, nDoors)
# Remaining door.
nRemain = reveal_door(nDoors, nCar, n1Choice)
print n1Choice, nRemain, nCar
if (nRemain == nCar):
    print "\rYou've won"
else:
    print "\rYou've lost"


1 0 1
You've lost