From 4c7b413ed9082d51b2af7f1c3cb2251ee2b1a338 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 7 Dec 2025 08:27:36 +0100 Subject: Add 2025 day 6 solutions --- 2025/06/puzzle-2.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 2025/06/puzzle-2.sh (limited to '2025/06/puzzle-2.sh') diff --git a/2025/06/puzzle-2.sh b/2025/06/puzzle-2.sh new file mode 100755 index 0000000..cba270f --- /dev/null +++ b/2025/06/puzzle-2.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +{ + printf '(' + for i in $(seq "$(head -n1 input | wc -c)") + do + num="$(cut -c $i input | paste -sd '')" + num="${num%${num##*[![:space:]]}}" + + case "$num" in + *[+*]) + test -n "$op" && printf ') + (' + op="${num#${num%?}}" + num="${num%?}" + printf '%d %s ' $num "$op" + ;; + '') + test "$op" = + + printf '%d' $? + ;; + *) + printf '%d %s ' $num "$op" + ;; + esac + done + printf ')\n' +} | bc -- cgit v1.2.3