aboutsummaryrefslogtreecommitdiff
path: root/challenge-111/abigail/lua/ch-1.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-111/abigail/lua/ch-1.lua')
-rw-r--r--challenge-111/abigail/lua/ch-1.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/challenge-111/abigail/lua/ch-1.lua b/challenge-111/abigail/lua/ch-1.lua
new file mode 100644
index 0000000000..194e55b458
--- /dev/null
+++ b/challenge-111/abigail/lua/ch-1.lua
@@ -0,0 +1,33 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-1.lua < input-file
+--
+
+local MATRIX_SIZE = 5
+
+matrix = {}
+
+--
+-- Read in the matrix
+--
+for i = 1, MATRIX_SIZE * MATRIX_SIZE do
+ matrix [io . read ("*number")] = 1
+end
+
+--
+-- Read in the rest, printing 1/0 depending on
+-- whether the number is present in the matrix or not.
+--
+while true do
+ target = io . read ("*number")
+ if target == nil then break end
+ if matrix [target]
+ then print (1)
+ else print (0)
+ end
+end