From 3bb23093ae15aaa2b11c3b3d771d6a9e42b73a0c Mon Sep 17 00:00:00 2001 From: Cody Hiar Date: Fri, 5 Feb 2021 10:43:34 -0700 Subject: day 7 part 1 --- day5/day5.py | 18 ++++++++++++++++++ day5/main.py | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 day5/day5.py delete mode 100644 day5/main.py (limited to 'day5') diff --git a/day5/day5.py b/day5/day5.py new file mode 100644 index 0000000..b544b61 --- /dev/null +++ b/day5/day5.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) diff --git a/day5/main.py b/day5/main.py deleted file mode 100644 index b544b61..0000000 --- a/day5/main.py +++ /dev/null @@ -1,18 +0,0 @@ -"""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) -- cgit v1.2.3