summary refs log tree commit diff homepage
path: root/2018/day03.c
blob: b4544c1da0f8fcb8290f94bb53d6933a63f089fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdio.h>
#include <stdlib.h>

typedef unsigned char byte;
typedef unsigned uint;

enum { Len = 1000 };
static byte fabric[Len][Len];

int main() {
	while (!feof(stdin)) {
		uint d, x, y, w, h;
		scanf("#%u @ %u,%u: %ux%u\n", &d, &x, &y, &w, &h);
		for (uint i = 0; i < w; ++i) {
			for (uint j = 0; j < h; ++j) {
				fabric[x + i][y + j]++;
			}
		}
	}
	uint count = 0;
	for (uint x = 0; x < Len; ++x) {
		for (uint y = 0; y < Len; ++y) {
			if (fabric[x][y] > 1) count++;
		}
	}
	printf("%u\n", count);
}