aboutsummaryrefslogtreecommitdiff
path: root/challenge-199/deadmarshal/lua/ch-1.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-199/deadmarshal/lua/ch-1.lua')
-rw-r--r--challenge-199/deadmarshal/lua/ch-1.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/challenge-199/deadmarshal/lua/ch-1.lua b/challenge-199/deadmarshal/lua/ch-1.lua
new file mode 100644
index 0000000000..3d75319798
--- /dev/null
+++ b/challenge-199/deadmarshal/lua/ch-1.lua
@@ -0,0 +1,17 @@
+#!/usr/bin/env lua
+
+local function good_pairs(t)
+ assert(type(t) == 'table','t must be a table!')
+ local count = 0
+ for i=1,#t do
+ for j=i+1,#t do
+ if t[i] == t[j] then count = count + 1 end
+ end
+ end
+ return count
+end
+
+print(good_pairs({1,2,3,1,1,3}))
+print(good_pairs({1,2,3}))
+print(good_pairs({1,1,1,1}))
+