From d39cf569a4486f7c86e9866a1c845a3d58209a51 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Wed, 2 Dec 2020 00:07:09 -0500 Subject: Solve day 2 part 1 --- 2020/day02.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 2020/day02.c 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 +#include +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); +} -- cgit 1.4.1