93 lines
1.5 KiB
C
93 lines
1.5 KiB
C
#include "lib.h"
|
|
|
|
#define DBG 0
|
|
|
|
static
|
|
unsigned char input[] = {
|
|
#embed "day0_input.txt"
|
|
};
|
|
|
|
static
|
|
unsigned char test[] = {
|
|
#embed "day0_test.txt"
|
|
};
|
|
|
|
|
|
static
|
|
unsigned long do_part1(size_t file_len, unsigned char file[file_len]) {
|
|
unsigned char *s = file;
|
|
unsigned long result = 0;
|
|
|
|
#if DBG
|
|
print("\n");
|
|
#endif
|
|
|
|
do {
|
|
s++;
|
|
} while (s != &file[file_len]);
|
|
|
|
return result;
|
|
}
|
|
|
|
static
|
|
unsigned long do_part2(size_t file_len, unsigned char file[file_len]) {
|
|
unsigned char *s = file;
|
|
unsigned long result = 0;
|
|
|
|
#if DBG
|
|
print("\n");
|
|
#endif
|
|
|
|
do {
|
|
s++;
|
|
} while (s != &file[file_len]);
|
|
|
|
return result;
|
|
}
|
|
|
|
#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 (unsigned long 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 (unsigned long 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);
|
|
}
|