aboutsummaryrefslogtreecommitdiff
path: root/challenge-243/deadmarshal/lua/ch-2.lua
diff options
context:
space:
mode:
authordeadmarshal <adeadmarshal@gmail.com>2023-11-15 21:53:10 +0330
committerdeadmarshal <adeadmarshal@gmail.com>2023-11-15 21:53:10 +0330
commit7d92a145e089e59f0f830843ba91cd7223bc6c98 (patch)
tree5e0043297d1fde64aa5c75c5e1440c4cbc393389 /challenge-243/deadmarshal/lua/ch-2.lua
parentd20e7296170b997b7e690a58b79156f6c81f1cd2 (diff)
downloadperlweeklychallenge-club-7d92a145e089e59f0f830843ba91cd7223bc6c98.tar.gz
perlweeklychallenge-club-7d92a145e089e59f0f830843ba91cd7223bc6c98.tar.bz2
perlweeklychallenge-club-7d92a145e089e59f0f830843ba91cd7223bc6c98.zip
TWC243 extra solutions
Diffstat (limited to 'challenge-243/deadmarshal/lua/ch-2.lua')
-rw-r--r--challenge-243/deadmarshal/lua/ch-2.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-243/deadmarshal/lua/ch-2.lua b/challenge-243/deadmarshal/lua/ch-2.lua
new file mode 100644
index 0000000000..c71dfcc814
--- /dev/null
+++ b/challenge-243/deadmarshal/lua/ch-2.lua
@@ -0,0 +1,16 @@
+#!/usr/bin/env lua
+
+local function floor_sum(t)
+ assert(type(t) == 'table','t must be a table!')
+ local sum = 0
+ for i=1,#t do
+ for j=1,#t do
+ sum = sum + (t[i] // t[j])
+ end
+ end
+ return sum
+end
+
+print(floor_sum{2,5,9})
+print(floor_sum{7,7,7,7,7,7,7})
+