# Simulating the Monty Hall problem
#
import random, sys
if sys.version > '3' : raw_input = input # Python 3
initial = raw_input("Initial choice (A,B,C)? ").upper()
action = raw_input("Always Switch/Hold (S,H) ? ").upper()
doors = ["A","B","C"]
totWins = 0
print("Let's play 100 times")
for i in range(100) :
placed = random.choice(doors) # Prize placed randomly
chosen = initial # Your first choice
used = [chosen,placed] # Moderator chooses an empty door
avail = [door for door in doors if door not in used]
opened = random.choice(avail)
if action == "S" : # You switch to remaining door
avail = [door for door in doors if door not in [chosen,opened]]
chosen = avail[0] # should be the only door left
youWin = (chosen == placed)
if youWin : totWins += 1
mesg = " Prize placed behind %s" % placed
mesg += "-You chose %s -Monty opened %s " % (initial,opened)
if action == "H" : mesg += " -You held to %s" % chosen
else : mesg += " -You switched to %s" % chosen
if youWin : mesg += " - won"
print(mesg)
print("Total Wins %d/100" % totWins)