-- https://www.twle.cn/l/yufei/exercise/python-exercise-1.htmlfunctiona1()for i = 1, 4dofor j = 1, 4dofor k = 1, 4doif (i ~= j and i ~=k and j ~= k) thenprint(i .. j .. k)
endendendendendfunctionp3()local res, go; res = 1; go = true;
while (not isSq(res + 100) or (not isSq(res + 100 + 168))) do
res = res + 1endprint(res)
return res
endfunctionisSq(n)local i; i = 1while (i * i ~= n and i < n) do i = i + 1endreturn i < n
endfunctionp4(y, m, d)functionisLeap(y)if (y % 400 == 0) thenreturntrueelseif (y % 100 == 0) thenreturnfalseelseif (y % 4 ==0) thenreturntrueelsereturnfalseendendlocal res, xs; res = 0; xs = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
for i = 1, m - 1do res = res + xs[i] end-- NOTE it's m - 1
res = res + d
if (isLeap(y)) then res = res + 1endprint(res)
return res
end
p4(2015, 6, 7)