summary refs log tree commit diff homepage
path: root/2020
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--2020/day02.c15
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);
+}