Worthwhile task shaving: Difference between revisions
m
→{{header|Phix}}: use pygments
m (→{{header|Phix}}: use pygments) |
|||
Line 401:
=={{header|Phix}}==
<!--
with javascript_semantics
constant SEC = 1,
MIN = 60,
HOUR = 60*MIN,
DAY = 8*HOUR, -- (allow some sleepage)
WEEK = 5*DAY, -- (omit weekends)
MONTH = 4*WEEK,
YEAR = 12*MONTH, -- (as 48 weeks/omit holidays)
shavings = {1,5,30,MIN,5*MIN,30*MIN,HOUR,6*HOUR,DAY},
frequencies = {{50,DAY},{5,DAY},{1,DAY},{1,WEEK},{1,MONTH},{1,YEAR}},
roundto = {SEC, MIN, HOUR, DAY, WEEK, MONTH, YEAR},
ts = {"sec", "min", "hour", "day", "week", "month", "year"}
function duration(atom a)
string es
for rdx=1 to length(roundto) do
atom t = trunc(a/roundto[rdx])
if rdx>1 and t<1 then exit end if
es = sprintf("%d %s%s",{t,ts[rdx],iff(t=1?"":"s")})
end for
return es
end function
printf(1,"""
Shave off | ------------------- How Often You Do The Task ----------------------
""")
for s=1 to length(shavings) do
integer si = shavings[s]
string line = sprintf("%10s ",duration(si))
for f=1 to length(frequencies) do
integer {per,slot} = frequencies[f]
if si*per > slot then
else
atom shaving = (5*YEAR/slot * per) * si
line &= sprintf("%10s ",duration(shaving))
end if
end for
printf(1,"%s\n",line)
end for
▲<!--</syntaxhighlight>-->
</syntaxhighlight>
{{out}}
One outlier here is 1hr 5/day ==> 3 years vs original 10 months: as per notes above for 5/8ths the cutoff is indeed 3 years.<br>
|