Problem 62. Elapsed Time
Solution Stats
Problem Comments
-
12 Comments
The testsuite input does not following the input format string.
Having a hard time with the test suite regarding the number of hours in one year. I think it should be 8 765.81277h/y
The test suite doesnt follow. it should be double digit days and month, not single digits according to his descrption
having problems with the test suite especially test no 3
having problems with test no 3 of the test suite,why?
It's a fun problem
the test suits are all passed , but the mathworks net tells its wrong.
and the size is '-1'.
i use the datenum function.
I use format bank to get 2 decimal output, anyone has a better idea?
using existing functions makes this trick easy
with an existing funcion it is solveable
function elapsed= elapsed_time(d1,d2)
d1='2010/12/14 12:00:00'
d2='2010/12/15 13:06:36'
a=(str2num(d2(1:4))-str2num(d1(1:4)))*8760;
b=(str2num(d2(6:7))-str2num(d1(6:7)))*720;
c=(str2num(d2(9:10))-str2num(d1(9:10)))*24;
e=str2num(d2(12:13))-str2num(d1(12:13));
f=(str2num(d2(15:16))-str2num(d1(15:16)))/60;
g=(str2num(d2(18:19))-str2num(d1(18:19)))/3600;
elapsed=a+b+c+e+f+g
end
it told me that solution is wrong?
Nice question
Solution Comments
-
1 Comment
This test program is wrong.To judge a leap year, you need to calculate if the following condition is satisfied mod(year,4)==0 & mod(year,100)~=0 & mod(year,400)==0. However, this team only count those years that mod(year,4)==0
-
1 Comment
why this function returns an error it works perfectly on my pc
-
1 Comment
the test suits are all passed , but the mathworks net tells its wrong. and the size is '-1'. i use the datenum function.
-
1 Comment
The value of d1 in Test Suite #3 is not to spec (one digit for the month).
-
1 Comment
Love the little "if" in the end ! :D
-
1 Comment
doesn't work any longer
Problem Recent Solvers2448
Suggested Problems
-
633 Solvers
-
Given a window, how many subsets of a vector sum positive
832 Solvers
-
10435 Solvers
-
Given a square and a circle, please decide whether the square covers more area.
660 Solvers
-
5875 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!