summary refs log tree commit diff homepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--2020/day03.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/2020/day03.c b/2020/day03.c
new file mode 100644
index 0000000..cd792a7
--- /dev/null
+++ b/2020/day03.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main(void) {
+	char grid[512][32];
+	int h = 0;
+	while (EOF != scanf("%s\n", grid[h])) {
+		h++;
+	}
+	int w = strlen(grid[0]);
+	int trees = 0;
+	for (int x = 0, y = 0; y < h; x += 3, y += 1) {
+		trees += grid[y][x%w] == '#';
+	}
+	printf("%d\n", trees);
+}
3:15 -0500'>2020-02-12Simplify macOS notify-sendJune McEnroe 2020-02-12Add imbox and notemap to pageJune McEnroe 2020-02-12Collapse simple linksJune McEnroe 2020-02-12Move catgirl up the pageJune McEnroe 2020-02-12Update catgirl pty grabJune McEnroe 2020-02-12Link to cgit /about pages where appropriateJune McEnroe 2020-02-11Separate LINKS from BINS for html to workJune McEnroe 2020-02-11Add margin to Bl-bullet itemsJune McEnroe 2020-02-10Match URLs inside parens or with paired parens insideJune McEnroe 2020-02-10Duplicate effective URL before passing it back to curlJune McEnroe 2020-02-09Add To Be Taught, If FortunateJune McEnroe 2020-02-04Add The Future of Another TimelineJune McEnroe 2020-01-31Reorganize the Makefile for the umpteenth timeJune McEnroe 2020-01-28Change scout sensitivity to 1.4June McEnroe 2020-01-28Import shows.txtJune McEnroe