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
-
Find the numeric mean of the prime numbers in a matrix.
8071 Solvers
-
Return the first and last characters of a character array
7350 Solvers
-
Find nearest prime number less than input number
461 Solvers
-
Fahrenheit to Celsius converter
486 Solvers
-
Natural numbers in string form
971 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!