Browse Source

Quick and dirty day 13

master
Chris Smith 6 years ago
parent
commit
ff95b394af
2 changed files with 49 additions and 0 deletions
  1. 6
    0
      13.py
  2. 43
    0
      data/13.txt

+ 6
- 0
13.py View File

@@ -0,0 +1,6 @@
1
+import itertools
2
+
3
+with open('data/13.txt', 'r') as file:
4
+    layers = dict(map(lambda l: tuple(map(int, l.strip().split(': '))), file.readlines()))
5
+    print(f'Part one: {sum(offset * length for offset, length in layers.items() if offset % ((length-1) * 2) == 0)}')
6
+    print(f'Part two: {next(delay for delay in itertools.count() if all((offset + delay) % ((length - 1) * 2) != 0 for offset, length in layers.items()))}')

+ 43
- 0
data/13.txt View File

@@ -0,0 +1,43 @@
1
+0: 5
2
+1: 2
3
+2: 3
4
+4: 4
5
+6: 6
6
+8: 4
7
+10: 6
8
+12: 10
9
+14: 6
10
+16: 8
11
+18: 6
12
+20: 9
13
+22: 8
14
+24: 8
15
+26: 8
16
+28: 12
17
+30: 12
18
+32: 8
19
+34: 8
20
+36: 12
21
+38: 14
22
+40: 12
23
+42: 10
24
+44: 14
25
+46: 12
26
+48: 12
27
+50: 24
28
+52: 14
29
+54: 12
30
+56: 12
31
+58: 14
32
+60: 12
33
+62: 14
34
+64: 12
35
+66: 14
36
+68: 14
37
+72: 14
38
+74: 14
39
+80: 14
40
+82: 14
41
+86: 14
42
+90: 18
43
+92: 17

Loading…
Cancel
Save