aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-10-12 20:05:55 +0200
committerAbigail <abigail@abigail.be>2021-10-13 01:54:38 +0200
commit55ef5170b12d97c33852518d6aae1531ec7e221e (patch)
tree805b84f027b0b453f4e6c6fb3f9639158ec077c2
parent2ba1944044994f98155f20da0f14aa8b2d9a5dd9 (diff)
downloadperlweeklychallenge-club-55ef5170b12d97c33852518d6aae1531ec7e221e.tar.gz
perlweeklychallenge-club-55ef5170b12d97c33852518d6aae1531ec7e221e.tar.bz2
perlweeklychallenge-club-55ef5170b12d97c33852518d6aae1531ec7e221e.zip
bc solutions for week 134
-rw-r--r--challenge-134/abigail/README.md2
-rw-r--r--challenge-134/abigail/bc/ch-1.bc12
-rw-r--r--challenge-134/abigail/bc/ch-2.bc25
-rw-r--r--challenge-134/abigail/t/ctest.ini3
4 files changed, 42 insertions, 0 deletions
diff --git a/challenge-134/abigail/README.md b/challenge-134/abigail/README.md
index 5642dc3187..836c8ef566 100644
--- a/challenge-134/abigail/README.md
+++ b/challenge-134/abigail/README.md
@@ -4,6 +4,7 @@
* [AWK](awk/ch-1.awk)
* [Bash](bash/ch-1.sh)
+* [bc](bc/ch-1.bc)
* [Befunge-93](befunge-93/ch-1.bf93)
* [C](c/ch-1.c)
* [Go](go/ch-1.go)
@@ -19,6 +20,7 @@
* [AWK](awk/ch-2.awk)
* [Bash](bash/ch-2.sh)
+* [bc](bc/ch-2.bc)
* [C](c/ch-2.c)
* [Go](go/ch-2.go)
* [Java](java/ch-2.java)
diff --git a/challenge-134/abigail/bc/ch-1.bc b/challenge-134/abigail/bc/ch-1.bc
new file mode 100644
index 0000000000..435c743e1c
--- /dev/null
+++ b/challenge-134/abigail/bc/ch-1.bc
@@ -0,0 +1,12 @@
+#
+# See ../README.md
+#
+
+#
+# Run as: bc ch-1.bc
+#
+t[1] = 789; t[2] = 798; t[3] = 879; t[4] = 897; t[5] = 978
+for (i = 1; i <= 5; i ++) {
+ 1023456000 + t[i]
+}
+quit
diff --git a/challenge-134/abigail/bc/ch-2.bc b/challenge-134/abigail/bc/ch-2.bc
new file mode 100644
index 0000000000..a9ce05c2c4
--- /dev/null
+++ b/challenge-134/abigail/bc/ch-2.bc
@@ -0,0 +1,25 @@
+#
+# See ../README.md
+#
+
+#
+# Run as: bc ch-2.bc < input-file
+#
+
+while (1) {
+ m = read(); if (m == 0) break
+ n = read(); if (n == 0) break
+ for (i = 1; i <= m * n; i ++) {
+ s[i] = 0
+ }
+ count = 0
+ for (i = 1; i <= n; i ++) {
+ for (j = 1; j <= m; j ++) {
+ if (s[i * j] == 0) {
+ count = count + 1
+ s[i * j] = 1
+ }
+ }
+ }
+ count
+}
diff --git a/challenge-134/abigail/t/ctest.ini b/challenge-134/abigail/t/ctest.ini
index 3c7da6ddae..448cbd1a24 100644
--- a/challenge-134/abigail/t/ctest.ini
+++ b/challenge-134/abigail/t/ctest.ini
@@ -9,3 +9,6 @@
[1-1]
no_input = 1
+
+[2-1/bc]
+add_to_input = 0