This repository was archived by the owner on Nov 23, 2021. It is now read-only.
forked from jordanbaez/DA_exercises
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsorcerers
More file actions
81 lines (64 loc) · 1.91 KB
/
sorcerers
File metadata and controls
81 lines (64 loc) · 1.91 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
gandalf = [10, 11, 13, 30, 20, 11, 10, 33, 22, 22]
saruman = [23, 66, 12, 33, 12, 10, 44, 23, 12, 17]
gwin=0
swin=0
for z in range(len(gandalf)):
if gandalf[z] < saruman[z]:
swin = swin+1
elif gandalf[z] == saruman[z]:
swin = swin+1
gwin = gwin+1
else:
gwin = gwin+1
if gwin > swin:
print('Gandalf wins')
elif gwin<swin:
print ('Saruman wins')
else:
print('Tie')
#BONUS
power = {
'Fireball': 50,
'Lightning bolt': 40,
'Magic arrow': 10,
'Black Tentacles': 25,
'Contagion': 45
}
gandalf = ['Fireball', 'Lightning bolt', 'Lightning bolt', 'Magic arrow', 'Fireball',
'Magic arrow', 'Lightning bolt', 'Fireball', 'Magic arrow', 'Fireball']
saruman = ['Contagion', 'Contagion', 'Black Tentacles', 'Fireball', 'Black Tentacles',
'Lightning bolt', 'Magic arrow', 'Contagion', 'Magic arrow', 'Magic arrow']
gpower = []
spower = []
for g in gandalf:
for k, v in power.items():
if k == g:
gpower.append(v)
print('gpower ',gpower)
for s in saruman:
for k, v in power.items():
if k == s:
spower.append(v)
print('spower ',spower)
count=[]
for y in range(len(gpower)):
if gpower[y] > spower[y]:
count.append('true')
elif gpower[y] == spower[y]:
count.append('true')
else:
count.append('false')
print(count)
v = 'true' # search for this value
n = 3 # number of consecutive appearances of v
vList = [v] * n
for i in range(len(count) - n):
if count[i:i + n] == vList:
print ('Gandalf wins')
break
else:
print ('Saruman wins')
print ('Gandalf\'s spell average = ', sum(gpower)/len(gpower))
print ('Saruman\'s spell average = ', sum(spower)/len(spower))
import numpy
print ('Gandalf\'s standard deviation = ',numpy.array(gpower).std(),', and Saruman\'s standard deviation = ',numpy.array(gpower).std())