update
This commit is contained in:
36
app.cpp
36
app.cpp
@@ -229,8 +229,9 @@ int day3_main() {
|
||||
}
|
||||
|
||||
int day4_main() {
|
||||
Arena arena = createArena(Megabytes(16));
|
||||
list<char> file = readEntireFile(&arena, strlit("./day-4-input"));
|
||||
Arena mainArena = createArena(Megabytes(16));
|
||||
Arena *arena = &mainArena;
|
||||
list<char> file = readEntireFile(arena, strlit("./day-4-input"));
|
||||
|
||||
int fileReadIndex = 0;
|
||||
int lines = 0;
|
||||
@@ -251,23 +252,24 @@ int day4_main() {
|
||||
fileReadIndex += lineLength + 1;
|
||||
}
|
||||
|
||||
list<char> fileStripped = PushList(&arena, char, file.length - lines);
|
||||
for (size_t i = 0; i < file.length; i++) {
|
||||
if (file.data[i] != '\n') {
|
||||
appendList(&fileStripped, (char)file.data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
string xmas = strlit("XMAS");
|
||||
int c = 0;
|
||||
int count = 0;
|
||||
for (int c = 0; c < fileStripped.length; c++) {
|
||||
string segment = strSlice(fileStripped.data, c, c+xmas.len);
|
||||
const char *print = cstring(&arena, segment);
|
||||
printf("%s\n", print);
|
||||
if (strEql(segment, xmas)) {
|
||||
c += xmas.len;
|
||||
count++;
|
||||
for (int c = 0; c < file.length; c++) {
|
||||
string strings[] = {
|
||||
//forwards
|
||||
strSlice(file.data, c, c+xmas.len),
|
||||
//down
|
||||
strSlice(file.data, c, c+xmas.len),
|
||||
//forwardsReverse
|
||||
strReverse(arena, strSlice(file.data, c, c+xmas.len)),
|
||||
//downReverse
|
||||
strReverse(arena, strSlice(file.data, c, c+xmas.len)),
|
||||
};
|
||||
for (size_t i = 0; i < ArrayCount(strings); i++) {
|
||||
if (strEql(strings[i], xmas)) {
|
||||
c += xmas.len;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user