diff options
| author | Abigail <abigail@abigail.be> | 2021-07-24 23:11:35 +0200 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-07-24 23:11:35 +0200 |
| commit | 62818508c81af33a19e400cce9145e681920eb82 (patch) | |
| tree | f11e3508db11b31712703cf4d5d02640cadc4a3d /challenge-122/abigail/bash | |
| parent | 52d0e0851f79fead3bdad2caed25e012a124a8eb (diff) | |
| download | perlweeklychallenge-club-62818508c81af33a19e400cce9145e681920eb82.tar.gz perlweeklychallenge-club-62818508c81af33a19e400cce9145e681920eb82.tar.bz2 perlweeklychallenge-club-62818508c81af33a19e400cce9145e681920eb82.zip | |
Solutions for week 122, part 2, in 8 different languages.
Diffstat (limited to 'challenge-122/abigail/bash')
| -rw-r--r-- | challenge-122/abigail/bash/ch-2.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-122/abigail/bash/ch-2.sh b/challenge-122/abigail/bash/ch-2.sh new file mode 100644 index 0000000000..d523f918bf --- /dev/null +++ b/challenge-122/abigail/bash/ch-2.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# +# See ../README.md +# + +# +# Run as: bash ch-2.sh < input-file +# + +set -f + +declare scores +l=$'\n' +scores[2]=$l + +read n + +for ((i = 3; i < n + 3; i ++)) +do for ((j = 1; j <= 3; j ++)) + do scores[$i]=${scores[$i]}${scores[$((i - j))]//$l/$l$j } + done +done + +echo "${scores[$((n + 2))]/$l/}" |
