diff options
author | June McEnroe <june@causal.agency> | 2020-12-03 01:27:16 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-12-03 01:27:16 -0500 |
commit | 057afdc268f82a4c908f224dfc7c062894d5ee7d (patch) | |
tree | 09ae64d0fe6e602fa3a66fe3326ca3db4a0d5172 | |
parent | Solve day 2 part 2 (diff) | |
download | aoc-057afdc268f82a4c908f224dfc7c062894d5ee7d.tar.gz aoc-057afdc268f82a4c908f224dfc7c062894d5ee7d.zip |
Solve day 3 part 1
Diffstat (limited to '')
-rw-r--r-- | 2020/day03.c | 16 |
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); +} |