From c37ba018558ad65a3c20d21bc28683f9ee127145 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Mon, 3 Dec 2018 00:25:08 -0500 Subject: Solve day 3 part 1 --- 2018/day03.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 2018/day03.c (limited to '2018') diff --git a/2018/day03.c b/2018/day03.c new file mode 100644 index 0000000..b4544c1 --- /dev/null +++ b/2018/day03.c @@ -0,0 +1,27 @@ +#include +#include + +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); +} -- cgit 1.4.1