aboutsummaryrefslogtreecommitdiff
path: root/day7/preamble
diff options
context:
space:
mode:
authorNæþ'n Lasseter <Næþ'n Lasseter nathan@bytemark.co.uk>2015-12-17 20:10:55 +0000
committerNæþ'n Lasseter <Næþ'n Lasseter nathan@bytemark.co.uk>2015-12-17 20:10:55 +0000
commit60ba2ffc498e7403a29c02aa23f078bb9da70c39 (patch)
tree4aa401ea8bd9774a09ae107c8e0f7b3a3588fbfe /day7/preamble
parent7a0053a986d5e691a0432291b8e077c212bbfc24 (diff)
Day 7, doesnt return
Diffstat (limited to 'day7/preamble')
-rw-r--r--day7/preamble26
1 files changed, 26 insertions, 0 deletions
diff --git a/day7/preamble b/day7/preamble
new file mode 100644
index 0000000..c3e2cce
--- /dev/null
+++ b/day7/preamble
@@ -0,0 +1,26 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+
+uint16_t* cache;
+char* incache;
+
+int wtoi(char* wire) {
+ int idx = 0, i;
+ for(i = 0; wire[i] != '\0'; i++) {
+ idx *= 26;
+ idx += wire[i];
+ }
+ return idx;
+}
+char iscached(char* wire) {
+ return incache[wtoi(wire)];
+}
+uint16_t getcache(char* wire) {
+ return cache[wtoi(wire)];
+}
+void putcache(char* wire, uint16_t value) {
+ cache[wtoi(wire)] = value;
+}
+