-
Notifications
You must be signed in to change notification settings - Fork 0
/
10th.py
63 lines (56 loc) · 1.05 KB
/
10th.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
import numpy as np
input = np.loadtxt("10-input.txt")
n = input.size
input.sort()
ones = 0
twos = 0
threes = 0
jolt = 0
diff = np.empty(n)
for i in range(n):
if (input[i]-jolt == 1):
ones+=1
diff[i]=1
elif (input[i]-jolt == 2):
twos+=1
diff[i]=2
elif (input[i]-jolt == 3):
threes+=1
diff[i]=3
else:
print("error")
jolt = input[i]
print(input)
print(diff)
print("ones: ", ones)
print("twos: ", twos)
print("threes: ", threes)
print ("check:", n - ones - twos - threes)
print ("threees times ones: ", (threes+1)*ones)
arr = 0.
i = 0
j = 0
number = 1
while (j < n):
while (i<n and diff[i]==1):
arr += 1
i += 1
if (arr == 0.):
print("0")
elif (arr == 1):
print("1")
elif (arr == 2):
print("2")
number *= 2
elif (arr == 3):
print("3")
number *= 4
elif (arr == 4):
print("4")
number *= 7
else:
print(arr)
i += 1
arr = 0
j = i
print ("number of combinations:", number)