This commit is contained in:
Evan Burkey 2022-12-21 14:19:16 -08:00
parent 77592d090e
commit cbd9541f30
2 changed files with 29 additions and 1 deletions

View File

@ -1,10 +1,38 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lfinput.h"
static void scan(char *input, size_t len) {
size_t sz = strlen(input);
for (size_t i = 0; i < sz - len; ++i) {
int char_set[256];
memset(char_set, 0, sizeof(int) * 256);
char *start = &input[i];
char *end = &input[i + len];
int fail = 0;
do {
if(char_set[*start] > 0) {
fail = 1;
break;
}
char_set[*start] = 1;
++start;
} while (start != end);
if (!fail) {
printf("%zu\n", i + len);
break;
}
}
}
void advent2022day06(void) {
char *input = get_input("input/2022/06");
printf("Solution for Day 06 of 2022 is not completed yet\n");
scan(input, 4);
scan(input, 14);
free(input);
}

View File