diff options
author | Cody Hiar <cody@hiar.ca> | 2021-02-05 09:29:54 -0700 |
---|---|---|
committer | Cody Hiar <cody@hiar.ca> | 2021-02-05 09:29:54 -0700 |
commit | b4a3bd52e5e610f431d9aa49e3ac0af918e1e344 (patch) | |
tree | 0b0a1794a93d7f9cfa5bfa9088eb75da750d7c94 /day5/main.py | |
parent | 34f71edd66e22b7d1e1b262d92d80e1bf335aa57 (diff) |
Adding day 5 and 6
Diffstat (limited to 'day5/main.py')
-rw-r--r-- | day5/main.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/day5/main.py b/day5/main.py new file mode 100644 index 0000000..b544b61 --- /dev/null +++ b/day5/main.py @@ -0,0 +1,18 @@ +"""Peter Norvig solution. Forgot to do day 5.""" +data = map(str.strip, open("input")) + +ID = int + +def seat_id(seat: str, table=str.maketrans('FLBR', '0011')) -> ID: + "Treat a seat description as a binary number; convert to int." + return ID(seat.translate(table), base=2) + + +ids = [seat_id(x) for x in data] + +# Part 1 +print(max(ids)) + +# Part 2 +[missing] = set(range(min(ids), max(ids))) - set(ids) +print(missing) |