Lua Source Code
-- Author: Hannes du Plooy
-- Date: 8 October 2013
-- Objective: To solve the following
-- ONE
-- ONE
-- ONE
-- +ONE
-- ----
-- TEN
done = false
for O=1,2 do
for E=0,9 do
if (O ~= E) then
tmp = E*4
carry = math.floor(tmp/10)
N = tmp % 10
if (N ~= O and N ~= E) then
tmp = carry + N*4
carry = math.floor(tmp/10)
E2 = tmp % 10
if (E2 == E) then
T = carry + O*4
if (T < 10) then
if (T ~= O and T ~= E and T ~= N) then
print("Answer is \n")
print(" " .. O .. N .. E)
print(" " .. O .. N .. E)
print(" " .. O .. N .. E)
print("+" .. O .. N .. E)
print("----")
print(" " .. T .. E .. N)
done = true
break
end
end
end
end
end
end
if done then break end
end