2023: Day 1, tweak to just use chimerautils

This commit is contained in:
Wesley Moore 2023-12-02 09:20:09 +10:00
parent 140ec1f33c
commit f213f6d254
No known key found for this signature in database
4 changed files with 13 additions and 10 deletions

7
2023/day1/day1.2.sh Normal file
View file

@ -0,0 +1,7 @@
#!/bin/sh
awk -f day1.2.awk $1 | tr -d a-z | grep -o '^.' > first
rev $1 | awk -f day1.2.rev.awk | rev | tr -d a-z | grep -o '.$' > last
paste -d '\0' first last | \
awk 'BEGIN { sum = 0 } { sum += $0 } END { print sum }'

View file

@ -1,6 +0,0 @@
#!/bin/zsh
paste -d '\0' \
<(awk -f day1.2.awk $1 | tr -d a-z | rg -o '^.') \
<(rev $1 | awk -f day1.2.rev.awk | rev | tr -d a-z | rg -o '.$') | \
awk 'BEGIN { sum = 0 } { sum += $0 } END { print sum }'

6
2023/day1/day1.sh Normal file
View file

@ -0,0 +1,6 @@
#!/bin/sh
tr -d a-z < $1 | grep -o '^.' > first
tr -d a-z < $1 | grep -o '.$' > last
paste -d '\0' first last | \
awk 'BEGIN { sum = 0 } { sum += $0 } END { print sum }'

View file

@ -1,4 +0,0 @@
#!/bin/zsh
paste -d '\0' <(tr -d a-z < $1 | rg -o ^.) <(tr -d a-z < $1 | rg -o .$) | \
awk 'BEGIN { sum = 0 } { sum += $0 } END { print sum }'