aboutsummaryrefslogtreecommitdiff
path: root/challenge-134/abigail/lua
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 /challenge-134/abigail/lua
parent7b588190ce06fe1e6da77799b1f8853db027ef99 (diff)
downloadperlweeklychallenge-club-0ed96034b49aa270842285d4170d2893641a2bfa.tar.gz
perlweeklychallenge-club-0ed96034b49aa270842285d4170d2893641a2bfa.tar.bz2
perlweeklychallenge-club-0ed96034b49aa270842285d4170d2893641a2bfa.zip
Lua solutions for week 134
Diffstat (limited to 'challenge-134/abigail/lua')
-rw-r--r--challenge-134/abigail/lua/ch-1.lua13
-rw-r--r--challenge-134/abigail/lua/ch-2.lua24
2 files changed, 37 insertions, 0 deletions
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