From 60ba2ffc498e7403a29c02aa23f078bb9da70c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A6=C3=BE=27n=20Lasseter?= Date: Thu, 17 Dec 2015 20:10:55 +0000 Subject: Day 7, doesnt return --- day7/preamble | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 day7/preamble (limited to 'day7/preamble') 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 +#include +#include +#include + +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; +} + -- cgit v1.2.1