aboutsummaryrefslogtreecommitdiff
path: root/challenge-113/abigail/lua/ch-2.lua
blob: 15aac1ac2d8454487aecbd0ab2a30f485893af95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/opt/local/bin/lua

--
-- See ../README.md
--

--
-- Run as: lua ch-2.lua < input-file
--

for line in io . lines () do
    local sum = 0
    for  n in line : gmatch ("[0-9]+")
    do   sum = sum + tonumber (n)
    end
    local c = 0
    for  n in line : gmatch ("[0-9]+")
    do   if   c > 0
         then io . write (" ")
         end
         c = c + 1
         io . write (sum - n)
    end
    io . write ("\n")
end