diff options
Diffstat (limited to 'advent-of-code/2022/06/1.c')
| -rw-r--r-- | advent-of-code/2022/06/1.c | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/advent-of-code/2022/06/1.c b/advent-of-code/2022/06/1.c deleted file mode 100644 index 30a64d9..0000000 --- a/advent-of-code/2022/06/1.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <stdio.h> -#include <stdbool.h> - -bool succ(char *buf) { - bool table[26] = {0}; - for (int i = 0; i < 4; i++) { - if(!table[buf[i] - 'a']) table[buf[i] - 'a'] = true; - else return false; - } - return true; -} - -int main() { - FILE *fp = fopen("input", "r"); - char buf[4] = {0}; - int i = 0; - int c; - while ((c = fgetc(fp)) != EOF) { - if (c < 'a' || c > 'z') continue; - buf[i % 4] = c; - if (i >= 4 && succ(buf)) break; - i++; - } - printf("%d\n", i+1); - return 0; -} |
