{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":2362,"title":"What day is it?","description":"Tell me what day is it. Return the full name of the day of the week as a string.\r\n\r\ne.g. It's June 12th 2014, so your function should return 'Thursday'","description_html":"\u003cp\u003eTell me what day is it. Return the full name of the day of the week as a string.\u003c/p\u003e\u003cp\u003ee.g. It's June 12th 2014, so your function should return 'Thursday'\u003c/p\u003e","function_template":"function y = day_of_week()\r\ny = 'Friday';\r\nend","test_suite":"%%\r\ntoday = java.util.Date;\r\nc = java.util.Calendar.getInstance();\r\nc.setTime( today );\r\ndayOfWeek = c.get(java.util.Calendar.DAY_OF_WEEK);\r\nswitch dayOfWeek\r\n    case 1\r\n        dayOfWeek = 'Sunday';    \r\n    case 2\r\n        dayOfWeek = 'Monday';\r\n    case 3\r\n        dayOfWeek = 'Tuesday';\r\n    case 4\r\n        dayOfWeek = 'Wednesday';\r\n    case 5\r\n        dayOfWeek = 'Thursday';\r\n    case 6\r\n        dayOfWeek = 'Friday';\r\n    case 7\r\n        dayOfWeek = 'Saturday';\r\nend\r\nassert(strcmp(dayOfWeek,day_of_week()))","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":450,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":222,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-06-12T20:06:06.000Z","updated_at":"2026-03-12T20:06:11.000Z","published_at":"2014-06-13T14:20:59.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTell me what day is it. Return the full name of the day of the week as a string.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ee.g. It's June 12th 2014, so your function should return 'Thursday'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45328,"title":"leap year","description":"find the number of leap years within the given time interval","description_html":"\u003cp\u003efind the number of leap years within the given time interval\u003c/p\u003e","function_template":"function b = leap_count(n)\r\n  y = x;\r\nend","test_suite":"%%\r\nn = 1900:2000;\r\nassert(isequal( leap_count(n),25))\r\n%%\r\nn = 100:2000;\r\nassert(isequal( leap_count(n),461))\r\n%%\r\nn = 1600:2000;\r\nassert(isequal( leap_count(n),98))\r\n%%\r\nn = 3000;\r\nassert(isequal( leap_count(n),0))\r\n%%\r\nn = 377:467;\r\nassert(isequal( leap_count(n),22))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":84,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-02-15T07:16:33.000Z","updated_at":"2025-12-21T21:32:21.000Z","published_at":"2020-02-15T07:16:59.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003efind the number of leap years within the given time interval\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45378,"title":"Lost days","description":"Given two dates in a particular format, calculate the difference between them.\r\n","description_html":"\u003cp\u003eGiven two dates in a particular format, calculate the difference between them.\u003c/p\u003e","function_template":"function y = date_dis(a,b,c)","test_suite":"%%\r\na=[2019 2 4];\r\nb=[1992 3 6];\r\nc='yyyy-MM-dd';\r\ny=calendarDuration(26,10,29);\r\nassert(isequal(date_dis(a,b,c),y))\r\n\r\n%%\r\na=[2029 12 14];\r\nb=[1892 13 16];\r\nc='yyyy-MM-dd';\r\ny=calendarDuration(136,10,28);\r\nassert(isequal(date_dis(a,b,c),y))\r\n\r\n%%\r\na='14/11/2018';\r\nb='14/12/2009';\r\nc='dd/MM/yyyy';\r\ny=calendarDuration(8,11,0);\r\nassert(isequal(date_dis(a,b,c),y))\r\n\r\n%%\r\na='29-12-2014';\r\nb='02-01-1916';\r\nc='dd-MM-yyyy';\r\ny=calendarDuration(98,11,27);\r\nassert(isequal(date_dis(a,b,c),y))","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":61,"test_suite_updated_at":"2020-03-23T11:35:18.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-23T11:23:03.000Z","updated_at":"2025-11-21T18:07:42.000Z","published_at":"2020-03-23T11:35:18.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two dates in a particular format, calculate the difference between them.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2196,"title":"Tax Season ! How much is my salary?","description":"Tax Season! I was employed for a period from x until y in a year and I get pay check of amount z on every alternate Friday of the week starting from first Friday since I am employed. Help me find out how much did I earn during my employment period.\r\n\r\nExample\r\n\r\n x = 01-Jan-2014\r\n y = 14-Feb-2014\r\n z = $2000 (x will always be \u003cy)\r\n\r\nThis period has total 4 alternate Fridays which were my \"pay-days\", so the salary for this period was 4*2000 = %8000\r\n\r\n","description_html":"\u003cp\u003eTax Season! I was employed for a period from x until y in a year and I get pay check of amount z on every alternate Friday of the week starting from first Friday since I am employed. Help me find out how much did I earn during my employment period.\u003c/p\u003e\u003cp\u003eExample\u003c/p\u003e\u003cpre\u003e x = 01-Jan-2014\r\n y = 14-Feb-2014\r\n z = $2000 (x will always be \u0026lt;y)\u003c/pre\u003e\u003cp\u003eThis period has total 4 alternate Fridays which were my \"pay-days\", so the salary for this period was 4*2000 = %8000\u003c/p\u003e","function_template":"function salary= AllAboutMoney_Honey(x,y,z)\r\nsalary = 0;\r\nend","test_suite":"%%\r\nx = '01-Jan-2014';\r\ny = '14-Feb-2014';\r\nz = 2000;\r\nsalary = 8000;\r\nassert(isequal(AllAboutMoney_Honey(x,y,z),salary))\r\n\r\n%%\r\nx = '14-Feb-2013';\r\ny = '29-Apr-2013';\r\nz = 3599;\r\nsalary = 21594;\r\nassert(isequal(AllAboutMoney_Honey(x,y,z),salary))\r\n\r\n%%\r\nx = '01-Jan-2012';\r\ny = '31-Dec-2012';\r\nz = 500;\r\nsalary = 13000;\r\nassert(isequal(AllAboutMoney_Honey(x,y,z),salary))\r\n\r\n%%\r\nx = '13-Dec-2011';\r\ny = '28-Jan-2012';\r\nz = 654;\r\nsalary = 2616;\r\nassert(isequal(AllAboutMoney_Honey(x,y,z),salary))\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":1,"created_by":16381,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":82,"test_suite_updated_at":"2014-02-18T17:46:13.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-02-18T17:13:55.000Z","updated_at":"2026-01-05T00:12:47.000Z","published_at":"2014-02-18T17:15:43.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTax Season! I was employed for a period from x until y in a year and I get pay check of amount z on every alternate Friday of the week starting from first Friday since I am employed. Help me find out how much did I earn during my employment period.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ x = 01-Jan-2014\\n y = 14-Feb-2014\\n z = $2000 (x will always be \u003cy)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis period has total 4 alternate Fridays which were my \\\"pay-days\\\", so the salary for this period was 4*2000 = %8000\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2336,"title":"Calendar Matrix","description":"Return a calendar matrix for the given values of month and year. Assume that Sunday is the first day of the week. The resulting calendar month will have seven columns and only as many rows (weeks) as needed to display all days of the month. Thus it might have either 4, 5, or 6 rows. Days preceding the first of the month or following the last of the month are given by zeros.\r\n\r\nExamples\r\n\r\n \u003e\u003e mo = 1\r\n \u003e\u003e yr = 2014\r\n \u003e\u003e momat = makeCalendar(mo,yr)\r\n\r\n     0     0     0     1     2     3     4\r\n     5     6     7     8     9    10    11\r\n    12    13    14    15    16    17    18\r\n    19    20    21    22    23    24    25\r\n    26    27    28    29    30    31     0\r\n\r\n \u003e\u003e mo = 2\r\n \u003e\u003e yr = 2015\r\n \u003e\u003e momat = makeCalendar(mo,yr)\r\n\r\n     1     2     3     4     5     6     7\r\n     8     9    10    11    12    13    14\r\n    15    16    17    18    19    20    21\r\n    22    23    24    25    26    27    28\r\n\r\n\r\n \u003e\u003e mo = 10\r\n \u003e\u003e yr = 2010\r\n \u003e\u003e momat = makeCalendar(mo,yr)\r\n\r\n     0     0     0     0     0     1     2\r\n     3     4     5     6     7     8     9\r\n    10    11    12    13    14    15    16\r\n    17    18    19    20    21    22    23\r\n    24    25    26    27    28    29    30\r\n    31     0     0     0     0     0     0","description_html":"\u003cp\u003eReturn a calendar matrix for the given values of month and year. Assume that Sunday is the first day of the week. The resulting calendar month will have seven columns and only as many rows (weeks) as needed to display all days of the month. Thus it might have either 4, 5, or 6 rows. Days preceding the first of the month or following the last of the month are given by zeros.\u003c/p\u003e\u003cp\u003eExamples\u003c/p\u003e\u003cpre\u003e \u0026gt;\u0026gt; mo = 1\r\n \u0026gt;\u0026gt; yr = 2014\r\n \u0026gt;\u0026gt; momat = makeCalendar(mo,yr)\u003c/pre\u003e\u003cpre\u003e     0     0     0     1     2     3     4\r\n     5     6     7     8     9    10    11\r\n    12    13    14    15    16    17    18\r\n    19    20    21    22    23    24    25\r\n    26    27    28    29    30    31     0\u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; mo = 2\r\n \u0026gt;\u0026gt; yr = 2015\r\n \u0026gt;\u0026gt; momat = makeCalendar(mo,yr)\u003c/pre\u003e\u003cpre\u003e     1     2     3     4     5     6     7\r\n     8     9    10    11    12    13    14\r\n    15    16    17    18    19    20    21\r\n    22    23    24    25    26    27    28\u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; mo = 10\r\n \u0026gt;\u0026gt; yr = 2010\r\n \u0026gt;\u0026gt; momat = makeCalendar(mo,yr)\u003c/pre\u003e\u003cpre\u003e     0     0     0     0     0     1     2\r\n     3     4     5     6     7     8     9\r\n    10    11    12    13    14    15    16\r\n    17    18    19    20    21    22    23\r\n    24    25    26    27    28    29    30\r\n    31     0     0     0     0     0     0\u003c/pre\u003e","function_template":"function momat = makeCalendar(mo,yr)\r\n  momat = 0;\r\nend","test_suite":"%%\r\n\r\nmo = 1;\r\nyr = 2014;\r\nmomat = makeCalendar(mo,yr);\r\nmomat_correct = [ ...\r\n     0     0     0     1     2     3     4\r\n     5     6     7     8     9    10    11\r\n    12    13    14    15    16    17    18\r\n    19    20    21    22    23    24    25\r\n    26    27    28    29    30    31     0];\r\nassert(isequal(momat,momat_correct)) \r\n\r\n%%\r\n\r\nmo = 2;\r\nyr = 2015;\r\nmomat = makeCalendar(mo,yr);\r\nmomat_correct = [ ...\r\n     1     2     3     4     5     6     7\r\n     8     9    10    11    12    13    14\r\n    15    16    17    18    19    20    21\r\n    22    23    24    25    26    27    28];\r\nassert(isequal(momat,momat_correct)) \r\n\r\n%%\r\n\r\nmo = 10;\r\nyr = 2010;\r\nmomat = makeCalendar(mo,yr);\r\nmomat_correct = [ ...\r\n     0     0     0     0     0     1     2\r\n     3     4     5     6     7     8     9\r\n    10    11    12    13    14    15    16\r\n    17    18    19    20    21    22    23\r\n    24    25    26    27    28    29    30\r\n    31     0     0     0     0     0     0];\r\nassert(isequal(momat,momat_correct))\r\n\r\n%%\r\n\r\nmo = 11;\r\nyr = 1972;\r\nmomat = makeCalendar(mo,yr);\r\nmomat_correct = [0 0 0 1 2 3 4;5 6 7 8 9 10 11;12 13 14 15 16 17 18;19 20 21 22 23 24 25;26 27 28 29 30 0 0];\r\n\r\nassert(isequal(momat,momat_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":7,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":161,"test_suite_updated_at":"2014-05-22T21:48:47.000Z","rescore_all_solutions":false,"group_id":31,"created_at":"2014-05-22T20:36:33.000Z","updated_at":"2026-03-03T16:29:43.000Z","published_at":"2014-05-22T20:47:34.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn a calendar matrix for the given values of month and year. Assume that Sunday is the first day of the week. The resulting calendar month will have seven columns and only as many rows (weeks) as needed to display all days of the month. Thus it might have either 4, 5, or 6 rows. Days preceding the first of the month or following the last of the month are given by zeros.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ \u003e\u003e mo = 1\\n \u003e\u003e yr = 2014\\n \u003e\u003e momat = makeCalendar(mo,yr)\\n\\n     0     0     0     1     2     3     4\\n     5     6     7     8     9    10    11\\n    12    13    14    15    16    17    18\\n    19    20    21    22    23    24    25\\n    26    27    28    29    30    31     0\\n\\n \u003e\u003e mo = 2\\n \u003e\u003e yr = 2015\\n \u003e\u003e momat = makeCalendar(mo,yr)\\n\\n     1     2     3     4     5     6     7\\n     8     9    10    11    12    13    14\\n    15    16    17    18    19    20    21\\n    22    23    24    25    26    27    28\\n\\n \u003e\u003e mo = 10\\n \u003e\u003e yr = 2010\\n \u003e\u003e momat = makeCalendar(mo,yr)\\n\\n     0     0     0     0     0     1     2\\n     3     4     5     6     7     8     9\\n    10    11    12    13    14    15    16\\n    17    18    19    20    21    22    23\\n    24    25    26    27    28    29    30\\n    31     0     0     0     0     0     0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2639,"title":"How Many Months Until It's Today Again?","description":"Given a particular date, calculate how many months must pass before that same day of the month occurs on the same day of the week.\r\n\r\nStart with 22-Oct-2014, which is a Wednesday. How many months must pass before the 22nd of the month occurs on a Wednesday again? Answer: You have to wait for six months. 22-Apr-2015 is also a Wednesday.\r\n\r\n\r\n*Example*\r\n\r\n d_in = '22-Oct-2014'\r\n wait_in_months = 6\r\n\r\n*Feature Tip*\r\n\r\nThis problem is made simpler by the \u003chttp://www.mathworks.com/help/matlab/date-and-time-operations.html DATETIME objects\u003e found in MATLAB \u003chttps://www.mathworks.com/help/matlab/release-notes.html?rntext=\u0026startrelease=R2014b\u0026endrelease=R2014b\u0026groupby=release\u0026sortby=descending Release 2014b\u003e and later.\r\n\r\n\r\n\r\n","description_html":"\u003cp\u003eGiven a particular date, calculate how many months must pass before that same day of the month occurs on the same day of the week.\u003c/p\u003e\u003cp\u003eStart with 22-Oct-2014, which is a Wednesday. How many months must pass before the 22nd of the month occurs on a Wednesday again? Answer: You have to wait for six months. 22-Apr-2015 is also a Wednesday.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e\u003c/p\u003e\u003cpre\u003e d_in = '22-Oct-2014'\r\n wait_in_months = 6\u003c/pre\u003e\u003cp\u003e\u003cb\u003eFeature Tip\u003c/b\u003e\u003c/p\u003e\u003cp\u003eThis problem is made simpler by the \u003ca href = \"http://www.mathworks.com/help/matlab/date-and-time-operations.html\"\u003eDATETIME objects\u003c/a\u003e found in MATLAB \u003ca href = \"https://www.mathworks.com/help/matlab/release-notes.html?rntext=\u0026startrelease=R2014b\u0026endrelease=R2014b\u0026groupby=release\u0026sortby=descending\"\u003eRelease 2014b\u003c/a\u003e and later.\u003c/p\u003e","function_template":"function wait_in_months = monthsUntilMatch(d_in)\r\n  wait_in_months = 0;\r\nend","test_suite":"%%\r\nd_in = '22-Oct-2014';\r\nm_correct = 6;\r\nm_test    = monthsUntilMatch(d_in);\r\nassert(isequal(m_test,m_correct))\r\n\r\n%%\r\nd_in = '2-Jul-2014';\r\nm_correct = 14;\r\nm_test    = monthsUntilMatch(d_in);\r\nassert(isequal(m_test,m_correct))\r\n\r\n%%\r\nd_in = '12-May-2011';\r\nm_correct = 8;\r\nm_test    = monthsUntilMatch(d_in);\r\nassert(isequal(m_test,m_correct))\r\n\r\n%%\r\nd_in = '14-Jul-1789';\r\nm_correct = 14;\r\nm_test    = monthsUntilMatch(d_in)\r\nassert(isequal(m_test,m_correct))\r\n\r\n%%\r\nd_in = '31-Dec-1999';\r\nm_correct = 3;\r\nm_test    = monthsUntilMatch(d_in)\r\nassert(isequal(m_test,m_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":7,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":131,"test_suite_updated_at":"2014-10-22T21:23:24.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-10-22T21:05:30.000Z","updated_at":"2026-01-05T00:04:16.000Z","published_at":"2014-10-22T21:23:24.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a particular date, calculate how many months must pass before that same day of the month occurs on the same day of the week.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eStart with 22-Oct-2014, which is a Wednesday. How many months must pass before the 22nd of the month occurs on a Wednesday again? Answer: You have to wait for six months. 22-Apr-2015 is also a Wednesday.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ d_in = '22-Oct-2014'\\n wait_in_months = 6]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eFeature Tip\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is made simpler by the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/help/matlab/date-and-time-operations.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDATETIME objects\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e found in MATLAB\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/help/matlab/release-notes.html?rntext=\u0026amp;startrelease=R2014b\u0026amp;endrelease=R2014b\u0026amp;groupby=release\u0026amp;sortby=descending\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eRelease 2014b\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and later.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45380,"title":"The End of the World","description":"given a date -- represent it in the Maya long count system.\r\n\r\n\u003chttps://en.wikipedia.org/wiki/Maya_calendar\u003e\r\n\r\n\u003chttps://maya.nmai.si.edu/calendar/maya-calendar-converter\u003e\r\n\r\nFor example,\r\n \r\n date = [2020 03 24]\r\n Maya = '13.0.7.6.10'","description_html":"\u003cp\u003egiven a date -- represent it in the Maya long count system.\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://en.wikipedia.org/wiki/Maya_calendar\"\u003ehttps://en.wikipedia.org/wiki/Maya_calendar\u003c/a\u003e\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://maya.nmai.si.edu/calendar/maya-calendar-converter\"\u003ehttps://maya.nmai.si.edu/calendar/maya-calendar-converter\u003c/a\u003e\u003c/p\u003e\u003cp\u003eFor example,\u003c/p\u003e\u003cpre\u003e date = [2020 03 24]\r\n Maya = '13.0.7.6.10'\u003c/pre\u003e","function_template":"function y = maya_cal(x)","test_suite":"%%\r\nx=[1989 03 01];\r\nassert(isequal(maya_cal(x),'12.18.15.15.4'))\r\n\r\n%%\r\nx=[1995 03 23];\r\nassert(isequal(maya_cal(x),'12.19.1.17.17'))\r\n\r\n%%\r\nx=[2005 03 23];\r\nassert(isequal(maya_cal(x),'12.19.12.2.10'))\r\n\r\n%%\r\nx=[2015 03 23];\r\nassert(isequal(maya_cal(x),'13.0.2.5.2'))\r\n\r\n%%\r\nx=[1993 02 19];\r\nassert(isequal(maya_cal(x),'12.18.19.15.15'))\r\n\r\n%%\r\nx=[2012 12 31];\r\nassert(isequal(maya_cal(x),'13.0.0.0.10'))\r\n\r\n\r\n%%\r\nx=[2112 09 17];\r\nassert(isequal(maya_cal(x),'13.5.1.3.9'))","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":55,"test_suite_updated_at":"2020-03-24T00:45:50.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-24T00:30:10.000Z","updated_at":"2025-11-21T18:25:00.000Z","published_at":"2020-03-24T00:45:50.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003egiven a date -- represent it in the Maya long count system.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Maya_calendar\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/Maya_calendar\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://maya.nmai.si.edu/calendar/maya-calendar-converter\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://maya.nmai.si.edu/calendar/maya-calendar-converter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ date = [2020 03 24]\\n Maya = '13.0.7.6.10']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":2362,"title":"What day is it?","description":"Tell me what day is it. Return the full name of the day of the week as a string.\r\n\r\ne.g. It's June 12th 2014, so your function should return 'Thursday'","description_html":"\u003cp\u003eTell me what day is it. Return the full name of the day of the week as a string.\u003c/p\u003e\u003cp\u003ee.g. It's June 12th 2014, so your function should return 'Thursday'\u003c/p\u003e","function_template":"function y = day_of_week()\r\ny = 'Friday';\r\nend","test_suite":"%%\r\ntoday = java.util.Date;\r\nc = java.util.Calendar.getInstance();\r\nc.setTime( today );\r\ndayOfWeek = c.get(java.util.Calendar.DAY_OF_WEEK);\r\nswitch dayOfWeek\r\n    case 1\r\n        dayOfWeek = 'Sunday';    \r\n    case 2\r\n        dayOfWeek = 'Monday';\r\n    case 3\r\n        dayOfWeek = 'Tuesday';\r\n    case 4\r\n        dayOfWeek = 'Wednesday';\r\n    case 5\r\n        dayOfWeek = 'Thursday';\r\n    case 6\r\n        dayOfWeek = 'Friday';\r\n    case 7\r\n        dayOfWeek = 'Saturday';\r\nend\r\nassert(strcmp(dayOfWeek,day_of_week()))","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":450,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":222,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-06-12T20:06:06.000Z","updated_at":"2026-03-12T20:06:11.000Z","published_at":"2014-06-13T14:20:59.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTell me what day is it. Return the full name of the day of the week as a string.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ee.g. It's June 12th 2014, so your function should return 'Thursday'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45328,"title":"leap year","description":"find the number of leap years within the given time interval","description_html":"\u003cp\u003efind the number of leap years within the given time interval\u003c/p\u003e","function_template":"function b = leap_count(n)\r\n  y = x;\r\nend","test_suite":"%%\r\nn = 1900:2000;\r\nassert(isequal( leap_count(n),25))\r\n%%\r\nn = 100:2000;\r\nassert(isequal( leap_count(n),461))\r\n%%\r\nn = 1600:2000;\r\nassert(isequal( leap_count(n),98))\r\n%%\r\nn = 3000;\r\nassert(isequal( leap_count(n),0))\r\n%%\r\nn = 377:467;\r\nassert(isequal( leap_count(n),22))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":84,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-02-15T07:16:33.000Z","updated_at":"2025-12-21T21:32:21.000Z","published_at":"2020-02-15T07:16:59.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003efind the number of leap years within the given time interval\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45378,"title":"Lost days","description":"Given two dates in a particular format, calculate the difference between them.\r\n","description_html":"\u003cp\u003eGiven two dates in a particular format, calculate the difference between them.\u003c/p\u003e","function_template":"function y = date_dis(a,b,c)","test_suite":"%%\r\na=[2019 2 4];\r\nb=[1992 3 6];\r\nc='yyyy-MM-dd';\r\ny=calendarDuration(26,10,29);\r\nassert(isequal(date_dis(a,b,c),y))\r\n\r\n%%\r\na=[2029 12 14];\r\nb=[1892 13 16];\r\nc='yyyy-MM-dd';\r\ny=calendarDuration(136,10,28);\r\nassert(isequal(date_dis(a,b,c),y))\r\n\r\n%%\r\na='14/11/2018';\r\nb='14/12/2009';\r\nc='dd/MM/yyyy';\r\ny=calendarDuration(8,11,0);\r\nassert(isequal(date_dis(a,b,c),y))\r\n\r\n%%\r\na='29-12-2014';\r\nb='02-01-1916';\r\nc='dd-MM-yyyy';\r\ny=calendarDuration(98,11,27);\r\nassert(isequal(date_dis(a,b,c),y))","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":61,"test_suite_updated_at":"2020-03-23T11:35:18.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-23T11:23:03.000Z","updated_at":"2025-11-21T18:07:42.000Z","published_at":"2020-03-23T11:35:18.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two dates in a particular format, calculate the difference between them.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2196,"title":"Tax Season ! How much is my salary?","description":"Tax Season! I was employed for a period from x until y in a year and I get pay check of amount z on every alternate Friday of the week starting from first Friday since I am employed. Help me find out how much did I earn during my employment period.\r\n\r\nExample\r\n\r\n x = 01-Jan-2014\r\n y = 14-Feb-2014\r\n z = $2000 (x will always be \u003cy)\r\n\r\nThis period has total 4 alternate Fridays which were my \"pay-days\", so the salary for this period was 4*2000 = %8000\r\n\r\n","description_html":"\u003cp\u003eTax Season! I was employed for a period from x until y in a year and I get pay check of amount z on every alternate Friday of the week starting from first Friday since I am employed. Help me find out how much did I earn during my employment period.\u003c/p\u003e\u003cp\u003eExample\u003c/p\u003e\u003cpre\u003e x = 01-Jan-2014\r\n y = 14-Feb-2014\r\n z = $2000 (x will always be \u0026lt;y)\u003c/pre\u003e\u003cp\u003eThis period has total 4 alternate Fridays which were my \"pay-days\", so the salary for this period was 4*2000 = %8000\u003c/p\u003e","function_template":"function salary= AllAboutMoney_Honey(x,y,z)\r\nsalary = 0;\r\nend","test_suite":"%%\r\nx = '01-Jan-2014';\r\ny = '14-Feb-2014';\r\nz = 2000;\r\nsalary = 8000;\r\nassert(isequal(AllAboutMoney_Honey(x,y,z),salary))\r\n\r\n%%\r\nx = '14-Feb-2013';\r\ny = '29-Apr-2013';\r\nz = 3599;\r\nsalary = 21594;\r\nassert(isequal(AllAboutMoney_Honey(x,y,z),salary))\r\n\r\n%%\r\nx = '01-Jan-2012';\r\ny = '31-Dec-2012';\r\nz = 500;\r\nsalary = 13000;\r\nassert(isequal(AllAboutMoney_Honey(x,y,z),salary))\r\n\r\n%%\r\nx = '13-Dec-2011';\r\ny = '28-Jan-2012';\r\nz = 654;\r\nsalary = 2616;\r\nassert(isequal(AllAboutMoney_Honey(x,y,z),salary))\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":1,"created_by":16381,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":82,"test_suite_updated_at":"2014-02-18T17:46:13.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-02-18T17:13:55.000Z","updated_at":"2026-01-05T00:12:47.000Z","published_at":"2014-02-18T17:15:43.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTax Season! I was employed for a period from x until y in a year and I get pay check of amount z on every alternate Friday of the week starting from first Friday since I am employed. Help me find out how much did I earn during my employment period.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ x = 01-Jan-2014\\n y = 14-Feb-2014\\n z = $2000 (x will always be \u003cy)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis period has total 4 alternate Fridays which were my \\\"pay-days\\\", so the salary for this period was 4*2000 = %8000\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2336,"title":"Calendar Matrix","description":"Return a calendar matrix for the given values of month and year. Assume that Sunday is the first day of the week. The resulting calendar month will have seven columns and only as many rows (weeks) as needed to display all days of the month. Thus it might have either 4, 5, or 6 rows. Days preceding the first of the month or following the last of the month are given by zeros.\r\n\r\nExamples\r\n\r\n \u003e\u003e mo = 1\r\n \u003e\u003e yr = 2014\r\n \u003e\u003e momat = makeCalendar(mo,yr)\r\n\r\n     0     0     0     1     2     3     4\r\n     5     6     7     8     9    10    11\r\n    12    13    14    15    16    17    18\r\n    19    20    21    22    23    24    25\r\n    26    27    28    29    30    31     0\r\n\r\n \u003e\u003e mo = 2\r\n \u003e\u003e yr = 2015\r\n \u003e\u003e momat = makeCalendar(mo,yr)\r\n\r\n     1     2     3     4     5     6     7\r\n     8     9    10    11    12    13    14\r\n    15    16    17    18    19    20    21\r\n    22    23    24    25    26    27    28\r\n\r\n\r\n \u003e\u003e mo = 10\r\n \u003e\u003e yr = 2010\r\n \u003e\u003e momat = makeCalendar(mo,yr)\r\n\r\n     0     0     0     0     0     1     2\r\n     3     4     5     6     7     8     9\r\n    10    11    12    13    14    15    16\r\n    17    18    19    20    21    22    23\r\n    24    25    26    27    28    29    30\r\n    31     0     0     0     0     0     0","description_html":"\u003cp\u003eReturn a calendar matrix for the given values of month and year. Assume that Sunday is the first day of the week. The resulting calendar month will have seven columns and only as many rows (weeks) as needed to display all days of the month. Thus it might have either 4, 5, or 6 rows. Days preceding the first of the month or following the last of the month are given by zeros.\u003c/p\u003e\u003cp\u003eExamples\u003c/p\u003e\u003cpre\u003e \u0026gt;\u0026gt; mo = 1\r\n \u0026gt;\u0026gt; yr = 2014\r\n \u0026gt;\u0026gt; momat = makeCalendar(mo,yr)\u003c/pre\u003e\u003cpre\u003e     0     0     0     1     2     3     4\r\n     5     6     7     8     9    10    11\r\n    12    13    14    15    16    17    18\r\n    19    20    21    22    23    24    25\r\n    26    27    28    29    30    31     0\u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; mo = 2\r\n \u0026gt;\u0026gt; yr = 2015\r\n \u0026gt;\u0026gt; momat = makeCalendar(mo,yr)\u003c/pre\u003e\u003cpre\u003e     1     2     3     4     5     6     7\r\n     8     9    10    11    12    13    14\r\n    15    16    17    18    19    20    21\r\n    22    23    24    25    26    27    28\u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; mo = 10\r\n \u0026gt;\u0026gt; yr = 2010\r\n \u0026gt;\u0026gt; momat = makeCalendar(mo,yr)\u003c/pre\u003e\u003cpre\u003e     0     0     0     0     0     1     2\r\n     3     4     5     6     7     8     9\r\n    10    11    12    13    14    15    16\r\n    17    18    19    20    21    22    23\r\n    24    25    26    27    28    29    30\r\n    31     0     0     0     0     0     0\u003c/pre\u003e","function_template":"function momat = makeCalendar(mo,yr)\r\n  momat = 0;\r\nend","test_suite":"%%\r\n\r\nmo = 1;\r\nyr = 2014;\r\nmomat = makeCalendar(mo,yr);\r\nmomat_correct = [ ...\r\n     0     0     0     1     2     3     4\r\n     5     6     7     8     9    10    11\r\n    12    13    14    15    16    17    18\r\n    19    20    21    22    23    24    25\r\n    26    27    28    29    30    31     0];\r\nassert(isequal(momat,momat_correct)) \r\n\r\n%%\r\n\r\nmo = 2;\r\nyr = 2015;\r\nmomat = makeCalendar(mo,yr);\r\nmomat_correct = [ ...\r\n     1     2     3     4     5     6     7\r\n     8     9    10    11    12    13    14\r\n    15    16    17    18    19    20    21\r\n    22    23    24    25    26    27    28];\r\nassert(isequal(momat,momat_correct)) \r\n\r\n%%\r\n\r\nmo = 10;\r\nyr = 2010;\r\nmomat = makeCalendar(mo,yr);\r\nmomat_correct = [ ...\r\n     0     0     0     0     0     1     2\r\n     3     4     5     6     7     8     9\r\n    10    11    12    13    14    15    16\r\n    17    18    19    20    21    22    23\r\n    24    25    26    27    28    29    30\r\n    31     0     0     0     0     0     0];\r\nassert(isequal(momat,momat_correct))\r\n\r\n%%\r\n\r\nmo = 11;\r\nyr = 1972;\r\nmomat = makeCalendar(mo,yr);\r\nmomat_correct = [0 0 0 1 2 3 4;5 6 7 8 9 10 11;12 13 14 15 16 17 18;19 20 21 22 23 24 25;26 27 28 29 30 0 0];\r\n\r\nassert(isequal(momat,momat_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":7,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":161,"test_suite_updated_at":"2014-05-22T21:48:47.000Z","rescore_all_solutions":false,"group_id":31,"created_at":"2014-05-22T20:36:33.000Z","updated_at":"2026-03-03T16:29:43.000Z","published_at":"2014-05-22T20:47:34.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn a calendar matrix for the given values of month and year. Assume that Sunday is the first day of the week. The resulting calendar month will have seven columns and only as many rows (weeks) as needed to display all days of the month. Thus it might have either 4, 5, or 6 rows. Days preceding the first of the month or following the last of the month are given by zeros.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ \u003e\u003e mo = 1\\n \u003e\u003e yr = 2014\\n \u003e\u003e momat = makeCalendar(mo,yr)\\n\\n     0     0     0     1     2     3     4\\n     5     6     7     8     9    10    11\\n    12    13    14    15    16    17    18\\n    19    20    21    22    23    24    25\\n    26    27    28    29    30    31     0\\n\\n \u003e\u003e mo = 2\\n \u003e\u003e yr = 2015\\n \u003e\u003e momat = makeCalendar(mo,yr)\\n\\n     1     2     3     4     5     6     7\\n     8     9    10    11    12    13    14\\n    15    16    17    18    19    20    21\\n    22    23    24    25    26    27    28\\n\\n \u003e\u003e mo = 10\\n \u003e\u003e yr = 2010\\n \u003e\u003e momat = makeCalendar(mo,yr)\\n\\n     0     0     0     0     0     1     2\\n     3     4     5     6     7     8     9\\n    10    11    12    13    14    15    16\\n    17    18    19    20    21    22    23\\n    24    25    26    27    28    29    30\\n    31     0     0     0     0     0     0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2639,"title":"How Many Months Until It's Today Again?","description":"Given a particular date, calculate how many months must pass before that same day of the month occurs on the same day of the week.\r\n\r\nStart with 22-Oct-2014, which is a Wednesday. How many months must pass before the 22nd of the month occurs on a Wednesday again? Answer: You have to wait for six months. 22-Apr-2015 is also a Wednesday.\r\n\r\n\r\n*Example*\r\n\r\n d_in = '22-Oct-2014'\r\n wait_in_months = 6\r\n\r\n*Feature Tip*\r\n\r\nThis problem is made simpler by the \u003chttp://www.mathworks.com/help/matlab/date-and-time-operations.html DATETIME objects\u003e found in MATLAB \u003chttps://www.mathworks.com/help/matlab/release-notes.html?rntext=\u0026startrelease=R2014b\u0026endrelease=R2014b\u0026groupby=release\u0026sortby=descending Release 2014b\u003e and later.\r\n\r\n\r\n\r\n","description_html":"\u003cp\u003eGiven a particular date, calculate how many months must pass before that same day of the month occurs on the same day of the week.\u003c/p\u003e\u003cp\u003eStart with 22-Oct-2014, which is a Wednesday. How many months must pass before the 22nd of the month occurs on a Wednesday again? Answer: You have to wait for six months. 22-Apr-2015 is also a Wednesday.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e\u003c/p\u003e\u003cpre\u003e d_in = '22-Oct-2014'\r\n wait_in_months = 6\u003c/pre\u003e\u003cp\u003e\u003cb\u003eFeature Tip\u003c/b\u003e\u003c/p\u003e\u003cp\u003eThis problem is made simpler by the \u003ca href = \"http://www.mathworks.com/help/matlab/date-and-time-operations.html\"\u003eDATETIME objects\u003c/a\u003e found in MATLAB \u003ca href = \"https://www.mathworks.com/help/matlab/release-notes.html?rntext=\u0026startrelease=R2014b\u0026endrelease=R2014b\u0026groupby=release\u0026sortby=descending\"\u003eRelease 2014b\u003c/a\u003e and later.\u003c/p\u003e","function_template":"function wait_in_months = monthsUntilMatch(d_in)\r\n  wait_in_months = 0;\r\nend","test_suite":"%%\r\nd_in = '22-Oct-2014';\r\nm_correct = 6;\r\nm_test    = monthsUntilMatch(d_in);\r\nassert(isequal(m_test,m_correct))\r\n\r\n%%\r\nd_in = '2-Jul-2014';\r\nm_correct = 14;\r\nm_test    = monthsUntilMatch(d_in);\r\nassert(isequal(m_test,m_correct))\r\n\r\n%%\r\nd_in = '12-May-2011';\r\nm_correct = 8;\r\nm_test    = monthsUntilMatch(d_in);\r\nassert(isequal(m_test,m_correct))\r\n\r\n%%\r\nd_in = '14-Jul-1789';\r\nm_correct = 14;\r\nm_test    = monthsUntilMatch(d_in)\r\nassert(isequal(m_test,m_correct))\r\n\r\n%%\r\nd_in = '31-Dec-1999';\r\nm_correct = 3;\r\nm_test    = monthsUntilMatch(d_in)\r\nassert(isequal(m_test,m_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":7,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":131,"test_suite_updated_at":"2014-10-22T21:23:24.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-10-22T21:05:30.000Z","updated_at":"2026-01-05T00:04:16.000Z","published_at":"2014-10-22T21:23:24.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a particular date, calculate how many months must pass before that same day of the month occurs on the same day of the week.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eStart with 22-Oct-2014, which is a Wednesday. How many months must pass before the 22nd of the month occurs on a Wednesday again? Answer: You have to wait for six months. 22-Apr-2015 is also a Wednesday.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ d_in = '22-Oct-2014'\\n wait_in_months = 6]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eFeature Tip\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is made simpler by the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/help/matlab/date-and-time-operations.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDATETIME objects\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e found in MATLAB\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/help/matlab/release-notes.html?rntext=\u0026amp;startrelease=R2014b\u0026amp;endrelease=R2014b\u0026amp;groupby=release\u0026amp;sortby=descending\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eRelease 2014b\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and later.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45380,"title":"The End of the World","description":"given a date -- represent it in the Maya long count system.\r\n\r\n\u003chttps://en.wikipedia.org/wiki/Maya_calendar\u003e\r\n\r\n\u003chttps://maya.nmai.si.edu/calendar/maya-calendar-converter\u003e\r\n\r\nFor example,\r\n \r\n date = [2020 03 24]\r\n Maya = '13.0.7.6.10'","description_html":"\u003cp\u003egiven a date -- represent it in the Maya long count system.\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://en.wikipedia.org/wiki/Maya_calendar\"\u003ehttps://en.wikipedia.org/wiki/Maya_calendar\u003c/a\u003e\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://maya.nmai.si.edu/calendar/maya-calendar-converter\"\u003ehttps://maya.nmai.si.edu/calendar/maya-calendar-converter\u003c/a\u003e\u003c/p\u003e\u003cp\u003eFor example,\u003c/p\u003e\u003cpre\u003e date = [2020 03 24]\r\n Maya = '13.0.7.6.10'\u003c/pre\u003e","function_template":"function y = maya_cal(x)","test_suite":"%%\r\nx=[1989 03 01];\r\nassert(isequal(maya_cal(x),'12.18.15.15.4'))\r\n\r\n%%\r\nx=[1995 03 23];\r\nassert(isequal(maya_cal(x),'12.19.1.17.17'))\r\n\r\n%%\r\nx=[2005 03 23];\r\nassert(isequal(maya_cal(x),'12.19.12.2.10'))\r\n\r\n%%\r\nx=[2015 03 23];\r\nassert(isequal(maya_cal(x),'13.0.2.5.2'))\r\n\r\n%%\r\nx=[1993 02 19];\r\nassert(isequal(maya_cal(x),'12.18.19.15.15'))\r\n\r\n%%\r\nx=[2012 12 31];\r\nassert(isequal(maya_cal(x),'13.0.0.0.10'))\r\n\r\n\r\n%%\r\nx=[2112 09 17];\r\nassert(isequal(maya_cal(x),'13.5.1.3.9'))","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":55,"test_suite_updated_at":"2020-03-24T00:45:50.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-24T00:30:10.000Z","updated_at":"2025-11-21T18:25:00.000Z","published_at":"2020-03-24T00:45:50.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003egiven a date -- represent it in the Maya long count system.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Maya_calendar\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/Maya_calendar\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://maya.nmai.si.edu/calendar/maya-calendar-converter\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://maya.nmai.si.edu/calendar/maya-calendar-converter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ date = [2020 03 24]\\n Maya = '13.0.7.6.10']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"calendar\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"calendar\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"calendar\"","","\"","calendar","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f10482b7b40\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f10482b7aa0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f10482b70a0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f10482b7e60\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f10482b7dc0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f10482b7d20\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f10482b7c80\u003e":"tag:\"calendar\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f10482b7c80\u003e":"tag:\"calendar\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"calendar\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"calendar\"","","\"","calendar","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f10482b7b40\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f10482b7aa0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f10482b70a0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f10482b7e60\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f10482b7dc0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f10482b7d20\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f10482b7c80\u003e":"tag:\"calendar\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f10482b7c80\u003e":"tag:\"calendar\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":2362,"difficulty_rating":"easy-medium"},{"id":45328,"difficulty_rating":"easy-medium"},{"id":45378,"difficulty_rating":"easy-medium"},{"id":2196,"difficulty_rating":"easy-medium"},{"id":2336,"difficulty_rating":"easy-medium"},{"id":2639,"difficulty_rating":"medium"},{"id":45380,"difficulty_rating":"medium"}]}}