From a09348694b0525513d812647a69dac3a36782f88 Mon Sep 17 00:00:00 2001 From: Adam Spragg Date: Sat, 14 Jan 2023 17:38:10 +0000 Subject: Puzzle 1: Consolidate 1a/1b programs into `1` with `-p` option Like the later puzzles --- 1a.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 1a.c (limited to '1a.c') diff --git a/1a.c b/1a.c deleted file mode 100644 index fa93b39..0000000 --- a/1a.c +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include - -int -main() -{ - char buf[BUFSIZ]; - long cal = 0, maxcal = 0, elf = 0, maxelf = 0; - - while (fgets(buf, sizeof(buf), stdin)) { - char * pbuf = buf; - long n; - if ((n = strtol(buf, &pbuf, 10)) == 0 && pbuf == buf) { - if (cal > maxcal) { - maxcal = cal; - maxelf = elf; - } - cal = 0; - ++elf; - } - else { - cal += n; - } - } - if (cal > maxcal) { - maxcal = cal; - maxelf = elf; - } - - printf("maxcal: %ld (elf: %ld)\n", maxcal, maxelf); - - return 0; -} - -- cgit v1.2.1