diff options
| author | Mistivia <i@mistivia.com> | 2024-02-14 14:55:21 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2024-02-14 14:55:21 +0800 |
| commit | dc6b5fe160647afcaff88242792113b5802176fe (patch) | |
| tree | fbaf92803820f820716ea584bd951267c9080a2e /advent-of-code/2023/01/part1.c | |
| parent | 60b0586ddc42cd8060e796e61267fc63a4397712 (diff) | |
refactor advent of code 2023 day 01 from c to racket
Diffstat (limited to 'advent-of-code/2023/01/part1.c')
| -rw-r--r-- | advent-of-code/2023/01/part1.c | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/advent-of-code/2023/01/part1.c b/advent-of-code/2023/01/part1.c deleted file mode 100644 index 3aace2a..0000000 --- a/advent-of-code/2023/01/part1.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <stdio.h> -#include <ctype.h> -#include <string.h> - -#include "str.h" - - -int main() { - FILE* fp = fopen("./input", "r"); - int sum = 0; - while (1) { - char *line = str_strip(fgetline(fp)); - if (line == NULL || strlen(line) == 0) { - break; - } - int d1 = -1, d2 = -1; - while (*line != '\0') { - if (isdigit(*line)) { - if (d1 == -1) d1 = *line - '0'; - d2 = *line - '0'; - } - line++; - } - if (d2 == -1) d2 = d1; - sum += d1 * 10 + d2; - } - printf("%d\n", sum); - return 0; -} - |
