diff options
| author | E7-87-83 <fungcheokyin@gmail.com> | 2022-01-13 16:52:50 +0800 |
|---|---|---|
| committer | E7-87-83 <fungcheokyin@gmail.com> | 2022-01-13 16:52:50 +0800 |
| commit | b82ed7c55b6a912b237e7fa396e433ac33ca79c8 (patch) | |
| tree | af2ad93bf0190b04d9c3775c87ab3dd61abd99dd /challenge-003/abigail/bash/ch-2.sh | |
| parent | 415b77f3f489715d7888de8794affe9afe8d1ffb (diff) | |
| parent | f0bd80b2369212d923d8c6a537ba5379067afbf9 (diff) | |
| download | perlweeklychallenge-club-b82ed7c55b6a912b237e7fa396e433ac33ca79c8.tar.gz perlweeklychallenge-club-b82ed7c55b6a912b237e7fa396e433ac33ca79c8.tar.bz2 perlweeklychallenge-club-b82ed7c55b6a912b237e7fa396e433ac33ca79c8.zip | |
-
Diffstat (limited to 'challenge-003/abigail/bash/ch-2.sh')
| -rw-r--r-- | challenge-003/abigail/bash/ch-2.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/challenge-003/abigail/bash/ch-2.sh b/challenge-003/abigail/bash/ch-2.sh new file mode 100644 index 0000000000..ca5e5fb510 --- /dev/null +++ b/challenge-003/abigail/bash/ch-2.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# +# See https://theweeklychallenge.org/blog/perl-weekly-challenge-003 +# + +# +# Run as: bash ch-2.sh < input-file +# + +set -f + +declare -A p + +while read n +do for ((row = 0; row <= n; row ++)) + do p["$row;0"]=1 + printf "1 " + for ((col = 1; col <= row; col ++)) + do p["$row;$col"]=$((${p["$((row-1));$((col-1))"]:-0} + \ + ${p["$((row-1));$col"]:-0})) + printf "%d " ${p["$row;$col"]} + done + echo + done +done |
