summary refs log tree commit diff homepage
path: root/2020
diff options
context:
space:
mode:
Diffstat (limited to '2020')
-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);
+}
e 2021-01-12Add htagml exampleJune McEnroe 2021-01-12Use mandoc and htagml for bin htmlJune McEnroe 2021-01-12Add htagmlJune McEnroe 2021-01-12Replace causal.agency with a simple mdoc pageJune McEnroe 2021-01-11Publish "Using vi"June McEnroe 2021-01-11Enable diff.colorMovedJune McEnroe 2021-01-10Set less search case-insensitiveJune McEnroe 2021-01-10Set EXINITJune McEnroe 2021-01-09Add c -t flag to print expression typeJune McEnroe 2021-01-05Update taglineJune McEnroe