-
Notifications
You must be signed in to change notification settings - Fork 0
/
padlock.py
136 lines (91 loc) · 2.8 KB
/
padlock.py
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
import os
os.system("cls")
import time
print(" _____________WELCOME TO THE PADLOCK CHALLENGE____________ " )
print("WHICH OF THE PADLOCK CODE CHALLENGE DO YOU NEED AN ANSWER TO: ")
print("1. pad1")
print("2. pad2")
print("3. pad3")
print("4. pad4")
print("5. pad5")
def pad_1():
code = 0
for i in range(1,41):
code = code + i
print("Code:")
print(code)
return
def pad_2():
code = 0
for digit1 in range(0,10):
for digit2 in range(0,10):
for digit3 in range(0,10):
if (digit1 < digit2) and (digit2 < digit3):
code +=1
print("Code:")
print(code)
return
def pad_3():
code = 0
for digit1 in range(0,10):
for digit2 in range(0,10):
for digit3 in range(0,10):
if (digit1%2 == 0) and (digit2%2 == 0) and (digit3%2 == 0):
code +=1
print("Code:")
print(code)
return
def pad_4():
code = 0
for digit1 in range(0,10):
for digit2 in range(0,10):
for digit3 in range(0,10):
if (digit1 + digit2 +digit3) %2 != 1:
code +=1
print("Code:")
print(code)
return
def pad_5():
code = 0
for digit1 in range(0,10):
for digit2 in range(0,10):
for digit3 in range(0,10):
if (digit1 == digit2) or (digit1 == digit3) or (digit2 == digit3):
code +=1
print("Code:")
print(code)
return
while True:
# take input from the user
choice = input("Enter choice(1/2/3/4/5): ")
# check if choice is one of the four options
if choice in ('1', '2', '3', '4', '5'):
try:
'''print("WHICH OF THE PADLOCK CODE CHALLENGE DO YOU NEED AN ANSWER TO: ")
print("1. pad1")
print("2. pad2")
print("3. pad3")
print("4. pad4")
print("5. pad5")'''
except ValueError:
print("Invalid input. Please enter a number between 1 and 5.")
continue
# check if choice is one of the four options
if choice in ('1', '2', '3', '4' , '5'):
if choice == '1':
pad_1()
elif choice == '2':
pad_2()
elif choice == '3':
pad_3()
elif choice == '4':
pad_4()
elif choice == '5':
pad_5()
# check if user wants another calculation
# break the while loop if answer is no
next_solution = input("Will you like to check another solution ? (yes/no): ")
if next_solution == "no":
break
else:
print("Invalid Input")