aboutsummaryrefslogtreecommitdiff
path: root/challenge-122/abigail/bash
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-122/abigail/bash')
-rw-r--r--challenge-122/abigail/bash/ch-1.sh11
-rw-r--r--challenge-122/abigail/bash/ch-2.sh25
2 files changed, 36 insertions, 0 deletions
diff --git a/challenge-122/abigail/bash/ch-1.sh b/challenge-122/abigail/bash/ch-1.sh
new file mode 100644
index 0000000000..29d3a79f9d
--- /dev/null
+++ b/challenge-122/abigail/bash/ch-1.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+#
+# See ../README.md
+#
+
+#
+# Run as: bash ch-1.sh < input-file
+#
+
+while read n; do echo $(((s += n) / ++ c)); done
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/}"