diff options
author | Marvin Borner | 2020-12-25 17:54:42 +0100 |
---|---|---|
committer | Marvin Borner | 2020-12-25 17:54:42 +0100 |
commit | 87b3a0997e7ee1b9b3a07f6339261dd954a65584 (patch) | |
tree | 077be118bf92f6e8967c9cd1a46736daff1f8808 /2020/25/solve.c | |
parent | 358a69b13e6c7ccae5218ff7e871b5d68ea07a79 (diff) |
Merry christmas!
Diffstat (limited to '2020/25/solve.c')
-rw-r--r-- | 2020/25/solve.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/2020/25/solve.c b/2020/25/solve.c new file mode 100644 index 0000000..fd6542e --- /dev/null +++ b/2020/25/solve.c @@ -0,0 +1,46 @@ +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +#define MAGIC 20201227 + +long part_one(FILE *fp) +{ + long res = 1; + + int pub1, pub2; + fscanf(fp, "%d\n%d", &pub1, &pub2); + + int loop1 = 1; + long val = 1; + while (val != pub1 && loop1++) + val = (val * 7) % MAGIC; + + for (int i = 0; i < loop1 - 1; i++) + res = (res * pub2) % MAGIC; + return res; +} + +long part_two(FILE *fp) +{ + long res = 0; + // Merry christmas! + return res; +} + +int main(int argc, char *argv[]) +{ + FILE *fp = fopen("input", "r"); + if (!fp) + exit(EXIT_FAILURE); + + clock_t tic = clock(); + printf("%lu\n", part_one(fp)); + rewind(fp); + printf("%lu\n", part_two(fp)); + clock_t toc = clock(); + printf("TIME: %f seconds\n", (double)(toc - tic) / CLOCKS_PER_SEC); + + fclose(fp); + return 0; +} |