Looks like I forget to commit Day 10!
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Sat, 12 Dec 2020 13:37:47 +0000 (13:37 +0000)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Sat, 12 Dec 2020 13:37:47 +0000 (13:37 +0000)
day10/22_10_19208.txt [new file with mode: 0644]
day10/7_5_8.txt [new file with mode: 0644]
day10/get_adaptor_chain.py [new file with mode: 0644]
day10/get_adaptor_choices.py [new file with mode: 0644]
day10/input.txt [new file with mode: 0644]

diff --git a/day10/22_10_19208.txt b/day10/22_10_19208.txt
new file mode 100644 (file)
index 0000000..e6376dc
--- /dev/null
@@ -0,0 +1,31 @@
+28
+33
+18
+42
+31
+14
+46
+20
+48
+47
+24
+23
+49
+45
+19
+38
+39
+11
+1
+32
+25
+35
+8
+17
+7
+9
+4
+2
+34
+10
+3
diff --git a/day10/7_5_8.txt b/day10/7_5_8.txt
new file mode 100644 (file)
index 0000000..ec4a03f
--- /dev/null
@@ -0,0 +1,11 @@
+16
+10
+15
+5
+1
+11
+7
+19
+6
+12
+4
diff --git a/day10/get_adaptor_chain.py b/day10/get_adaptor_chain.py
new file mode 100644 (file)
index 0000000..19c81f0
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/python3
+
+import sys
+
+filename=(len(sys.argv) > 1) and sys.argv[1] or "22_10.txt"
+
+cur_jolts=0
+adaptors=[int(line.rstrip()) for line in open(filename, "r")]
+adaptors.sort()
+end_jolts=adaptors[-1]+3
+
+diff_counts={}
+
+for adaptor in adaptors:
+    if adaptor-cur_jolts == 3:
+        if 3 not in diff_counts:
+            diff_counts[3]=0
+        diff_counts[3]+=1
+    elif adaptor-cur_jolts == 1:
+        if 1 not in diff_counts:
+            diff_counts[1]=0
+        diff_counts[1]+=1
+    else:
+        raise Exception("Diff is not 1 or 3!")
+    cur_jolts=adaptor
+
+diff_counts[3]+=1
+print(diff_counts)
+print(diff_counts[1] * diff_counts[3])
diff --git a/day10/get_adaptor_choices.py b/day10/get_adaptor_choices.py
new file mode 100644 (file)
index 0000000..60c4556
--- /dev/null
@@ -0,0 +1,34 @@
+#!/usr/bin/python3
+
+import sys
+
+filename=(len(sys.argv) > 1) and sys.argv[1] or "22_10.txt"
+
+adaptors=[int(line.rstrip()) for line in open(filename, "r")]
+adaptors.sort()
+end_jolts=adaptors[-1]+3
+
+adaptors.insert(0, 0)
+adaptors.append(end_jolts)
+
+cur_configs=1
+
+def get_choices():
+    choice_count=1
+    can_reach={}
+    paths={0:1}
+    for adaptor in adaptors:
+        can_reach[adaptor]=[a for a in adaptors if (a >= adaptor+1 and a <= adaptor+3)]
+
+    for adaptor in adaptors:
+        for adaptor2 in can_reach[adaptor]:
+            if adaptor2 not in paths:
+                paths[adaptor2]=0
+            paths[adaptor2]+=paths[adaptor]
+
+    return paths[adaptors[-1]]
+
+total = get_choices()
+
+print("Maybe possibly all the configs")
+print(total)
diff --git a/day10/input.txt b/day10/input.txt
new file mode 100644 (file)
index 0000000..42631e9
--- /dev/null
@@ -0,0 +1,102 @@
+107
+13
+116
+132
+24
+44
+56
+69
+28
+135
+152
+109
+42
+112
+10
+43
+122
+87
+49
+155
+175
+71
+39
+173
+50
+156
+120
+145
+176
+45
+149
+148
+15
+1
+68
+9
+168
+131
+150
+59
+83
+167
+3
+169
+6
+123
+174
+81
+138
+72
+157
+144
+65
+75
+33
+19
+140
+160
+16
+57
+93
+90
+8
+58
+98
+130
+141
+114
+84
+29
+22
+94
+113
+129
+108
+36
+14
+115
+102
+151
+78
+139
+170
+82
+2
+70
+126
+101
+25
+62
+95
+104
+23
+163
+32
+103
+121
+119
+48
+166
+7
+53