In [2]:
%pylab inline
In [66]:
nDoors = 3
doors = range(0, nDoors)
nCar = np.random.randint(0, nDoors)
print nCar
In [156]:
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.
_door.pop(np.random.randint(0, len(_doors)))
return _doors[0] if len(_doors) != 0 else nCar
In [308]:
# 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"