Cody

Problem 44437. How many days in a month?

Solution 3440713

Submitted on 27 Oct 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   Pass
filetext = fileread('daysInMonth.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden') assert(isempty(strfind(filetext, 'if')),'IF statements are forbidden')

2   Pass
m = 1; d_correct = 31; assert(isequal(daysInMonth(m),d_correct))

3   Pass
m = 2; d_correct = 28; assert(isequal(daysInMonth(m),d_correct))

4   Fail
m = 3; d_correct = 31; assert(isequal(daysInMonth(m),d_correct))

Assertion failed.

5   Fail
m = 4; d_correct = 30; assert(isequal(daysInMonth(m),d_correct))

Assertion failed.

6   Fail
m = 5; d_correct = 31; assert(isequal(daysInMonth(m),d_correct))

Assertion failed.

7   Fail
m = 6; d_correct = 30; assert(isequal(daysInMonth(m),d_correct))

Assertion failed.

8   Fail
m = 7; d_correct = 31; assert(isequal(daysInMonth(m),d_correct))

Assertion failed.

9   Fail
m = 8; d_correct = 31; assert(isequal(daysInMonth(m),d_correct))

Assertion failed.

10   Fail
m = 9; d_correct = 30; assert(isequal(daysInMonth(m),d_correct))

Assertion failed.

11   Fail
m = 10; d_correct = 31; assert(isequal(daysInMonth(m),d_correct))

Assertion failed.

12   Fail
m = 11; d_correct = 30; assert(isequal(daysInMonth(m),d_correct))

Assertion failed.

13   Fail
m = 12; d_correct = 31; assert(isequal(daysInMonth(m),d_correct))

Assertion failed.

14   Pass
m = 13; d_correct = -1; assert(isequal(daysInMonth(m),d_correct))

15   Pass
m = randi([-100 0]); d_correct = -1; assert(isequal(daysInMonth(m),d_correct))

Suggested Problems

More from this Author25

Community Treasure Hunt

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

Start Hunting!