summaryrefslogtreecommitdiffstats
path: root/day5
diff options
context:
space:
mode:
Diffstat (limited to 'day5')
-rw-r--r--day5/__init__.py40
-rw-r--r--day5/example.txt3
-rw-r--r--day5/input.txt815
3 files changed, 0 insertions, 858 deletions
diff --git a/day5/__init__.py b/day5/__init__.py
deleted file mode 100644
index 405b589..0000000
--- a/day5/__init__.py
+++ /dev/null
@@ -1,40 +0,0 @@
1from math import ceil, floor
2from typing import Iterator, Any
3
4from aoc import BaseAssignment
5
6
7class Assignment(BaseAssignment):
8 def parse_item(self, item: str) -> Any:
9 row = self.calculate_postition(input=item[:7], min=0, max=127)
10 col = self.calculate_postition(input=item[7:], min=0, max=7)
11 return (row * 8) + col
12
13 def calculate_postition(self, input: str, min: int, max: int) -> int:
14 input_length = len(input)
15 action = input[0]
16 half = (max - min) / 2
17 if action in ['F', 'L']:
18 return min \
19 if input_length == 1 \
20 else self.calculate_postition(input[1:], min=min,
21 max=floor(max - half))
22 elif action in ['B', 'R']:
23 return max \
24 if input_length == 1 \
25 else self.calculate_postition(input[1:], min=ceil(min + half),
26 max=max)
27
28
29class AssignmentOne(Assignment):
30 def run(self, input: Iterator) -> Any:
31 return max(*input)
32
33
34class AssignmentTwo(Assignment):
35 def run(self, input: Iterator) -> Any:
36 seat_ids = sorted(input)
37 for index, id in enumerate(seat_ids):
38 next_id = id + 1
39 if id + 1 != seat_ids[index + 1]:
40 return next_id
diff --git a/day5/example.txt b/day5/example.txt
deleted file mode 100644
index f8b3bec..0000000
--- a/day5/example.txt
+++ /dev/null
@@ -1,3 +0,0 @@
1BFFFBBFRRR
2FFFBBBFRRR
3BBFFBBFRLL \ No newline at end of file
diff --git a/day5/input.txt b/day5/input.txt
deleted file mode 100644
index 0436d37..0000000
--- a/day5/input.txt
+++ /dev/null
@@ -1,815 +0,0 @@
1BFBBFFFLRR
2FFBFBBBLLL
3FBFBFBFLLL
4BBFFFBFLLR
5FBFFBBFLRR
6BBFBFFFLLL
7FFBBFFFRLL
8BFBFBBBR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FBBFFFBRLL
95FFBBFBBRRL
96FFBBFFFLLR
97FBFBBFBLLL
98BFFFBBFLRR
99BFBFBFFLRR
100BFFFFBFRRR
101BBFBBFFRLL
102BFBBBBBLRR
103BFBBBBFLLL
104BBFBBBBLLR
105FFBBBFFRRR
106BBFFBFBLRR
107FFFBBBFRLR
108BFBFFFBLRR
109BFFFBBFLLL
110FBBBBFFLRL
111FBBFFFFRRL
112FFBFFBBRRL
113BFBBBBBRLR
114FBBFFBBLRL
115BBFBFBBRLL
116FBFFBFBRLR
117FBBBBFFLLR
118FBBFBBFRRL
119FBFBBBBRLL
120BFFBFBFRLL
121FFBFBBFRRL
122FBFFFBFRRL
123FBFFBBFRRL
124FFBFBBFRLL
125BBFBBBBLRL
126BFFFBBBRRL
127FFBFFFBLRR
128FFBBFBBLRL
129BFBFBBFRRR
130BFFFFFFRRL
131FBBBBBBRRR
132FBFBBFBLRR
133FBFFFFFRLR
134BFFBBBFLRR
135BFBBFFBLLL
136FBFFFFBLRL
137FFBBBBBLRL
138FFFBBBFRLL
139FFBBFBFRLL
140FBFBBBFLRL
141FFBBBFBRLL
142BBFBBFBLRL
143FFBFBFFRLR
144BBFBBBBLRR
145FFFBBBBRRR
146FBBBFBFLLL
147BFFFBFBRLR
148FBBFBBFRRR
149FBFFBBBRLR
150FBFBBFBRLR
151FBBBFBBLLL
152BBFBFBFLLL
153FFBBFBBRLL
154FBBFBBBLRR
155BFFFBBFRRL
156BFBFFBFLRR
157BBFBBBFLLL
158BFFFBBFRLR
159BFBBFBFLRL
160FBBBBBFRRR
161FBFFFBBRRR
162BBFFFFBLRR
163FBFBFBFLRL
164BBFFBBBRLL
165FFBBBFFLRR
166FFBBBBFLRR
167FBFBFBBRRL
168BBFBFFBRRL
169FBBBFFBLLL
170BFBFFFFLLR
171FFBFFBFLRR
172BFBBFFFLLR
173BBFBBFFLRR
174BFFFFFFLLR
175BBFFBFBRRL
176FBBBFBBRLL
177BFBBBFBLLR
178BFBBFFBRLR
179FBFBBBFRRR
180BFBBBBBRRR
181FFBBFBBRLR
182FBBFBBFRLR
183BFFBBFBRLR
184FBFFFFFLLL
185FBBFFBFRLL
186FBBBBFFRRL
187FBFBBBBLRL
188FFFBBFBLRR
189FFBFFBBLRR
190FFBBBBBLRR
191FBBFFBFRRR
192FBBBFBFRRR
193FBBFBBBLLR
194BFFFFBFLLL
195FFBFFFFRRL
196BFBFFBBLRL
197FFBFFFFRLR
198FBFBFBFRLL
199BBFBFBBRRL
200FFBFBBFLLR
201BFBBFFBLLR
202FBFFBFFLLL
203BFFBBFBRRR
204FBFFFBBRLL
205BBFBBFFRRR
206FBFBBFBLRL
207FBFBFBBLRL
208FBFFBBFRRR
209FBFFBBBLRL
210FFBFBBBRRR
211BFBBBFFLLR
212FFBBFFFRRL
213FFBBBBBRRL