aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-10-12 11:23:54 +0200
committerAbigail <abigail@abigail.be>2021-10-12 11:23:54 +0200
commit0ed96034b49aa270842285d4170d2893641a2bfa (patch)
tree4f5f1dbe52d07ce76f6ce14405cc29dabffab8c9
parent7b588190ce06fe1e6da77799b1f8853db027ef99 (diff)
downloadperlweeklychallenge-club-0ed96034b49aa270842285d4170d2893641a2bfa.tar.gz
perlweeklychallenge-club-0ed96034b49aa270842285d4170d2893641a2bfa.tar.bz2
perlweeklychallenge-club-0ed96034b49aa270842285d4170d2893641a2bfa.zip
Lua solutions for week 134
-rw-r--r--challenge-134/abigail/README.md6
-rw-r--r--challenge-134/abigail/lua/ch-1.lua13
-rw-r--r--challenge-134/abigail/lua/ch-2.lua24
3 files changed, 41 insertions, 2 deletions
diff --git a/challenge-134/abigail/README.md b/challenge-134/abigail/README.md
index e3b1b50bb8..3ea3d1e459 100644
--- a/challenge-134/abigail/README.md
+++ b/challenge-134/abigail/README.md
@@ -6,11 +6,13 @@
* [Bash](bash/ch-1.sh)
* [Befunge-93](befunge-93/ch-1.bf93)
* [C](c/ch-1.c)
+* [Lua](lua/ch-1.lua)
* [Perl](perl/ch-1.pl)
## Part 2
* [AWK](awk/ch-2.awk)
-* [Bash](bash/ch-1.sh)
-* [C](c/ch-1.c)
+* [Bash](bash/ch-2.sh)
+* [C](c/ch-2.c)
+* [Lua](lua/ch-2.lua)
* [Perl](perl/ch-2.pl)
diff --git a/challenge-134/abigail/lua/ch-1.lua b/challenge-134/abigail/lua/ch-1.lua
new file mode 100644
index 0000000000..1b0d219dce
--- /dev/null
+++ b/challenge-134/abigail/lua/ch-1.lua
@@ -0,0 +1,13 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-1.lua
+--
+
+for _, tail in ipairs ({789, 798, 879, 897, 978}) do
+ print (1023456000 + tail)
+end
diff --git a/challenge-134/abigail/lua/ch-2.lua b/challenge-134/abigail/lua/ch-2.lua
new file mode 100644
index 0000000000..4ea5926b60
--- /dev/null
+++ b/challenge-134/abigail/lua/ch-2.lua
@@ -0,0 +1,24 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-2.lua < input-file
+--
+
+for line in io . lines () do
+ local _, _, m, n = line : find ("([0-9]+)%s+([0-9]+)")
+ local seen = {}
+ local count = 0
+ for x = 1, m do
+ for y = 1, n do
+ if seen [x * y] == nil then
+ seen [x * y] = 1
+ count = count + 1
+ end
+ end
+ end
+ print (count)
+end