|
5 | 5 | numbers = sorted([int(x) for x in f])
|
6 | 6 |
|
7 | 7 | k = np.diff(numbers)
|
8 | | -print((1+len(k[k == 1])) * (1+len(k[k == 3]))) |
| 8 | +print((1+(k == 1).sum()) * (1+(k == 3).sum())) |
9 | 9 |
|
10 | | -# 1 --> ignore |
11 | | -# 2 --> 1, 0 (2) |
12 | | -# 3 --> 1 1, 1 0, 0 1, 0 0 (4) |
13 | | -# 4 --> 1 1 1, 1 0 0, 0 1 0, 0 0 1, 1 1 0, 1 0 1, 0 1 1 (7) |
14 | 10 | cands = [e for i, e in run_length.encode(np.diff([0]+numbers)) if i == 1 and e > 1]
|
15 | | -t = {2: 2, 3: 4, 4: 7} |
16 | | -transformed = [t[e] for e in cands] |
17 | | -print(np.prod(transformed)) |
| 11 | +combinations = {2: 2, 3: 4, 4: 7} |
| 12 | +print(np.prod([combinations[e] for e in cands])) |
0 commit comments