From 7d92a145e089e59f0f830843ba91cd7223bc6c98 Mon Sep 17 00:00:00 2001 From: deadmarshal Date: Wed, 15 Nov 2023 21:53:10 +0330 Subject: TWC243 extra solutions --- challenge-243/deadmarshal/lua/ch-2.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 challenge-243/deadmarshal/lua/ch-2.lua (limited to 'challenge-243/deadmarshal/lua/ch-2.lua') 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}) + -- cgit