Day of the Week by tabasa

for l in io.lines()do\x0d
m={}\x0d
i=1\x0d
for n in l:gmatch("%d+")do m[i]=tonumber(n);i=i+1 end\x0d
\x0d
function r(i)\x0d
return i-i%1\x0d
end\x0d
\x0d
function w(a)\x0d
y,m,d=a[1],a[2],a[3]\x0d
if m<3 then y=y-1;m=m+12 end\x0d
return (y+r(y/4)-r(y/100)+r(y/400)+r((13*m+8)/5)+d)%7\x0d
end\x0d
\x0d
print(w(m))\x0d
end

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page