-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathday13.py
55 lines (48 loc) · 833 Bytes
/
day13.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
ans = 0
mp = 1
def comp(a, b):
if type(a) == int:
a = [a]
if type(b) == int:
b = [b]
if len(a) == 1 and len(b) == 1 and type(a[0]) == int and type(b[0]) == int:
if a[0] == b[0]:
return 0
if a[0] > b[0]:
return 1
if a[0] < b[0]:
return -1
if len(a) == 0 and len(b) == 0:
return 0
if len(a) == 0:
return -1
if len(b) == 0:
return 1
y = comp(a[0], b[0])
if y == 0:
return comp(a[1:], b[1:])
return y
arr = [[[2]], [[6]]]
while True:
l1 = input()
l2 = input()
if l1[0] == '~':
break;
a = eval(l1)
b = eval(l2)
arr.append(a)
arr.append(b)
x = comp(a, b)
#print(x)
if x == -1:
ans += mp
input()
mp += 1
from functools import cmp_to_key
arr.sort(key=cmp_to_key(comp))
ans2 = 1
for i in range(len(arr)):
if arr[i] == [[2]] or arr[i] == [[6]]:
ans2 *= (i+1)
print(ans)
print(ans2)