diff options
Diffstat (limited to '2022/day03')
-rw-r--r-- | 2022/day03/input1.txt | 6 | ||||
-rw-r--r-- | 2022/day03/input2.txt | 300 | ||||
-rwxr-xr-x | 2022/day03/main | bin | 0 -> 20800 bytes | |||
-rw-r--r-- | 2022/day03/main.c | 36 | ||||
-rw-r--r-- | 2022/day03/main2.c | 45 |
5 files changed, 387 insertions, 0 deletions
diff --git a/2022/day03/input1.txt b/2022/day03/input1.txt new file mode 100644 index 0000000..f17e726 --- /dev/null +++ b/2022/day03/input1.txt @@ -0,0 +1,6 @@ +vJrwpWtwJgWrhcsFMMfFFhFp +jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL +PmmdzqPrVvPwwTWBwg +wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn +ttgJtRGJQctTZtZT +CrZsJsPPZsGzwwsLwLmpwMDw diff --git a/2022/day03/input2.txt b/2022/day03/input2.txt new file mode 100644 index 0000000..09ed9e4 --- /dev/null +++ b/2022/day03/input2.txt @@ -0,0 +1,300 @@ +gvNbShZZgQfWdQhdPQmggLTFLwmwjFqjVVgM +CsJnHllcsnnnnJrGRnRwPPLVmFLHLBjFFVHmPT +JlnCtctJnJDcJlDCRpPrSSQWfphzWZfbZSvfNfbS +WjvRSdSQjvpjWzNlnZlNZqCCMzZZ +nJtJsbctPBPwLNcDZNNGLClC +tsFJHBgJwgJbnvSHHWVWHhVhpQ +zRzPhCCSHVZzfGHZ +qBsWBpqBwBcvqqWgdfZrprdggPHHVZ +WWmvwvBbnWmnwvWcbmWWnqNCRSDRRSSjjSDbPJbRjClLhC +rQrznfHHhrHzllzlzTGcJgtJ +jhhjjSZVPWVZvSFtTttLTglgFtvm +dqSCqVWdbDSSVqbVVSqhNdrnpnCnfsnnwfnsRpMpBMrf +rTnvrSSHvHtnDQVDtfmW +ZjCglhcCJschpZbZgbtGmRtbGmwtQtbmtN +FFZCghFJhlslFpjcdFTPLHHmrqTMTdzBLHLH +WzDfrDwwDCCDMnfDHHJjTHTtNd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ZhWzTj +vlSRJrRJvbGGrSSJgWvlScptFmwbmfHHBfsNFmBbfsFm diff --git a/2022/day03/main b/2022/day03/main Binary files differnew file mode 100755 index 0000000..6f77a3f --- /dev/null +++ b/2022/day03/main diff --git a/2022/day03/main.c b/2022/day03/main.c new file mode 100644 index 0000000..69068fa --- /dev/null +++ b/2022/day03/main.c @@ -0,0 +1,36 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +char getWrong(char *line) +{ + char *middle = line + strlen(line)/2; + char *a = line; + char *b = middle; + for (char *a = line; a < middle; a++) + { + for (char *b = middle; *b != '\n'; b++) + { + if ( *a == *b ) return *b; + } + } +} + +int main() +{ + char *line = NULL; + size_t len; + int prios = 0; + + while (getline(&line, &len, stdin) >= 0) + { + char wrong = getWrong(line); + printf("%c", wrong); + int prio; + if ( wrong >= 97 && wrong <= 122 ) prio = wrong - 96; + else prio = wrong - 64 + 26; + printf("%d", prio); + prios += prio; + } + printf("\n%d\n", prios); +} diff --git a/2022/day03/main2.c b/2022/day03/main2.c new file mode 100644 index 0000000..17daa38 --- /dev/null +++ b/2022/day03/main2.c @@ -0,0 +1,45 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +char getWrong(char *line, char *line2, char *line3) +{ + + for (char *a = line; *a != '\n'; a++) + { + for (char *b = line2; *b != '\n'; b++) + { + for (char *c = line3; *c != '\n'; c++) + { + if ( *a == *b && *a == *c ) return *b; + } + } + } +} + +int main() +{ + char *line = NULL; + char *line2 = NULL; + char *line3 = NULL; + size_t len; + size_t len2; + size_t len3; + int prios = 0; + + while (getline(&line, &len, stdin) >= 0) + { + getline(&line2, &len2, stdin); + getline(&line3, &len3, stdin); + + char wrong = getWrong(line, line2, line3); + printf("%c", wrong); + int prio; + if ( wrong >= 97 && wrong <= 122 ) prio = wrong - 96; + else prio = wrong - 64 + 26; + printf("%d", prio); + prios += prio; + } + printf("\n%d\n", prios); +} + |