summary refs log tree commit diff homepage
path: root/2020/day03.c
blob: cd792a7999b504dc73df1bc09c98e2e9f633a8ba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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);
}