diff options
author | Adam Spragg <adam@spra.gg> | 2023-01-14 17:38:10 +0000 |
---|---|---|
committer | Adam Spragg <adam@spra.gg> | 2023-01-14 17:57:06 +0000 |
commit | a09348694b0525513d812647a69dac3a36782f88 (patch) | |
tree | 0716b4a34630e09451ca2618075424911db61c7f /1a.c | |
parent | e9cba2b3fcdc5f5c356fdb2d43cffb5b2cde9d3c (diff) |
Puzzle 1: Consolidate 1a/1b programs into `1` with `-p` option
Like the later puzzles
Diffstat (limited to '1a.c')
-rw-r--r-- | 1a.c | 34 |
1 files changed, 0 insertions, 34 deletions
@@ -1,34 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -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; -} - |