summaryrefslogtreecommitdiff
path: root/aoc/2025/01/c.c
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2026-03-18 21:48:13 +0000
committermhsn <mail@mhsn.net>2026-03-18 21:48:13 +0000
commit86bac31392a76da84817eec020d2b84d099b3cc1 (patch)
treee2ee52db59b86b914d5b4bcceb19c9b5d899fff4 /aoc/2025/01/c.c
parent62fe361fc42dea75deaf7ac31c0ba6ba80e26a9c (diff)
downloadpuzzles-86bac31392a76da84817eec020d2b84d099b3cc1.tar.gz
puzzles-86bac31392a76da84817eec020d2b84d099b3cc1.zip
add other challenges supportHEADmaster
Diffstat (limited to 'aoc/2025/01/c.c')
-rw-r--r--aoc/2025/01/c.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/aoc/2025/01/c.c b/aoc/2025/01/c.c
new file mode 100644
index 0000000..115ea13
--- /dev/null
+++ b/aoc/2025/01/c.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+int main()
+{
+ char dir;
+ int64_t n;
+ int64_t p = 50;
+ int64_t p1 = 0, p2 = 0;
+ while (scanf("%c%ld ", &dir, &n) == 2) {
+ int64_t new = p + (dir == 'R' ? n : -n);
+ p2 += labs(new) / 100 + (p != 0 && new <= 0);
+ p = (p = new % 100) >= 0 ? p : p + 100;
+ p1 += p == 0;
+ }
+ printf("silver: %ld\ngold: %ld", p1, p2);
+ return 0;
+}