-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
66 lines (43 loc) · 981 Bytes
/
main.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
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
from shapley import shapley_value
def gnomes_v(pls):
return divmod(len(pls), 2)[0]
def business_v(pls):
return landlord(pls, lambda x: x)
def landlord(pls, f):
x = len(pls) - 1
if 1 in pls:
return f(x)
else:
return 0
def landlord_sq(lst):
return landlord(lst, lambda x: x * x)
def socks_v(pls):
if len(pls) >= 2:
return 1
else:
return 0
def shoes_v(pls):
if 1 in pls and len(pls) >= 2:
return 1
else:
return 0
def shoes_mn_v(pls):
ll = len([None for x in pls if x < 0])
rr = len([None for x in pls if x > 0])
return min(ll, rr)
def road(pls):
return -max(pls, default=0)
def pipes(pls):
if pls == {1, 2}:
return 4
elif pls == {1, 3}:
return 1
elif pls == {1, 2, 3}:
return 4
return 0
players = [1, 2, 3, 4, 5]
v = road
vect = shapley_value(players, v)
print(vect)
print(sum(vect))
print(vect[0] / v(set(players)))