62 lines
968 B
Text
62 lines
968 B
Text
import stdlib.*;
|
|
import stdlib.stdin.*;
|
|
import stdlib.math.*;
|
|
|
|
exported func main() {
|
|
foreach testCase in [#][
|
|
7259,
|
|
86400,
|
|
6000000,
|
|
] {
|
|
testCase.timeString().println();
|
|
}
|
|
}
|
|
|
|
func timeString(seconds int) str {
|
|
result = "";
|
|
|
|
minutes = seconds / 60;
|
|
set seconds = seconds.mod(60);
|
|
if seconds > 0 {
|
|
set result = seconds.str() + " sec";
|
|
}
|
|
|
|
hours = minutes / 60;
|
|
set minutes = minutes.mod(60);
|
|
if minutes > 0 {
|
|
set result = minutes.str() + if result != "" {
|
|
" min, " + result
|
|
} else {
|
|
" min"
|
|
};
|
|
}
|
|
|
|
days = hours / 24;
|
|
set hours = hours.mod(24);
|
|
if hours > 0 {
|
|
set result = hours.str() + if result != "" {
|
|
" hr, " + result
|
|
} else {
|
|
" hr"
|
|
};
|
|
}
|
|
|
|
weeks = days / 7;
|
|
set days = days.mod(7);
|
|
if days > 0 {
|
|
set result = days.str() + if result != "" {
|
|
" d, " + result
|
|
} else {
|
|
" d"
|
|
};
|
|
}
|
|
if weeks > 0 {
|
|
set result = weeks.str() + if result != "" {
|
|
" wk, " + result
|
|
} else {
|
|
" wk"
|
|
};
|
|
}
|
|
|
|
return result;
|
|
}
|