Cody

Problem 45328. leap year

Solution 2803606

Submitted on 6 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))

Index exceeds the number of array elements (101). Error in leap_count (line 4) b = b + (~mod(n(i),400) || (~mod(n(i),4) && ~~mod(n(i),100))); Error in Test1 (line 2) assert(isequal( leap_count(n),25))

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

Assertion failed.

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

Index exceeds the number of array elements (401). Error in leap_count (line 4) b = b + (~mod(n(i),400) || (~mod(n(i),4) && ~~mod(n(i),100))); Error in Test3 (line 2) assert(isequal( leap_count(n),98))

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

Index exceeds the number of array elements (1). Error in leap_count (line 4) b = b + (~mod(n(i),400) || (~mod(n(i),4) && ~~mod(n(i),100))); Error in Test4 (line 2) assert(isequal( leap_count(n),0))

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

Index exceeds the number of array elements (91). Error in leap_count (line 4) b = b + (~mod(n(i),400) || (~mod(n(i),4) && ~~mod(n(i),100))); 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!