diff options
Diffstat (limited to 'day7/preamble')
-rw-r--r-- | day7/preamble | 26 |
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; +} + |