2022-06
This commit is contained in:
parent
77592d090e
commit
cbd9541f30
@ -1,10 +1,38 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "lfinput.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) {
|
void advent2022day06(void) {
|
||||||
char *input = get_input("input/2022/06");
|
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);
|
free(input);
|
||||||
}
|
}
|
||||||
|
0
src/2022/scripts/massage05.py
Normal file
0
src/2022/scripts/massage05.py
Normal file
Loading…
x
Reference in New Issue
Block a user