diff options
Diffstat (limited to 'challenge-241/deadmarshal/lua/ch-1.lua')
| -rw-r--r-- | challenge-241/deadmarshal/lua/ch-1.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-241/deadmarshal/lua/ch-1.lua b/challenge-241/deadmarshal/lua/ch-1.lua new file mode 100644 index 0000000000..a63054cda6 --- /dev/null +++ b/challenge-241/deadmarshal/lua/ch-1.lua @@ -0,0 +1,19 @@ +#!/usr/bin/env lua + +local function arithmetic_triplets(t,diff) + local count = 0 + for i=1,#t do + for j=i+1,#t do + for k=j+1,#t do + if t[j] - t[i] == diff and t[k] - t[j] == diff then + count = count + 1 + end + end + end + end + return count +end + +print(arithmetic_triplets({0,1,4,6,7,10},3)) +print(arithmetic_triplets({4,5,6,7,8,9},2)) + |
