-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprob49.py
More file actions
40 lines (38 loc) · 1.07 KB
/
Copy pathprob49.py
File metadata and controls
40 lines (38 loc) · 1.07 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
__author__ = 'Vince'
"""Rock Paper Scissors"""
def rps(moveset):
"""Moveset should be list of strings such as RS, SR, PP representing
the first and second players moves. Function counts who wins
most games and returns the winner (1 or 2).
"""
player_one_wins = 0
player_two_wins = 0
for game in moveset:
if game[0] == game[1]:
continue
elif game[0] == 'R':
if game[1] == 'S':
player_one_wins += 1
else:
player_two_wins += 1
elif game[0] == "S":
if game[1] == "P":
player_one_wins += 1
else:
player_two_wins += 1
else:
if game[1] == "R":
player_one_wins += 1
else:
player_two_wins += 1
if player_one_wins > player_two_wins:
return 1
elif player_two_wins > player_one_wins:
return 2
else:
return "draw"
inp = open('test.txt')
N = int(inp.readline())
for i in range(N):
print rps(inp.readline().split()),
inp.close()