aboutsummaryrefslogtreecommitdiff
path: root/2020/25
diff options
context:
space:
mode:
authorMarvin Borner2020-12-25 17:54:42 +0100
committerMarvin Borner2020-12-25 17:54:42 +0100
commit87b3a0997e7ee1b9b3a07f6339261dd954a65584 (patch)
tree077be118bf92f6e8967c9cd1a46736daff1f8808 /2020/25
parent358a69b13e6c7ccae5218ff7e871b5d68ea07a79 (diff)
Merry christmas!
Diffstat (limited to '2020/25')
-rw-r--r--2020/25/Makefile10
-rw-r--r--2020/25/input2
-rw-r--r--2020/25/solve.c46
3 files changed, 58 insertions, 0 deletions
diff --git a/2020/25/Makefile b/2020/25/Makefile
new file mode 100644
index 0000000..fc2ff1a
--- /dev/null
+++ b/2020/25/Makefile
@@ -0,0 +1,10 @@
+.PHONY: solve.c
+
+solve.o: solve.c
+ @gcc -Ofast $+ -o $@
+
+clean:
+ @rm -f *.o
+
+run: solve.o
+ @./solve.o
diff --git a/2020/25/input b/2020/25/input
new file mode 100644
index 0000000..5ef34a0
--- /dev/null
+++ b/2020/25/input
@@ -0,0 +1,2 @@
+11349501
+5107328
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;
+}