-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount.py
executable file
·39 lines (35 loc) · 948 Bytes
/
count.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
#!/usr/bin/python3
import sys
import numpy as np
import matplotlib.pyplot as plt
def main() -> int:
if (len(sys.argv) != 1):
print("usage: {}".format(sys.argv[0]), file=sys.stderr)
return 1
N = -1
scores = None
hist = []
succ = []
for line in sys.stdin:
a = list(map(int, line.split()))
if (N == -1):
N = len(a)
scores = np.zeros(N)
ans = -1
for i in sorted(a):
if (a.count(i) == 1):
ans = a.index(i)
break
if (ans != -1):
scores[ans] += 1
succ.append(sum(scores))
hist.append(scores.copy())
succ = np.array(succ)
hist = np.array(hist).T / succ
plt.stackplot(np.arange(hist.shape[1])+1, *hist, labels=["strategy " + str(i) for i in range(N)])
plt.xscale("log")
plt.legend()
plt.show()
return 0
if (__name__ == "__main__"):
exit(main())