-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonty_Hall.py
More file actions
166 lines (126 loc) · 6.78 KB
/
Monty_Hall.py
File metadata and controls
166 lines (126 loc) · 6.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import random
import time
import os
from typing import no_type_check
def presentation():
DOORS = ['''
███╗░░░███╗░█████╗░███╗░░██╗████████╗██╗░░░██╗░░░░░░██╗░░██╗░█████╗░██╗░░░░░██╗░░░░░
████╗░████║██╔══██╗████╗░██║╚══██╔══╝╚██╗░██╔╝░░░░░░██║░░██║██╔══██╗██║░░░░░██║░░░░░
██╔████╔██║██║░░██║██╔██╗██║░░░██║░░░░╚████╔╝░█████╗███████║███████║██║░░░░░██║░░░░░
██║╚██╔╝██║██║░░██║██║╚████║░░░██║░░░░░╚██╔╝░░╚════╝██╔══██║██╔══██║██║░░░░░██║░░░░░
██║░╚═╝░██║╚█████╔╝██║░╚███║░░░██║░░░░░░██║░░░░░░░░░██║░░██║██║░░██║███████╗███████╗
╚═╝░░░░░╚═╝░╚════╝░╚═╝░░╚══╝░░░╚═╝░░░░░░╚═╝░░░░░░░░░╚═╝░░╚═╝╚═╝░░╚═╝╚══════╝╚══════╝
██████╗░██████╗░░█████╗░██████╗░██╗░░░░░███████╗███╗░░░███╗
██╔══██╗██╔══██╗██╔══██╗██╔══██╗██║░░░░░██╔════╝████╗░████║
██████╔╝██████╔╝██║░░██║██████╦╝██║░░░░░█████╗░░██╔████╔██║
██╔═══╝░██╔══██╗██║░░██║██╔══██╗██║░░░░░██╔══╝░░██║╚██╔╝██║
██║░░░░░██║░░██║╚█████╔╝██████╦╝███████╗███████╗██║░╚═╝░██║
╚═╝░░░░░╚═╝░░╚═╝░╚════╝░╚═════╝░╚══════╝╚══════╝╚═╝░░░░░╚═╝
█▄▄ █▄█ █▀▀ █▀▄▀█ ▄█ █▀█
█▄█ █ █▀ █ ▀ █ █ ▀▀█
||===||===||===|| ||===||===||===|| ||===||===||===||
|| 1 || || 2 || || 3 ||
|| O|| || O|| || O||
|| || || || || ||
|| || || || || ||
================== ================== ================== '''
,]
print(DOORS[0])
def door_opened (door):
DOOR = ['''
||===||===||===||
|| 1 ||
|| O||
|| ||
|| ||
=================== ''',
'''
||===||===||===||
|| 2 ||
|| O||
|| ||
|| ||
=================== ''',
'''
||===||===||===||
|| 3 ||
|| O||
|| ||
|| ||
=================== ''',
]
print(DOOR[door - 1])
def door_pair(door1, door2):
DOOR_PAIR = ['''
||===||===||===|| ||===||===||===||
|| ''' + str(door1)+ ''' || || ''' + str(door2) + ''' ||
|| O|| || O||
|| || || ||
|| || || ||
================== ================== '''
]
print(DOOR_PAIR[0])
def doors_state():
data = {
"CASE 1" : [1,2,3],
"CASE 2" : [3,2,1],
"CASE 3" : [2,1,3],
"CASE 4" : [2,3,1],
"CASE 5" : [1,3,2],
"CASE 6" : [3,1,2],
}
case_random = random.choice(list(data.values()))
return case_random
def door_select():
TITLE = ['''
█▀▀ █░░ █ █▀▀ █▀▀ █░█ █▄░█ ▄▀█ █▀█ █░█ █▀▀ █▀█ ▀█▀ ▄▀█
██▄ █▄▄ █ █▄█ ██▄ █▄█ █░▀█ █▀█ █▀▀ █▄█ ██▄ █▀▄ ░█░ █▀█
''',]
selected = int(input(TITLE[0]))
return selected
#########################################################################
def main():
presentation()
case_random = list(doors_state())
price = random.choice(case_random) ## UBICACION DEL PREMIO
answer = door_select() ## PUERTA ELEGIDA
if answer == price:
case_random.remove(answer)
not_price = random.choice(case_random)
case_random.remove(not_price)
not_price_final = random.choice(case_random)
elif answer != price:
case_random.remove(answer)
case_random.remove(price)
not_price_final = random.choice(case_random)
not_price = price
else:
pass
# case_random.remove(answer) ## QUITAMOS EL ELEMENTO ELEGIDO
# not_price = random.choice(case_random) ## ELEGIMOS UNA PUERTA CUALQUIERA
# case_random.remove(not_price)
last_select = not_price
print("ELEGISTE LA PUERTA: " + str(answer))
door_opened(answer)
time.sleep(1.5)
print("LA PUERTA " + str(not_price_final) + " NO TIENE EL PREMIO")
door_opened(not_price_final)
time.sleep(1)
print("SOLO QUEDA LA PUERTA: " + str(answer) + " Y LA PUERTA: " + str(last_select))
door_pair(answer, last_select)
time.sleep(1)
change = input("DESEAS CAMBIAR DE PUERTA? Y/N: ")
if (change == 'Y') or (change == 'y'):
answer = last_select
elif (change == 'N') or (change == 'n'):
answer = answer
else:
pass
if answer == price:
print("GANASTE!")
else:
print("PERDISTE :(")
print("LA PUERTA GANADORA ES: " + str(price))
door_opened(price)
if __name__ == "__main__":
main()