aboutsummaryrefslogtreecommitdiff
path: root/challenge-146/abigail/bash
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.freedom.nl>2022-01-03 12:25:51 +0100
committerAbigail <abigail@abigail.freedom.nl>2022-01-03 16:14:38 +0100
commit4699f600935129b16a48074d8534411ce935db17 (patch)
tree1ff6170ab68961c4d133c8a975b8323e7f2b5ed4 /challenge-146/abigail/bash
parent41f8dae6667e8b4215b9f2507d7a2e14236890b9 (diff)
downloadperlweeklychallenge-club-4699f600935129b16a48074d8534411ce935db17.tar.gz
perlweeklychallenge-club-4699f600935129b16a48074d8534411ce935db17.tar.bz2
perlweeklychallenge-club-4699f600935129b16a48074d8534411ce935db17.zip
Week 146
Part 1 is a fixed output challenge, so, just a glorified Hello World program. It's stolen from project Euler, task 7.
Diffstat (limited to 'challenge-146/abigail/bash')
-rw-r--r--challenge-146/abigail/bash/ch-1.sh11
-rw-r--r--challenge-146/abigail/bash/ch-2.sh27
2 files changed, 38 insertions, 0 deletions
diff --git a/challenge-146/abigail/bash/ch-1.sh b/challenge-146/abigail/bash/ch-1.sh
new file mode 100644
index 0000000000..64ba3a2d29
--- /dev/null
+++ b/challenge-146/abigail/bash/ch-1.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+#
+# See ../README.md
+#
+
+#
+# Run as: bash ch-1.sh
+#
+
+echo "104743" \ No newline at end of file
diff --git a/challenge-146/abigail/bash/ch-2.sh b/challenge-146/abigail/bash/ch-2.sh
new file mode 100644
index 0000000000..5a5ee147f5
--- /dev/null
+++ b/challenge-146/abigail/bash/ch-2.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+#
+# See ../README.md
+#
+
+#
+# Run as: bash ch-2.sh < input-file
+#
+
+set -f
+
+IFS=/
+
+while read a b
+do for ((i = 1; i <= 2; i ++))
+ do if ((a < b))
+ then ((b -= a))
+ else ((a -= b))
+ fi
+ if ((a == 0 || b == 0))
+ then break
+ fi
+ printf "$a/$b "
+ done
+ echo
+done