RosettaCodeData/Task/Long-year/Pluto/long-year.pluto
2026-04-30 12:34:36 -04:00

15 lines
597 B
Text

local fmt = require "fmt"
local centuries = {"20th", "21st", "22nd"}
local starts = {1900, 2000, 2100}
local td = "Thursday" -- check if beginnning or end of year is Thursday or both are
for i = 1, #centuries do
local long_years = {}
print($"\nLong years in the {centuries[i]} century:")
for j = starts[i], starts[i] + 99 do
local day1 = os.date("%A", os.time({year = j, month = 1, day = 1}))
local day2 = os.date("%A", os.time({year = j, month = 12, day = 31}))
if day1 == td or day2 == td then long_years:insert(j) end
end
fmt.lprint(long_years)
end