Skip to content

Commit

Permalink
Solve p16 in lua (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Oct 10, 2024
1 parent 9c8a1e1 commit 354858f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lua/src/p0016.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ return {
local power = 1
local answer = 0

for i = 1,1000 do
for j = 1,#numbers do
numbers[j] = numbers[j] * 2
for _ = 1,1000 do
for i = 1,#numbers do
numbers[i] = numbers[i] * 2
end
for j = 1,(#numbers - 1) do
if (numbers[j] > ten15) then
numbers[j + 1] = numbers[j + 1] + math.floor(numbers[j] / ten15)
numbers[j] = numbers[j] % ten15
for i = 1,(#numbers - 1) do
if (numbers[i] > ten15) then
numbers[i + 1] = numbers[i + 1] + math.floor(numbers[i] / ten15)
numbers[i] = numbers[i] % ten15
end
end
end
for i = 1, 18 do
for j = 1,#numbers do
answer = answer + math.floor(numbers[j] / power) % 10
for _ = 1, 18 do
for i = 1,#numbers do
answer = answer + math.floor(numbers[i] / power) % 10
end
power = power * 10
end
Expand Down

0 comments on commit 354858f

Please sign in to comment.