Browse Source

Move puzzle inputs to a subdir

master
Chris Smith 7 years ago
parent
commit
cf1cad80cb
24 changed files with 12 additions and 12 deletions
  1. 1
    1
      01.py
  2. 1
    1
      02.py
  3. 1
    1
      03.py
  4. 1
    1
      04.py
  5. 1
    1
      06.py
  6. 1
    1
      07.py
  7. 1
    1
      08.py
  8. 1
    1
      09.py
  9. 1
    1
      10.py
  10. 1
    1
      11.py
  11. 1
    1
      12.py
  12. 1
    1
      15.py
  13. 0
    0
      data/01.txt
  14. 0
    0
      data/02.txt
  15. 0
    0
      data/03.txt
  16. 0
    0
      data/04.txt
  17. 0
    0
      data/06.txt
  18. 0
    0
      data/07.txt
  19. 0
    0
      data/08.txt
  20. 0
    0
      data/09.txt
  21. 0
    0
      data/10.txt
  22. 0
    0
      data/11.txt
  23. 0
    0
      data/12.txt
  24. 0
    0
      data/15.txt

+ 1
- 1
01.py View File

@@ -8,7 +8,7 @@ def steps(start, delta, count):
8 8
     sign = int(math.copysign(1, delta))
9 9
     return [start] * count if delta == 0 else range(start + sign, start + delta + sign, sign)
10 10
 
11
-with open('01.txt', 'r') as file:
11
+with open('data/01.txt', 'r') as file:
12 12
     input = file.read()
13 13
 
14 14
 movement_lookup = {'L': -1, 'R': +1}

+ 1
- 1
02.py View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 import operator
4 4
 
5
-with open('02.txt', 'r') as file:
5
+with open('data/02.txt', 'r') as file:
6 6
     input = [x.strip() for x in file.readlines()]
7 7
 
8 8
 dirs = {'U': (0, -1), 'D': (0, 1), 'L': (-1, 0), 'R': (1, 0)}

+ 1
- 1
03.py View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 from itertools import chain
4 4
 
5
-with open('03.txt', 'r') as file:
5
+with open('data/03.txt', 'r') as file:
6 6
     tris = [[int(s) for s in l.strip().split()] for l in file.readlines()]
7 7
     possible = lambda tris: len([1 for t in [sorted(t) for t in tris] if t[0] + t[1] > t[2]])
8 8
     print("Part one: %s" % possible(tris))

+ 1
- 1
04.py View File

@@ -3,7 +3,7 @@
3 3
 import re
4 4
 from collections import namedtuple
5 5
 
6
-with open('04.txt', 'r') as file:
6
+with open('data/04.txt', 'r') as file:
7 7
     Room = namedtuple('Room', 'name sector checksum')
8 8
     rooms = [Room(*re.search(r'^(.*?)-([0-9]+)\[(.*?)\]$', l).groups()) for l in file.readlines()]
9 9
     checksum = lambda x: re.sub(r'(.)\1+', r'\1',

+ 1
- 1
06.py View File

@@ -1,6 +1,6 @@
1 1
 #!/usr/bin/python3
2 2
 
3
-with open('06.txt', 'r') as file:
3
+with open('data/06.txt', 'r') as file:
4 4
     cols = list(zip(*map(str.strip, file.readlines())))
5 5
     print(''.join(max(set(col), key=col.count) for col in cols))
6 6
     print(''.join(min(set(col), key=col.count) for col in cols))

+ 1
- 1
07.py View File

@@ -15,7 +15,7 @@ hypernet = lambda x: re.sub(r'^.*?\[|\].*?\[|\].*?$', '#', x)
15 15
 # Returns all supernet parts (outside of brackets) of x
16 16
 supernet = lambda x: re.sub(r'\[.*?\]', '#', x)
17 17
 
18
-with open('07.txt', 'r') as file:
18
+with open('data/07.txt', 'r') as file:
19 19
     ips = list(map(str.strip, file.readlines()))
20 20
     # tls: has at least one ABBA that's not also in its hypernet sections
21 21
     tls = set(filter(abba, ips)) - set(filter(lambda ip: abba(hypernet(ip)), ips))

+ 1
- 1
08.py View File

@@ -3,7 +3,7 @@
3 3
 import re
4 4
 import numpy as np
5 5
 
6
-with open('08.txt', 'r') as file:
6
+with open('data/08.txt', 'r') as file:
7 7
     lines = list(map(str.strip, file.readlines()))
8 8
     lights = np.zeros((6, 50), dtype=bool)
9 9
     for line in lines:

+ 1
- 1
09.py View File

@@ -23,7 +23,7 @@ def parse(data, rfun=len):
23 23
             + parse(data[bracket + 1 + num:], rfun))
24 24
 
25 25
 
26
-with open('09.txt', 'r') as file:
26
+with open('data/09.txt', 'r') as file:
27 27
     input = re.sub('\s+', '', file.read())
28 28
     print(parse(input))
29 29
     print(rparse(input))

+ 1
- 1
10.py View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 import collections
4 4
 
5
-with open('10.txt', 'r') as file:
5
+with open('data/10.txt', 'r') as file:
6 6
     targets = collections.defaultdict(lambda: {'inputs': [], 'low': -1, 'high': -1})
7 7
     lines = list(map(str.split, map(str.strip, file.readlines())))
8 8
     for instr in lines:

+ 1
- 1
11.py View File

@@ -6,7 +6,7 @@ import itertools, re
6 6
 lift = '*YOU ARE HERE*'
7 7
 
8 8
 # Read the input
9
-with open('11.txt', 'r') as file:
9
+with open('data/11.txt', 'r') as file:
10 10
     lines = list(map(str.strip, file.readlines()))
11 11
     floors = [re.findall(r'\b(\S+ (?:generator|microchip))\b', line) for line in lines]
12 12
     floors[0].append(lift)

+ 1
- 1
12.py View File

@@ -1,6 +1,6 @@
1 1
 #!/usr/bin/python3
2 2
 
3
-with open('12.txt', 'r') as file:
3
+with open('data/12.txt', 'r') as file:
4 4
     instr = list(map(str.split, map(str.strip, file.readlines())))
5 5
 
6 6
 def value(x):

+ 1
- 1
15.py View File

@@ -24,7 +24,7 @@ def run(lines):
24 24
     times = (i for i, c in enumerate(combos) if all(p == 0 for p in c))
25 25
     return next(times)
26 26
 
27
-with open('15.txt', 'r') as file:
27
+with open('data/15.txt', 'r') as file:
28 28
     lines = file.readlines()
29 29
     print("Step 1: %s" % run(lines))
30 30
     print("Step 2: %s" % run(lines + ['Disc #7 has 11 positions; at time=0, it is at position 0.']))

01.txt → data/01.txt View File


02.txt → data/02.txt View File


03.txt → data/03.txt View File


04.txt → data/04.txt View File


06.txt → data/06.txt View File


07.txt → data/07.txt View File


08.txt → data/08.txt View File


09.txt → data/09.txt View File


10.txt → data/10.txt View File


11.txt → data/11.txt View File


12.txt → data/12.txt View File


15.txt → data/15.txt View File


Loading…
Cancel
Save