Cody

Problem 45328. leap year

Solution 2874341

Submitted on 24 Aug 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
n = 1900:2000; assert(isequal( leap_count(n),25))

Undefined function 'leapyear' for input arguments of type 'double'. Error in leap_count (line 3) sum(leapyear(year(datetime(string(n), 'Format', 'yyyy'))) == 1); Error in Test1 (line 2) assert(isequal( leap_count(n),25))

2   Fail
n = 100:2000; assert(isequal( leap_count(n),461))

Undefined function 'leapyear' for input arguments of type 'double'. Error in leap_count (line 3) sum(leapyear(year(datetime(string(n), 'Format', 'yyyy'))) == 1); Error in Test2 (line 2) assert(isequal( leap_count(n),461))

3   Fail
n = 1600:2000; assert(isequal( leap_count(n),98))

Undefined function 'leapyear' for input arguments of type 'double'. Error in leap_count (line 3) sum(leapyear(year(datetime(string(n), 'Format', 'yyyy'))) == 1); Error in Test3 (line 2) assert(isequal( leap_count(n),98))

4   Fail
n = 3000; assert(isequal( leap_count(n),0))

Undefined function 'leapyear' for input arguments of type 'double'. Error in leap_count (line 3) sum(leapyear(year(datetime(string(n), 'Format', 'yyyy'))) == 1); Error in Test4 (line 2) assert(isequal( leap_count(n),0))

5   Fail
n = 377:467; assert(isequal( leap_count(n),22))

Undefined function 'leapyear' for input arguments of type 'double'. Error in leap_count (line 3) sum(leapyear(year(datetime(string(n), 'Format', 'yyyy'))) == 1); Error in Test5 (line 2) assert(isequal( leap_count(n),22))

Suggested Problems

More from this Author149

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!