From ff0bb53c15ddb51c94bcf9400c68f0858a48a6e2 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Thu, 1 Dec 2022 21:47:09 +0900 Subject: [aoc/2022] Finish day 1 --- aoc/2022/01/part-one.sh | 2 ++ aoc/2022/01/part-two.sh | 3 +++ 2 files changed, 5 insertions(+) create mode 100755 aoc/2022/01/part-one.sh create mode 100755 aoc/2022/01/part-two.sh diff --git a/aoc/2022/01/part-one.sh b/aoc/2022/01/part-one.sh new file mode 100755 index 0000000..a0e0095 --- /dev/null +++ b/aoc/2022/01/part-one.sh @@ -0,0 +1,2 @@ +#!/bin/sh +sed 's/$/+/' | { echo 0; sed 's/^+$/p0/'; echo p; } | dc | sort -n | tail -1 diff --git a/aoc/2022/01/part-two.sh b/aoc/2022/01/part-two.sh new file mode 100755 index 0000000..a5a4d77 --- /dev/null +++ b/aoc/2022/01/part-two.sh @@ -0,0 +1,3 @@ +#!/bin/sh +sed 's/$/+/' | { echo 0; sed 's/^+$/p0/'; echo p; } | dc | + sort -n | tail -n 3 | { echo 0; sed 's/$/+/'; echo p; } | dc -- cgit 1.4.1