92 lines
1.6 KiB
C
92 lines
1.6 KiB
C
#include "lib.h"
|
|
|
|
#define DBG 0
|
|
|
|
static
|
|
ch input[] = {
|
|
#embed "day0_input.txt"
|
|
};
|
|
|
|
static
|
|
ch test[] = {
|
|
#embed "day0_test.txt"
|
|
};
|
|
|
|
alignas(0x40) static
|
|
struct {
|
|
line padstart[4];
|
|
struct { ch *s; num _extra[7]; };
|
|
union { line l; struct { ch s[16]; num n; }; } result;
|
|
line padend;
|
|
} m;
|
|
static_assert(offsetof(typeof(m),result) % 64 == 0);
|
|
static_assert(offsetof(typeof(m),padend) % 64 == 0);
|
|
|
|
static
|
|
num do_part1(size_t file_len, ch file[file_len]) {
|
|
m = (typeof(m)){ };
|
|
m.s = file;
|
|
m.result.n = 0;
|
|
|
|
#if DBG
|
|
print("\n");
|
|
#endif
|
|
|
|
do {
|
|
m.s++;
|
|
} while (m.s != &file[file_len]);
|
|
|
|
return m.result.n;
|
|
}
|
|
|
|
static
|
|
num do_part2(size_t file_len, ch file[file_len]) {
|
|
return 0;
|
|
}
|
|
|
|
#define RUN_TEST1 1
|
|
#define RUN_PART1 0
|
|
#define RUN_TEST2 0
|
|
#define RUN_PART2 0
|
|
|
|
#define TEST1_EXPECT -1
|
|
#define TEST2_EXPECT -1
|
|
|
|
void run() {
|
|
#if RUN_TEST1
|
|
print("PART 1 TEST: ");
|
|
if (num v = do_part1(countof(test), test); v != TEST1_EXPECT) {
|
|
print("FAILED (got ");
|
|
printd(v);
|
|
print(", expected " xstr(TEST1_EXPECT) ")\n");
|
|
} else {
|
|
print("PASSED\n");
|
|
}
|
|
#endif
|
|
|
|
#if RUN_PART1
|
|
print("PART 1 RESULT: ");
|
|
printd(do_part1(countof(input), input));
|
|
print("\n");
|
|
#endif
|
|
|
|
#if RUN_TEST2
|
|
print("PART 2 TEST: ");
|
|
if (num v = do_part2(countof(test), test); v != TEST2_EXPECT) {
|
|
print("FAILED (got ");
|
|
printd(v);
|
|
print(", expected " xstr(TEST2_EXPECT) ")\n");
|
|
} else {
|
|
print("PASSED\n");
|
|
}
|
|
#endif
|
|
|
|
#if RUN_PART2
|
|
print("PART 2 RESULT: ");
|
|
printd(do_part2(countof(input), input));
|
|
print("\n");
|
|
#endif
|
|
|
|
exit_group(0);
|
|
}
|