forked from osirislab/Hack-Night
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinput3.py
More file actions
35 lines (26 loc) · 917 Bytes
/
input3.py
File metadata and controls
35 lines (26 loc) · 917 Bytes
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
from random import randint
def printpegs(code):
print " --------------------- "
print " |",
for c in code:
print c, "|",
print ""
print " --------------------- "
print "Master Mind Game"
flag = "this_is_a_flag"
mm_code = (randint(0,9), randint(0,9), randint(0,9), randint(0,9), randint(0,9))
print "I've set my code. Guess it!"
print "Rules: You should input your guesses as 5 digits separated by commas."
print " I will respond by marking the correct digits with a 2, marking"
print " digits in the wrong place with a 1, and marking wrong digits 0."
while True:
guess = input('guess> ')
if len(guess) != 5:
print "You must guess a 5-digit code!"
continue
printpegs(guess)
right = map(lambda x,y: (x == y) + (x in mm_code), guess, mm_code)
printpegs(right)
if guess == mm_code:
print "You got it right!"
exit(0)