-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhps.py
More file actions
55 lines (49 loc) · 1.31 KB
/
hps.py
File metadata and controls
55 lines (49 loc) · 1.31 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
# import time
# start_time = time.time()
with open("hps.in","r") as f_in:
N = int(f_in.readline().strip("\n"))
game = []
for _ in range(N):
x = f_in.readline().strip("\n").split()
game.append([int(x[0]),int(x[1])])
def win(dict1):
ctr = 0
for x in game:
player1 = x[0]
player2 = x[1]
if dict1[player1] == "hoof" and dict1[player2] == "scissors":
ctr += 1
elif dict1[player1] == "scissors" and dict1[player2] == "paper":
ctr += 1
elif dict1[player1] == "paper" and dict1[player2] == "hoof":
ctr += 1
return ctr
max = 0
dict1 = {1:"hoof", 2:"paper", 3:"scissors"}
t = win(dict1)
if t > max:
max = t
dict1 = {1:"hoof", 2:"scissors", 3:"paper"}
t = win(dict1)
if t > max:
max = t
dict1 = {1:"paper", 2:"hoof", 3:"scissors"}
t = win(dict1)
if t > max:
max = t
dict1 = {1:"paper", 2:"scissors", 3:"hoof"}
t = win(dict1)
if t > max:
max = t
dict1 = {1:"scissors", 2:"hoof", 3:"paper"}
t = win(dict1)
if t > max:
max = t
dict1 = {1:"scissors", 2:"paper", 3:"hoof"}
t = win(dict1)
if t > max:
max = t
# print(max)
with open("hps.out","w") as f_out:
f_out.write(str(max) + "\n")
# print("time elapsed: {:.2f}s".format(time.time() - start_time))