-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunOffAS53
More file actions
66 lines (66 loc) · 1.4 KB
/
RunOffAS53
File metadata and controls
66 lines (66 loc) · 1.4 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
def CountVotes():
Winner=False
A="Alice"
B="Bob"
C="Charlie"
Votes=[[A,B,C],[A,C,B],[B,C,A],[B,A,C],[C,A,B]]
CountA=0
CountB=0
CountC=0
y=0
for x in range(len(Votes)):
if Votes[x][y]==A:
CountA=CountA+1
elif Votes[x][y]==B:
CountB=CountB+1
else:
CountC=CountC+1
if CountA/len(Votes)>0.5:
return A
Winner=True
elif CountB/len(Votes)>0.5:
return B
Winner=True
elif CountC/len(Votes)>0.5:
return C
Winner=True
else:
if min(CountA,CountB,CountC)==CountB:
CountA=0
removed=A
elif min(CountA,CountB,CountC)==CountB:
CountB=0
removed=B
else:
CountC=0
removed=C
while Winner==False:
y=y+1
for x in range(len(Votes)):
if Votes[x][y-1]==removed:
if Votes[x][y]==A:
CountA=CountA+1
elif Votes[x][1]==B:
CountB=CountB+1
else:
CountC=CountC+1
if CountA/len(Votes)>0.5:
return A
Winner=True
elif CountB/len(Votes)>0.5:
return B
Winner=True
elif CountC/len(Votes)>0.5:
return C
Winner=True
else:
if min(CountA,CountB,CountC)==CountB:
CountA=0
removed=A
elif min(CountA,CountB,CountC)==CountB:
CountB=0
removed=B
else:
CountC=0
removed=C
print(CountVotes())