diff options
author | June McEnroe <june@causal.agency> | 2020-12-02 00:07:09 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-12-02 00:07:09 -0500 |
commit | d39cf569a4486f7c86e9866a1c845a3d58209a51 (patch) | |
tree | 265c32a62ec7e3538adf2b6d7f96ab642ddeb2b6 | |
parent | Solve day 1 part 2 (diff) | |
download | aoc-d39cf569a4486f7c86e9866a1c845a3d58209a51.tar.gz aoc-d39cf569a4486f7c86e9866a1c845a3d58209a51.zip |
Solve day 2 part 1
-rw-r--r-- | 2020/day02.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/2020/day02.c b/2020/day02.c new file mode 100644 index 0000000..597efde --- /dev/null +++ b/2020/day02.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <stdlib.h> +int main(void) { + int valid = 0; + int l, u; + char c, p[256]; + while (EOF != scanf("%d-%d %c: %s\n", &l, &u, &c, p)) { + int n = 0; + for (int i = 0; p[i]; ++i) { + if (p[i] == c) n++; + } + if (n >= l && n <= u) valid++; + } + printf("%d\n", valid); +} |