split code and remove prints
This commit is contained in:
parent
992473a1ee
commit
d5ffd524b1
@ -10,16 +10,12 @@ for _, timer in pairs(split(io.open(arg[3]):read("*a"), ",")) do
|
||||
fishes[tonumber(timer)] = fishes[tonumber(timer)] + 1
|
||||
end
|
||||
|
||||
for day = 1, 256 do
|
||||
for day = 1, 80 do
|
||||
fishes[9] = (fishes[0] or 0) + (fishes[9] or 0)
|
||||
fishes[7] = (fishes[0] or 0) + (fishes[7] or 0)
|
||||
for timer = 0, 9 do
|
||||
fishes[timer] = fishes[timer + 1]
|
||||
end
|
||||
for k = 0, 9 do
|
||||
io.write((fishes[k] or "_")..",")
|
||||
end
|
||||
io.write("\n")
|
||||
end
|
||||
|
||||
local sum = 0
|
||||
|
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env luajit
|
||||
require("utils")
|
||||
|
||||
local fishes = {}
|
||||
for timer = 0, 9 do
|
||||
fishes[timer] = 0
|
||||
end
|
||||
|
||||
for _, timer in pairs(split(io.open(arg[3]):read("*a"), ",")) do
|
||||
fishes[tonumber(timer)] = fishes[tonumber(timer)] + 1
|
||||
end
|
||||
|
||||
for day = 1, 256 do
|
||||
fishes[9] = (fishes[0] or 0) + (fishes[9] or 0)
|
||||
fishes[7] = (fishes[0] or 0) + (fishes[7] or 0)
|
||||
for timer = 0, 9 do
|
||||
fishes[timer] = fishes[timer + 1]
|
||||
end
|
||||
end
|
||||
|
||||
local sum = 0
|
||||
for timer, fishday in pairs(fishes) do
|
||||
sum = sum + fishday
|
||||
end
|
||||
|
||||
print(sum)
|
Loading…
Reference in New Issue
Block a user