aboutsummaryrefslogtreecommitdiff
path: root/challenge-127/deadmarshal/lua/ch-2.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-127/deadmarshal/lua/ch-2.lua')
-rw-r--r--challenge-127/deadmarshal/lua/ch-2.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/challenge-127/deadmarshal/lua/ch-2.lua b/challenge-127/deadmarshal/lua/ch-2.lua
new file mode 100644
index 0000000000..60136c3c29
--- /dev/null
+++ b/challenge-127/deadmarshal/lua/ch-2.lua
@@ -0,0 +1,17 @@
+#!/usr/bin/env lua
+
+local function conflict_intervals(t)
+ assert(type(t) == 'table','t must be a table!')
+ for i=2,#t do
+ local b = false
+ for j=1,i-1 do
+ if t[i][1] >= t[j][1] and t[i][1] <= t[j][2] then b = true end
+ end
+ if b then io.write(string.format('(%d %d) ',t[i][1],t[i][2])) end
+ end
+ print("")
+end
+
+conflict_intervals{{1,4},{3,5},{6,8},{12,13},{3,20}}
+conflict_intervals{{3,4},{5,7},{6,9},{10,12},{13,15}}
+