Cody

Problem 44437. How many days in a month?

Solution 2052883

Submitted on 10 Dec 2019 by ariel afriat
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))

d = 31

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

d = 28

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

d = 31

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

d = 30

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

d = 31

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

d = 30

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

d = 31

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

d = 31

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

d = 30

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

d = 31

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

d = 30

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

d = 31

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

d = -1

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

d = -1