diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2022-05-06 23:52:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-06 23:52:27 +0100 |
| commit | ec0d440c0166df125085965960faf51eeca241c3 (patch) | |
| tree | 69ffce31bcca6d6b153ed7b733971498d96cc1bd /challenge-163/deadmarshal/lua/ch-2.lua | |
| parent | 67cc3af871ef6bec7dae84cfe98c1588fa2cb3ed (diff) | |
| parent | e14476b64148f02531bbd641d012cf835aa3826a (diff) | |
| download | perlweeklychallenge-club-ec0d440c0166df125085965960faf51eeca241c3.tar.gz perlweeklychallenge-club-ec0d440c0166df125085965960faf51eeca241c3.tar.bz2 perlweeklychallenge-club-ec0d440c0166df125085965960faf51eeca241c3.zip | |
Merge pull request #6060 from deadmarshal/challenge163
Added solutions to challenge 163
Diffstat (limited to 'challenge-163/deadmarshal/lua/ch-2.lua')
| -rw-r--r-- | challenge-163/deadmarshal/lua/ch-2.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-163/deadmarshal/lua/ch-2.lua b/challenge-163/deadmarshal/lua/ch-2.lua new file mode 100644 index 0000000000..c4f666d16f --- /dev/null +++ b/challenge-163/deadmarshal/lua/ch-2.lua @@ -0,0 +1,15 @@ +function summations(t) + assert(type(t) == 'table', 't must be a table!') + for i=1, #t do + for j=i+1, #t-1 do + t[j+1] = t[j] + t[j+1] + end + end + return t[#t] +end + +local t = {1,2,3,4,5} +local t2 = {1,3,5,7,9} +print(summations(t)) +print(summations(t2)) + |
