diff --git a/10/10.py b/10/10.py new file mode 100644 index 0000000..95273c8 --- /dev/null +++ b/10/10.py @@ -0,0 +1,23 @@ + +with open("input") as f: + adapters = [int(x) for x in f.read().strip().split("\n")] + +adapters.extend([0, max(adapters)+3]) +adapters.sort() +joltages = [b-a for a, b in zip(adapters, adapters[1:])] +print(joltages.count(1)*joltages.count(3)) + + +joltages = ''.join(str(x) for x in joltages) +joltages = joltages.split('3') + +counts = { + '': 1, + '1': 1, + '11': 2, + '111': 4, + '1111': 7, + } +from functools import reduce +print(reduce(lambda x, y: x*counts[y], joltages, 1)) + diff --git a/10/input b/10/input new file mode 100644 index 0000000..5b0d755 --- /dev/null +++ b/10/input @@ -0,0 +1,102 @@ +153 +17 +45 +57 +16 +147 +39 +121 +75 +70 +85 +134 +128 +115 +51 +139 +44 +65 +119 +168 +122 +72 +105 +31 +103 +89 +154 +114 +55 +25 +48 +38 +132 +157 +84 +71 +113 +143 +83 +64 +109 +129 +120 +100 +151 +79 +125 +22 +161 +167 +19 +26 +118 +142 +4 +158 +11 +35 +56 +18 +40 +7 +150 +99 +54 +152 +60 +27 +164 +78 +47 +82 +63 +46 +91 +32 +135 +3 +108 +10 +159 +127 +69 +110 +126 +133 +28 +15 +104 +138 +160 +98 +90 +144 +1 +2 +92 +41 +86 +66 +95 +12