From 216f5909936d74244ccbf11fd8371b6a0472ed55 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Sun, 13 Dec 2020 23:09:29 +0100 Subject: [PATCH] Complete day 13, part 1 --- 13/input | 2 ++ 13/part1 | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 13/input create mode 100755 13/part1 diff --git a/13/input b/13/input new file mode 100644 index 0000000..b155530 --- /dev/null +++ b/13/input @@ -0,0 +1,2 @@ +1008833 +19,x,x,x,x,x,x,x,x,41,x,x,x,x,x,x,x,x,x,643,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,17,13,x,x,x,x,23,x,x,x,x,x,x,x,509,x,x,x,x,x,37,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,29 diff --git a/13/part1 b/13/part1 new file mode 100755 index 0000000..274043f --- /dev/null +++ b/13/part1 @@ -0,0 +1,12 @@ +#!/usr/bin/python3 + +with open("input") as fh: + now = int(fh.readline()) + ids = [int(x) for x in fh.readline().split(",") if x != "x"] + +min_dt = now # arbitrary large number +for id in ids: + dt = -now % id + if dt < min_dt: + print(id, dt, id * dt) + min_dt = dt