From e7c9108b95e39d7ea5a29ae06d619c4727f11027 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 29 Oct 2021 23:02:39 +0200 Subject: Initial commit --- 2015/02/puzzle-1.awk | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 2015/02/puzzle-1.awk (limited to '2015/02/puzzle-1.awk') diff --git a/2015/02/puzzle-1.awk b/2015/02/puzzle-1.awk new file mode 100755 index 0000000..e316ba2 --- /dev/null +++ b/2015/02/puzzle-1.awk @@ -0,0 +1,20 @@ +#!/usr/bin/env -S awk -f + +function min(a, b, c) +{ + if (a <= b && a <= c) + return a + if (b <= a && b <= c) + return b + return c +} + +BEGIN { FS = "x" } +{ + x = $1 * $2 + y = $2 * $3 + z = $1 * $3 + + sum += (2 * x) + (2 * y) + (2 * z) + min(x, y, z) +} +END { print sum } -- cgit v1.2.3