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/16/puzzle-2.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 2015/16/puzzle-2.sh (limited to '2015/16/puzzle-2.sh') diff --git a/2015/16/puzzle-2.sh b/2015/16/puzzle-2.sh new file mode 100755 index 0000000..e854c7c --- /dev/null +++ b/2015/16/puzzle-2.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env sh + +# Definitely there is a better way to do this, but this is fine +# Original solution was just me using regex in vim lol + +sed '/children/!s/$/, children: 3/' input \ + | sed '/cats/!s/$/, cats: 8/' \ + | sed '/samoyeds/!s/$/, samoyeds: 2/' \ + | sed '/pomeranians/!s/$/, pomeranians: 2/' \ + | sed '/akitas/!s/$/, akitas: 0/' \ + | sed '/vizslas/!s/$/, vizslas: 0/' \ + | sed '/goldfish/!s/$/, goldfish: 4/' \ + | sed '/trees/!s/$/, trees: 4/' \ + | sed '/cars/!s/$/, cars: 2/' \ + | sed '/perfumes/!s/$/, perfumes: 1/' \ + | sed 's/$/ /' \ + | grep 'children: 3' \ + | grep 'samoyeds: 2' \ + | grep 'akitas: 0' \ + | grep 'vizslas: 0' \ + | grep 'cars: 2' \ + | grep 'perfumes: 1' \ + | grep 'goldfish: [0-4][ ,]' \ + | grep 'pomeranians: [0-2][ ,]' \ + | grep 'cats: \([8-9]\|[1-9][0-9]\)' \ + | sed -n '/trees: \([4-9]\|[1-9][0-9]\)/s/Sue \([0-9]*\).*/\1/p' -- cgit v1.2.3