diff options
| -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 |
