Cody

Problem 2639. How Many Months Until It's Today Again?

Solution 1104677

Submitted on 16 Jan 2017 by Lucinda King
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
d_in = '22-Oct-2014'; m_correct = 6; m_test = monthsUntilMatch(d_in); assert(isequal(m_test,m_correct))

d_dt = datetime 22-Oct-2014 d_week = cell 'Wednesday' d_dt = datetime 22-Nov-2014 idx = 2 d_dt = datetime 22-Dec-2014 idx = 3 d_dt = datetime 22-Jan-2015 idx = 4 d_dt = datetime 22-Feb-2015 idx = 5 d_dt = datetime 22-Mar-2015 idx = 6 d_dt = datetime 22-Apr-2015 wait_in_months = 6

2   Pass
d_in = '2-Jul-2014'; m_correct = 14; m_test = monthsUntilMatch(d_in); assert(isequal(m_test,m_correct))

d_dt = datetime 02-Jul-2014 d_week = cell 'Wednesday' d_dt = datetime 02-Aug-2014 idx = 2 d_dt = datetime 02-Sep-2014 idx = 3 d_dt = datetime 02-Oct-2014 idx = 4 d_dt = datetime 02-Nov-2014 idx = 5 d_dt = datetime 02-Dec-2014 idx = 6 d_dt = datetime 02-Jan-2015 idx = 7 d_dt = datetime 02-Feb-2015 idx = 8 d_dt = datetime 02-Mar-2015 idx = 9 d_dt = datetime 02-Apr-2015 idx = 10 d_dt = datetime 02-May-2015 idx = 11 d_dt = datetime 02-Jun-2015 idx = 12 d_dt = datetime 02-Jul-2015 idx = 13 d_dt = datetime 02-Aug-2015 idx = 14 d_dt = datetime 02-Sep-2015 wait_in_months = 14

3   Pass
d_in = '12-May-2011'; m_correct = 8; m_test = monthsUntilMatch(d_in); assert(isequal(m_test,m_correct))

d_dt = datetime 12-May-2011 d_week = cell 'Thursday' d_dt = datetime 12-Jun-2011 idx = 2 d_dt = datetime 12-Jul-2011 idx = 3 d_dt = datetime 12-Aug-2011 idx = 4 d_dt = datetime 12-Sep-2011 idx = 5 d_dt = datetime 12-Oct-2011 idx = 6 d_dt = datetime 12-Nov-2011 idx = 7 d_dt = datetime 12-Dec-2011 idx = 8 d_dt = datetime 12-Jan-2012 wait_in_months = 8

4   Pass
d_in = '14-Jul-1789'; m_correct = 14; m_test = monthsUntilMatch(d_in) assert(isequal(m_test,m_correct))

d_dt = datetime 14-Jul-1789 d_week = cell 'Tuesday' d_dt = datetime 14-Aug-1789 idx = 2 d_dt = datetime 14-Sep-1789 idx = 3 d_dt = datetime 14-Oct-1789 idx = 4 d_dt = datetime 14-Nov-1789 idx = 5 d_dt = datetime 14-Dec-1789 idx = 6 d_dt = datetime 14-Jan-1790 idx = 7 d_dt = datetime 14-Feb-1790 idx = 8 d_dt = datetime 14-Mar-1790 idx = 9 d_dt = datetime 14-Apr-1790 idx = 10 d_dt = datetime 14-May-1790 idx = 11 d_dt = datetime 14-Jun-1790 idx = 12 d_dt = datetime 14-Jul-1790 idx = 13 d_dt = datetime 14-Aug-1790 idx = 14 d_dt = datetime 14-Sep-1790 wait_in_months = 14 m_test = 14

5   Pass
d_in = '31-Dec-1999'; m_correct = 3; m_test = monthsUntilMatch(d_in) assert(isequal(m_test,m_correct))

d_dt = datetime 31-Dec-1999 d_week = cell 'Friday' d_dt = datetime 31-Jan-2000 idx = 2 d_dt = datetime 29-Feb-2000 idx = 3 d_dt = datetime 31-Mar-2000 wait_in_months = 3 m_test = 3