From 6596b48113ced669b206d2e1f1e8ba6edcba88a2 Mon Sep 17 00:00:00 2001 From: Orangerot Date: Sat, 17 Dec 2022 01:16:18 +0100 Subject: adv2022 first 8 days --- 2022/day03/input1.txt | 6 + 2022/day03/input2.txt | 300 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2022/day03/main | Bin 0 -> 20800 bytes 2022/day03/main.c | 36 ++++++ 2022/day03/main2.c | 45 ++++++++ 5 files changed, 387 insertions(+) create mode 100644 2022/day03/input1.txt create mode 100644 2022/day03/input2.txt create mode 100755 2022/day03/main create mode 100644 2022/day03/main.c create mode 100644 2022/day03/main2.c (limited to '2022/day03') 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 +dqSCqVWdbDSSVqbVVSqhNdrnpn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JTmSVZJTBDZ +wGsznPGGBHdzHhtHDD +WMVSWqVmrSBMpvWVMFtdClhDtqDDHhdtQt +RgWVRcmgnPPnjJBg +BmfPBHBFswLLjQQnLCnzzW +SRdvvRSGrdlRSvTgRrMVCjVWCZzMnVZhWzTj +vlSRJrRJvbGGrSSJgWvlScptFmwbmfHHBfsNFmBbfsFm diff --git a/2022/day03/main b/2022/day03/main new file mode 100755 index 0000000..6f77a3f Binary files /dev/null and b/2022/day03/main differ 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 +#include +#include + +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 +#include +#include + +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); +} + -- cgit v1.2.3