From 24c19b12dc9054a056fe46d6aa551578071c75b6 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Wed, 11 Dec 2019 18:16:01 -0500 Subject: Solve day 8 part 1 --- 2019/day08.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 2019/day08.c (limited to '2019/day08.c') diff --git a/2019/day08.c b/2019/day08.c new file mode 100644 index 0000000..05011c8 --- /dev/null +++ b/2019/day08.c @@ -0,0 +1,28 @@ +#include +#include +#include +int main(void) { + char layers[128][6][25]; + size_t len = fread(layers, sizeof(layers[0]), 128, stdin); + int min, min0 = INT_MAX; + for (int l = 0; l < len; ++l) { + int zero = 0; + for (int y = 0; y < 6; ++y) { + for (int x = 0; x < 25; ++x) { + if (layers[l][y][x] == '0') zero++; + } + } + if (zero < min0) { + min = l; + min0 = zero; + } + } + int one = 0, two = 0; + for (int y = 0; y < 6; ++y) { + for (int x = 0; x < 25; ++x) { + if (layers[min][y][x] == '1') one++; + if (layers[min][y][x] == '2') two++; + } + } + printf("%d\n", one * two); +} -- cgit 1.4.1 h=3.3.1&id=26dc0b11e36846f5746ea16897cceabf84495340'>refs log tree commit diff
Commit message (Expand)Author
2021-05-08Import LibreSSL 3.3.3June McEnroe
2021-04-18build: Remove added x509_verify.3 links 3.3.2June McEnroe
2021-04-18tls: Use EC_KEY_set_ex_dataJune McEnroe
2021-04-18Import LibreSSL 3.3.2June McEnroe
2021-03-05Bump version to 3.3.1p1 3.3.1p1June McEnroe
2021-03-05build: Add OpenSSL includes to libcompatJune McEnroe
2020-12-15Import LibreSSL 3.3.1June McEnroe
2020-11-24Import LibreSSL 3.3.0June McEnroe
2020-10-22Import LibreSSL 3.2.2June McEnroe
2020-09-29Import LibreSSL 3.2.1June McEnroe
2020-09-29import: Add m4/ax_add_fortify_source.m4June McEnroe
2020-08-05build: Add README.7 to EXTRA_DIST 3.2.0June McEnroe
2020-08-03doc: Indicate that only OpenSSL 1.1.1b and newer workJune McEnroe