diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-12-29 19:25:59 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-29 19:25:59 +0000 |
| commit | 391618c86bc7b3f8e1243ae7e26ee996a240d6b2 (patch) | |
| tree | befbe8f797b911942c575d62674c51a8e1a2f291 /challenge-145/abigail/lua/ch-1.lua | |
| parent | 58223a8102e2541f830e1208a0cc1daf6024331e (diff) | |
| parent | a7cfe19e7988033b8b37d4effedcf01ee203ff0e (diff) | |
| download | perlweeklychallenge-club-391618c86bc7b3f8e1243ae7e26ee996a240d6b2.tar.gz perlweeklychallenge-club-391618c86bc7b3f8e1243ae7e26ee996a240d6b2.tar.bz2 perlweeklychallenge-club-391618c86bc7b3f8e1243ae7e26ee996a240d6b2.zip | |
Merge pull request #5442 from Abigail/abigail/week-145
Week 145
Diffstat (limited to 'challenge-145/abigail/lua/ch-1.lua')
| -rw-r--r-- | challenge-145/abigail/lua/ch-1.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/challenge-145/abigail/lua/ch-1.lua b/challenge-145/abigail/lua/ch-1.lua new file mode 100644 index 0000000000..27ab36961a --- /dev/null +++ b/challenge-145/abigail/lua/ch-1.lua @@ -0,0 +1,30 @@ +#!/opt/local/bin/lua + +-- +-- See ../README.md +-- + +-- +-- Run as: lua ch-1.lua < input-file +-- + +local a = {} +local b = {} + +local a_line = io . read ("*l") +local b_line = io . read ("*l") + +for n in a_line : gmatch ("-?[0-9]+") do + a [#a + 1] = tonumber (n) +end +for n in b_line : gmatch ("-?[0-9]+") do + b [#b + 1] = tonumber (n) +end + +local sum = 0 + +for i = 1, #a do + sum = sum + a [i] * b [i] +end + +print (sum) |
