aboutsummaryrefslogtreecommitdiff
path: root/day7/preamble
blob: c3e2cce0aa71ec4737832f6250e3ec68dea4c67b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
}