aboutsummaryrefslogtreecommitdiff
path: root/challenge-130/abigail/lua/ch-1.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-130/abigail/lua/ch-1.lua')
-rw-r--r--challenge-130/abigail/lua/ch-1.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-130/abigail/lua/ch-1.lua b/challenge-130/abigail/lua/ch-1.lua
new file mode 100644
index 0000000000..6b5479291b
--- /dev/null
+++ b/challenge-130/abigail/lua/ch-1.lua
@@ -0,0 +1,25 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-1.lua < input-file
+--
+
+for line in io . lines () do
+ local numbers = {}
+ for n in line : gmatch ("([1-9][0-9]*)") do
+ if numbers [n] == nil then
+ numbers [n] = 1
+ else
+ numbers [n] = numbers [n] + 1
+ end
+ end
+ for number, count in pairs (numbers) do
+ if numbers [number] % 2 == 1 then
+ print (number)
+ end
+ end
+end