From 9b0cdfd4455b00997839ae414bb3dddb378310a2 Mon Sep 17 00:00:00 2001 From: Nathan van Ofwegen Date: Thu, 10 Dec 2020 22:51:27 +0100 Subject: [PATCH] day10 pt1 --- day10/day10.py | 26 ++++++++++++++ day10/input.txt | 90 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 day10/day10.py create mode 100644 day10/input.txt diff --git a/day10/day10.py b/day10/day10.py new file mode 100644 index 0000000..ac8d8ee --- /dev/null +++ b/day10/day10.py @@ -0,0 +1,26 @@ +def part1(): + file = open("input.txt") + lines = [int(i) for i in file.readlines()] + + lines = sorted(lines) + + diffs = {1: 0, 3: 0} + + diffs[lines[0]] += 1 + lines.append(max(lines) + 3) + + for i in range(1, len(lines)): + diff = lines[i] - lines[i - 1] + diffs[diff] += 1 + + print("Part 1 %d " % (diffs[1] * diffs[3])) + + +def part2(): + file = open("input.txt") + lines = [int(i) for i in file.readlines()] + + +if __name__ == "__main__": + part1() + part2() diff --git a/day10/input.txt b/day10/input.txt new file mode 100644 index 0000000..1ae22aa --- /dev/null +++ b/day10/input.txt @@ -0,0 +1,90 @@ +114 +51 +122 +26 +121 +90 +20 +113 +8 +138 +57 +44 +135 +76 +134 +15 +21 +119 +52 +118 +107 +99 +73 +72 +106 +41 +129 +83 +19 +66 +132 +56 +32 +79 +27 +115 +112 +58 +102 +64 +50 +2 +39 +3 +77 +85 +103 +140 +28 +133 +78 +34 +13 +61 +25 +35 +89 +40 +7 +24 +33 +96 +108 +71 +11 +128 +92 +111 +55 +80 +91 +31 +70 +101 +14 +18 +12 +4 +84 +125 +120 +100 +65 +86 +93 +67 +139 +1 +47 +38