From 04197d46e899873af5478b4d5ccaf1579fe0b6f8 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 5 Dec 2022 17:34:48 +0100 Subject: Add 2016 day 3 solutions --- 2016/03/puzzle-2.awk | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 2016/03/puzzle-2.awk (limited to '2016/03/puzzle-2.awk') diff --git a/2016/03/puzzle-2.awk b/2016/03/puzzle-2.awk new file mode 100755 index 0000000..6e2c2f7 --- /dev/null +++ b/2016/03/puzzle-2.awk @@ -0,0 +1,14 @@ +#!/usr/bin/awk -f + +NR % 3 == 1 { split($0, x) } +NR % 3 == 2 { split($0, y) } +NR % 3 == 0 { split($0, z) } + +(NR % 3 == 0) && (x[1] + y[1] > z[1]) && + (y[1] + z[1] > x[1]) && (z[1] + x[1] > y[1]) { c++ } +(NR % 3 == 0) && (x[2] + y[2] > z[2]) && + (y[2] + z[2] > x[2]) && (z[2] + x[2] > y[2]) { c++ } +(NR % 3 == 0) && (x[3] + y[3] > z[3]) && + (y[3] + z[3] > x[3]) && (z[3] + x[3] > y[3]) { c++ } + +END { print c } -- cgit v1.2.3