{"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":44479,"title":"Friday or not","description":"I love Friday. Please tell me whether the day is Friday.\r\n\r\nDateformat is 'yyyy-mm-dd'  or 'dd-mmm-yyyy' or 'mm/dd/yyyy'.\r\n\r\nExamples;\r\n\r\ninput  D =  '2018-01-03';  % Wednesday\r\n\r\noutput y = 0\r\n\r\ninput  D =  '5-Jan-2018';  % Friday\r\n\r\noutput y = 1 \r\n\r\ninput  D =  '09/09/2019';  % Monday\r\n\r\noutput y = 0 \r\n","description_html":"\u003cp\u003eI love Friday. Please tell me whether the day is Friday.\u003c/p\u003e\u003cp\u003eDateformat is 'yyyy-mm-dd'  or 'dd-mmm-yyyy' or 'mm/dd/yyyy'.\u003c/p\u003e\u003cp\u003eExamples;\u003c/p\u003e\u003cp\u003einput  D =  '2018-01-03';  % Wednesday\u003c/p\u003e\u003cp\u003eoutput y = 0\u003c/p\u003e\u003cp\u003einput  D =  '5-Jan-2018';  % Friday\u003c/p\u003e\u003cp\u003eoutput y = 1\u003c/p\u003e\u003cp\u003einput  D =  '09/09/2019';  % Monday\u003c/p\u003e\u003cp\u003eoutput y = 0\u003c/p\u003e","function_template":"function y = Fri(D)\r\n  y = 1;\r\nend","test_suite":"%% 1\r\nD = '5-Jan-2018';\r\ny_correct = 1;\r\nassert(isequal(Fri(D),y_correct))\r\n%% 2\r\nD = '09/09/2019';\r\ny_correct = 0;\r\nassert(isequal(Fri(D),y_correct))\r\n%% 3\r\nD = '2000-01-01';\r\ny_correct = 0;\r\nassert(isequal(Fri(D),y_correct))\r\n%% 4\r\nD = '2020-12-25';\r\ny_correct = 1;\r\nassert(isequal(Fri(D),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":137687,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":96,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-01-04T06:58:08.000Z","updated_at":"2026-03-16T12:05:20.000Z","published_at":"2018-01-04T07:28:06.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\u003eI love Friday. Please tell me whether the day is Friday.\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\u003eDateformat is 'yyyy-mm-dd' or 'dd-mmm-yyyy' or 'mm/dd/yyyy'.\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\u003eExamples;\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\u003einput D = '2018-01-03'; % 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eoutput y = 0\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\u003einput D = '5-Jan-2018'; % Friday\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\u003eoutput y = 1\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\u003einput D = '09/09/2019'; % Monday\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\u003eoutput y = 0\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":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":42711,"title":"Find Month \u0026 day for given day number of a year ","description":"Find Month \u0026 day for given day number of a year  (day number is any number ranging from 1 to 366)","description_html":"\u003cp\u003eFind Month \u0026 day for given day number of a year  (day number is any number ranging from 1 to 366)\u003c/p\u003e","function_template":"function vec = your_fcn_name(x)\r\n%%logic\r\nend","test_suite":"%%\r\nx = 23;\r\nvec_crt=[1 23];\r\nassert(isequal(your_fcn_name(x),vec_crt))\r\n%%\r\nx = 54;\r\nvec_crt=[2 23];\r\nassert(isequal(your_fcn_name(x),vec_crt))\r\n%%\r\nx = 231;\r\nvec_crt=[8 18];\r\nassert(isequal(your_fcn_name(x),vec_crt))\r\n%%\r\nx = 300;\r\nvec_crt=[10 26];\r\nassert(isequal(your_fcn_name(x),vec_crt))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":46868,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":96,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-01-15T06:34:44.000Z","updated_at":"2026-01-05T00:10:53.000Z","published_at":"2016-01-15T06:48:57.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 Month \u0026amp; day for given day number of a year (day number is any number ranging from 1 to 366)\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":720,"title":"Find number of days","description":"The input is two date in string format (dd-mm-yyyy)\r\n\r\nfind out the number of days between these two dates.\r\nExample:\r\n\r\ninput: '15-jan-2000' '24-may-2012'\r\n\r\n(if today is 24-may-2012)\r\n\r\noutput: 4509","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 171px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 85.5px; transform-origin: 407px 85.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 336.5px 8px; transform-origin: 336.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe input is two date in string format (dd-mm-yyyy), Find out the number of days between these two dates. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 30.5px 8px; transform-origin: 30.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample: \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 108px 8px; transform-origin: 108px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003einput: '15-jan-2000' '24-may-2012'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 79px 8px; transform-origin: 79px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e(if today is 24-may-2012)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 40px 8px; transform-origin: 40px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eoutput: 4509\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = countDays(x1,x2)\r\n","test_suite":"%%\r\nx1 = '15-jan-2000';\r\nx2 = '24-may-2012';\r\ny_correct = 4513;\r\nassert(isequal(countDays(x1,x2),y_correct))\r\n\r\n%%\r\nx1 = '15-jan-1000';\r\nx2 = '24-may-2012';\r\ny_correct =  369755;\r\nassert(isequal(countDays(x1,x2),y_correct))\r\n\r\n%%\r\nx1 = '24-may-2013';\r\nx2 = '24-may-2012';\r\ny_correct =  365;\r\nassert(isequal(countDays(x1,x2),y_correct))\r\n\r\n%%\r\nx1 = '30-apr-2021';\r\nx2 = '30-apr-2021';\r\nassert(isequal(countDays(x1,x2),0))","published":true,"deleted":false,"likes_count":0,"comments_count":7,"created_by":4320,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":238,"test_suite_updated_at":"2021-04-19T08:49:24.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2012-05-24T12:45:19.000Z","updated_at":"2026-01-05T00:22:17.000Z","published_at":"2012-05-24T12:49:18.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe input is two date in string format (dd-mm-yyyy), Find out the number of days between these two dates. \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\u003eExample: \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\u003einput: '15-jan-2000' '24-may-2012'\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\u003e(if today is 24-may-2012)\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\u003eoutput: 4509\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\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":45381,"title":"Maya long Count","description":"Given a Mayan date, calculate the number of days after the end of the last Great Cycle.\r\n\r\n\u003chttps://en.wikipedia.org/wiki/Maya_calendar\u003e\r\n\r\nNext problem \r\n\r\n\u003chttps://www.mathworks.com/matlabcentral/cody/problems/45380-the-end-of-the-world\u003e\r\n","description_html":"\u003cp\u003eGiven a Mayan date, calculate the number of days after the end of the last Great Cycle.\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\u003eNext problem\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/45380-the-end-of-the-world\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/45380-the-end-of-the-world\u003c/a\u003e\u003c/p\u003e","function_template":"function y = maya_count(x)","test_suite":"%%\r\na='0.0.0.17.19';\r\nassert(isequal(maya_count(a),359))\r\n%%\r\na='0.1.1.0.0';\r\nassert(isequal(maya_count(a),7560))\r\n%%\r\na='9.8.9.13.0';\r\nassert(isequal(maya_count(a),1357100))\r\n%%\r\na='12.8.19.13.2';\r\nassert(isequal(maya_count(a),1792702))\r\n%%\r\na='5.0.1.2.3';\r\nassert(isequal(maya_count(a),720403))\r\n","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":14,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-24T01:02:51.000Z","updated_at":"2025-11-27T19:47:09.000Z","published_at":"2020-03-24T01:02:51.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 Mayan date, calculate the number of days after the end of the last Great Cycle.\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:r\u003e\u003cw:t\u003eNext problem\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://www.mathworks.com/matlabcentral/cody/problems/45380-the-end-of-the-world\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/45380-the-end-of-the-world\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\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":1877,"title":"Friday the 13th","description":"According to superstition, lots of unpleasant stuff happens on Friday the 13th, so you might like to find the next occurence of such a date. Given a date string ('dd/mm/yyyy'), return the next occurence of a Friday the 13th. If the date string is already a Friday the 13th, return the original string. Output should be in the form of a date string ('dd/mm/yyyy').\r\n\r\nExample:\r\ndate = '13/09/2013', nextfri13(date) = '13/09'2013';\r\ndate = '15/12/2013', nextfri13(date) = '13/06/2014';\r\n\r\nAnd so on. Good luck!","description_html":"\u003cp\u003eAccording to superstition, lots of unpleasant stuff happens on Friday the 13th, so you might like to find the next occurence of such a date. Given a date string ('dd/mm/yyyy'), return the next occurence of a Friday the 13th. If the date string is already a Friday the 13th, return the original string. Output should be in the form of a date string ('dd/mm/yyyy').\u003c/p\u003e\u003cp\u003eExample:\r\ndate = '13/09/2013', nextfri13(date) = '13/09'2013';\r\ndate = '15/12/2013', nextfri13(date) = '13/06/2014';\u003c/p\u003e\u003cp\u003eAnd so on. Good luck!\u003c/p\u003e","function_template":"function y = nextfri13(date)\r\n  y = x;\r\nend","test_suite":"%%\r\ndate = '13/09/2013';\r\ny_correct = '13/09/2013';\r\nassert(isequal(nextfri13(date),y_correct))\r\n%%\r\ndate = '15/09/2013';\r\ny_correct = '13/12/2013';\r\nassert(isequal(nextfri13(date),y_correct))\r\n%%\r\ndate = '17/12/2013';\r\ny_correct = '13/06/2014';\r\nassert(isequal(nextfri13(date),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":16311,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":71,"test_suite_updated_at":"2013-09-17T12:01:39.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-16T07:58:38.000Z","updated_at":"2026-04-01T09:51:48.000Z","published_at":"2013-09-16T07:59:41.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\u003eAccording to superstition, lots of unpleasant stuff happens on Friday the 13th, so you might like to find the next occurence of such a date. Given a date string ('dd/mm/yyyy'), return the next occurence of a Friday the 13th. If the date string is already a Friday the 13th, return the original string. Output should be in the form of a date string ('dd/mm/yyyy').\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\u003eExample: date = '13/09/2013', nextfri13(date) = '13/09'2013'; date = '15/12/2013', nextfri13(date) = '13/06/2014';\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\u003eAnd so on. Good luck!\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":45365,"title":"Count the days","description":"Count the occurrence of a particular day (e.g. Monday) for a given duration.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 21px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 10.5px; transform-origin: 407px 10.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 239px 8px; transform-origin: 239px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCount the occurrence of a particular day (e.g. Monday) for a given duration.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = count_days_2(year,day)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(count_days_2([2010:2020],'Fri'),574))\r\n%%\r\nassert(isequal(count_days_2([1910:2020],'Sat'),5792))\r\n%%\r\nassert(isequal( count_days_2([1942:1947],'Sun'),313))\r\n%%\r\nassert(isequal(count_days_2([1899:1912],'Wed'),730))\r\n%%\r\nassert(isequal(count_days_2([1798:1902],'Sun'),5478))\r\n%%\r\nassert(isequal(count_days_2(2012,'Mon'),53))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":65,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-15T19:12:07.000Z","updated_at":"2025-12-14T15:43:27.000Z","published_at":"2020-03-15T19:12:33.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCount the occurrence of a particular day (e.g. Monday) for a given duration.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":216,"title":"Is this date a palindrome?emordnilap a etad siht sI","description":"Take a MATLAB date number as input, and return true if the date is a palindrome, false if the date is not a palindrome.  A date number is a scalar double representing the decimal days since Jan. 1, 0000 (type \"help datenum\").\r\n\r\nThe date shall be considered a palindrome if the \"mmddyy\" form of the date is a palindrome with leading zeros removed from months and days.  Thus, a date number of 706076 corresponds to March 3, 1933, which can be written 03/03/33.  Then the leading zeros are removed to get \"3333\" --\u003e true.  Date number 695118 corresponds to March 3, 1903, i.e. \"030303\" which reduces to \"3303\" --\u003e false.","description_html":"\u003cp\u003eTake a MATLAB date number as input, and return true if the date is a palindrome, false if the date is not a palindrome.  A date number is a scalar double representing the decimal days since Jan. 1, 0000 (type \"help datenum\").\u003c/p\u003e\u003cp\u003eThe date shall be considered a palindrome if the \"mmddyy\" form of the date is a palindrome with leading zeros removed from months and days.  Thus, a date number of 706076 corresponds to March 3, 1933, which can be written 03/03/33.  Then the leading zeros are removed to get \"3333\" --\u003e true.  Date number 695118 corresponds to March 3, 1903, i.e. \"030303\" which reduces to \"3303\" --\u003e false.\u003c/p\u003e","function_template":"function tf = isPalindrome(d)\r\n  tf = false;\r\nend","test_suite":"%%\r\nd = datenum('01-Jan-2011 02:02:02',0);\r\ntf = true;\r\nassert(isequal(isPalindrome(d),tf))\r\n\r\n%%\r\nd = datenum('02/01/12',2);\r\ntf = true;\r\nassert(isequal(isPalindrome(d),tf))\r\n\r\n%%\r\nd = datenum('12-Nov-1943',1);\r\ntf = false;\r\nassert(isequal(isPalindrome(d),tf))\r\n\r\n%%\r\nd = datenum('10/10/01',2);\r\ntf = false;\r\nassert(isequal(isPalindrome(d),tf))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":80,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":90,"test_suite_updated_at":"2018-08-30T16:48:29.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-01T16:08:32.000Z","updated_at":"2026-01-05T00:09:20.000Z","published_at":"2012-02-01T23:06:32.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\u003eTake a MATLAB date number as input, and return true if the date is a palindrome, false if the date is not a palindrome. A date number is a scalar double representing the decimal days since Jan. 1, 0000 (type \\\"help datenum\\\").\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\u003eThe date shall be considered a palindrome if the \\\"mmddyy\\\" form of the date is a palindrome with leading zeros removed from months and days. Thus, a date number of 706076 corresponds to March 3, 1933, which can be written 03/03/33. Then the leading zeros are removed to get \\\"3333\\\" --\u003e true. Date number 695118 corresponds to March 3, 1903, i.e. \\\"030303\\\" which reduces to \\\"3303\\\" --\u003e false.\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":2483,"title":"How long until the weekend?","description":"Write a function a that takes a date vector as an input and returns the number of hours until the weekend begins.  The beginning of the weekend is defined as 5:00 PM on Friday.  For example\r\n\r\n  input=[ 2014 08 04 08 00 00]\r\n  weekend(input) = 105\r\n\r\n  input=[ 2014 08 08 16 30 00]\r\n  weekend(input) = 0.5\r\n\r\nstr2num and other cheat functions are not allowed.","description_html":"\u003cp\u003eWrite a function a that takes a date vector as an input and returns the number of hours until the weekend begins.  The beginning of the weekend is defined as 5:00 PM on Friday.  For example\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003einput=[ 2014 08 04 08 00 00]\r\nweekend(input) = 105\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003einput=[ 2014 08 08 16 30 00]\r\nweekend(input) = 0.5\r\n\u003c/pre\u003e\u003cp\u003estr2num and other cheat functions are not allowed.\u003c/p\u003e","function_template":"function y = weekend(x)\r\n  y = x;\r\nend","test_suite":"%%\r\n%%\r\n% It's going to be a long week\r\na = [2014 8 4 08 00 0];\r\nweekend(a)\r\nb = 105;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n\r\n%%\r\na = [2014 08 05 10 23 34];\r\nweekend(a)\r\nb=78.607222;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n\r\n%%\r\n% Half way there\r\na = [2014 08 06 13 39 15];\r\nb = 51.3458333;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n\r\n%%\r\na = [2014 08 07 23 12 41];\r\nb = 17.788611;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n%%\r\n% Counting down the minutes\r\na = [2014 08 08 16 31 59];\r\nb = 0.466944;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n%%\r\n\r\na = [2013 08 29 15 59 10];\r\nb = 25.013888;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n%%\r\na = [2013 12 30 09 05 9];\r\nb = 103.914166;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n%%\r\na = [2012 02 27 10 32 33];\r\nb = 102.457500;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n\r\n\r\n%%\r\n% Prohibited functions.  List may be added to if more cheats arise\r\nt=evalc('type weekend.m');\r\nbadwords={'str2num'};\r\nassert(~any(cellfun(@(y) any(strfind(t,y)),badwords)));\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":18156,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":75,"test_suite_updated_at":"2014-08-07T12:18:26.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-08-04T19:26:18.000Z","updated_at":"2026-01-06T07:27:25.000Z","published_at":"2014-08-04T19:36:09.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\u003eWrite a function a that takes a date vector as an input and returns the number of hours until the weekend begins. The beginning of the weekend is defined as 5:00 PM on Friday. For 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[input=[ 2014 08 04 08 00 00]\\nweekend(input) = 105\\n\\ninput=[ 2014 08 08 16 30 00]\\nweekend(input) = 0.5]]\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\u003estr2num and other cheat functions are not allowed.\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":2524,"title":"weekday and month ","description":"Given a year and a weekday, determine how many months of that year had five of those weekdays. It is kind of easy to find.\r\nExample:\r\ny = 2014\r\nd = 'Sun'\r\n\r\nresult = 4","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 163.733px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 81.8667px; transform-origin: 407px 81.8667px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 237.5px 8px; transform-origin: 237.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a year and a weekday, determine how many months of that year had \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 13.5px 8px; transform-origin: 13.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003efive\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 125px 8px; transform-origin: 125px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e of those weekdays. It is kind of easy to find.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 32px 8.5px; tab-size: 4; transform-origin: 32px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ey = 2014\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 36px 8.5px; tab-size: 4; transform-origin: 36px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 16px 8.5px; transform-origin: 16px 8.5px; \"\u003ed = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 20px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 20px 8.5px; \"\u003e'Sun'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 8.5px; tab-size: 4; transform-origin: 0px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 40px 8.5px; tab-size: 4; transform-origin: 40px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eresult = 4\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = dd(year,day)\r\n  y = x;\r\nend","test_suite":"%%\r\nyear = 2014;\r\nday = 'Sun'\r\ny_correct = 4;\r\nassert(isequal(dd(year,day),y_correct))\r\n\r\n%%\r\nyear = 2014;\r\nday = 'Wed'\r\ny_correct = 5;\r\nassert(isequal(dd(year,day),y_correct))\r\n\r\n%%\r\nyear = 2025;\r\nday = 'Mon'\r\ny_correct = 4;\r\nassert(isequal(dd(year,day),y_correct))\r\n\r\n%%\r\nyear = 1999;\r\nday = 'Fri'\r\ny_correct = 5;\r\nassert(isequal(dd(year,day),y_correct))\r\n\r\n%%\r\nyear = 2020;\r\nday = 'Thu'\r\ny_correct = 5;\r\nassert(isequal(dd(year,day),y_correct))\r\n\r\n%%\r\nyear = 2000;\r\nday = 'Sat'\r\ny_correct = 5;\r\nassert(isequal(dd(year,day),y_correct))\r\n\r\n%%\r\nyear = 2022;\r\nday = 'Tue'\r\ny_correct = 4;\r\nassert(isequal(dd(year,day),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":17203,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":71,"test_suite_updated_at":"2022-01-28T09:58:21.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-08-20T10:55:40.000Z","updated_at":"2026-01-05T00:00:24.000Z","published_at":"2014-08-20T10:55:40.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a year and a weekday, determine how many months of that year had \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efive\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of those weekdays. It is kind of easy to find.\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\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[y = 2014\\nd = 'Sun'\\n\\nresult = 4]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":2454,"title":"birthday on same day of week","description":"Say, Mr. X's birthday is on 20th July, 2014. It was Sunday. Determine the closest year when his birthday will again be on Sunday. In this case it is, 2025.\r\n\r\nInput is a date string representing Mr. X's birthday. Return the year as double.","description_html":"\u003cp\u003eSay, Mr. X's birthday is on 20th July, 2014. It was Sunday. Determine the closest year when his birthday will again be on Sunday. In this case it is, 2025.\u003c/p\u003e\u003cp\u003eInput is a date string representing Mr. X's birthday. Return the year as double.\u003c/p\u003e","function_template":"function [yeah] = birthDay(date)\r\n\r\n% date will be on 'mm-dd-yyyy' format","test_suite":"%%\r\n% mm-dd-yyyy format\r\n%%\r\nassert(isequal(birthDay('7-20-2014'),2025));\r\n\r\n%%\r\nassert(isequal(birthDay('5-6-2014'),2025));\r\n\r\n%%\r\nassert(isequal(birthDay('1-1-2013'),2019));\r\n\r\n%%\r\nassert(isequal(birthDay('5-1-2010'),2021));\r\n\r\n%%\r\nassert(isequal(birthDay('11-4-1989'),1995));","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":17203,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":82,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-07-20T07:31:12.000Z","updated_at":"2025-12-15T21:53:57.000Z","published_at":"2014-07-20T07:31:12.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\u003eSay, Mr. X's birthday is on 20th July, 2014. It was Sunday. Determine the closest year when his birthday will again be on Sunday. In this case it is, 2025.\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\u003eInput is a date string representing Mr. X's birthday. Return the year as double.\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\"}]}"},{"id":1039,"title":"Get an array of month-ends in a date range","description":"Create a function that would return a list of month-ends falling in a given date range. \r\nIf a start date or end date falls on a month-end, that date should be included in the output (close ended range) \r\n\r\nFor example: \r\n  \r\n  date_start = datenum('10 Nov 2010');\r\n  date_end   = datenum('10 Feb 2011');\r\n  dates_me   = month_ends(date_start, date_end); \r\n  datestr(dates_me)\r\n    \r\n  ans =\r\n    \r\n  30-Nov-2010\r\n  31-Dec-2010\r\n  31-Jan-2011\r\n\r\n  \r\n\r\n","description_html":"\u003cp\u003eCreate a function that would return a list of month-ends falling in a given date range. \r\nIf a start date or end date falls on a month-end, that date should be included in the output (close ended range)\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003edate_start = datenum('10 Nov 2010');\r\ndate_end   = datenum('10 Feb 2011');\r\ndates_me   = month_ends(date_start, date_end); \r\ndatestr(dates_me)\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eans =\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003e30-Nov-2010\r\n31-Dec-2010\r\n31-Jan-2011\r\n\u003c/pre\u003e","function_template":"function y = month_ends(date_start,date_end)\r\n  y = eomdate(date_start);\r\nend","test_suite":"%%\r\nd1 = datenum('10-Nov-2010');\r\nd2 = datenum('10-Feb-2011');\r\ny_correct = datenum({'30-Nov-2010','31-Dec-2010','31-Jan-2011'});\r\nassert(isequal(month_ends(d1,d2),y_correct))\r\n%%\r\n\r\nd1 = datenum('31-Jan-2000');\r\nd2 = datenum('10-Apr-2000');\r\ny_correct = datenum({'31-Jan-2000','29-Feb-2000','31-Mar-2000'});\r\nassert(isequal(month_ends(d1,d2),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":8363,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":117,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-11-19T15:21:20.000Z","updated_at":"2026-02-15T11:36:16.000Z","published_at":"2012-11-19T15:36:36.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\u003eCreate a function that would return a list of month-ends falling in a given date range. If a start date or end date falls on a month-end, that date should be included in the output (close ended range)\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_start = datenum('10 Nov 2010');\\ndate_end   = datenum('10 Feb 2011');\\ndates_me   = month_ends(date_start, date_end); \\ndatestr(dates_me)\\n\\nans =\\n\\n30-Nov-2010\\n31-Dec-2010\\n31-Jan-2011]]\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":45398,"title":"Seconds","description":"Given the number of seconds after 12 am, find the time in the given format (12/24).\r\nIf the format is not mentioned, use 24-hour format.\r\nFor example,\r\n sec = 120s\r\n output = '12:02:00:000 AM'","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"block-size: 127px; display: block; min-width: 0px; padding-block-start: 0px; padding-inline-start: 2px; padding-left: 2px; padding-top: 0px; perspective-origin: 408px 63.5px; transform-origin: 408px 63.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 256.308px 8px; transform-origin: 256.308px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven the number of seconds after 12 am, find the time in the given format (12/24).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 155.567px 8px; transform-origin: 155.567px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf the format is not mentioned, use 24-hour format.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 40.8417px 8px; transform-origin: 40.8417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor example,\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 36px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 404px 18px; transform-origin: 404px 18px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 18px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; line-height: 18px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 9px; text-wrap-mode: nowrap; transform-origin: 404px 9px; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(33, 33, 33); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(33, 33, 33); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(33, 33, 33); border-left-style: none; border-left-width: 0px; border-right-color: rgb(33, 33, 33); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 42.35px 8.5px; tab-size: 4; transform-origin: 42.35px 8.5px; unicode-bidi: normal; white-space-collapse: preserve; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e sec = 120s\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 18px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; line-height: 18px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 9px; text-wrap-mode: nowrap; transform-origin: 404px 9px; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(33, 33, 33); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(33, 33, 33); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(33, 33, 33); border-left-style: none; border-left-width: 0px; border-right-color: rgb(33, 33, 33); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 103.95px 8.5px; tab-size: 4; transform-origin: 103.95px 8.5px; unicode-bidi: normal; white-space-collapse: preserve; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 38.5px 8.5px; transform-origin: 38.5px 8.5px; \"\u003e output = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(133, 22, 209); border-block-start-color: rgb(133, 22, 209); border-bottom-color: rgb(133, 22, 209); border-inline-end-color: rgb(133, 22, 209); border-inline-start-color: rgb(133, 22, 209); border-left-color: rgb(133, 22, 209); border-right-color: rgb(133, 22, 209); border-top-color: rgb(133, 22, 209); caret-color: rgb(133, 22, 209); color: rgb(133, 22, 209); column-rule-color: rgb(133, 22, 209); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(133, 22, 209); perspective-origin: 65.45px 8.5px; text-decoration-color: rgb(133, 22, 209); text-emphasis-color: rgb(133, 22, 209); transform-origin: 65.45px 8.5px; \"\u003e'12:02:00:000 AM'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function t = sec_time(x,format)\r\n\r\nend","test_suite":"%%\r\nassert(isequal(sec_time(12,'12'),'12:00:12:000 AM'))\r\n%%\r\nassert(isequal(sec_time(1200),'00:20:00:000'))\r\n%%\r\nassert(isequal(sec_time(12000,'24'),'03:20:00:000'))\r\n%%\r\nassert(isequal(sec_time(22000.34,'24'),'06:06:40:340'))\r\n%%\r\nassert(isequal(sec_time(88000.34),'00:26:40:340'))\r\n%%\r\nassert(isequal(sec_time(56734,'12'),' 3:45:34:000 PM'))\r\n%%\r\nassert(isequal(sec_time(556734,'12'),'10:38:54:000 AM'))\r\n%%\r\nassert(isequal(sec_time(.999,'12'),'12:00:00:999 AM'))\r\n%%\r\n%Added by Dyuman Joshi, 31/12/2025\r\n%to test against hard-coded solutions\r\nfiletext = fileread('sec_time.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp ''') || ...\r\n          contains(filetext, 'switch') || contains(filetext, '.34') || contains(filetext, '.999'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":363598,"edited_by":223089,"edited_at":"2025-12-31T11:13:00.000Z","deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2025-12-31T11:13:00.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-29T22:43:56.000Z","updated_at":"2025-12-31T11:13:05.000Z","published_at":"2020-03-29T22:43:56.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven the number of seconds after 12 am, find the time in the given format (12/24).\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\u003eIf the format is not mentioned, use 24-hour format.\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\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[ sec = 120s\\n output = '12:02:00:000 AM']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":44479,"title":"Friday or not","description":"I love Friday. Please tell me whether the day is Friday.\r\n\r\nDateformat is 'yyyy-mm-dd'  or 'dd-mmm-yyyy' or 'mm/dd/yyyy'.\r\n\r\nExamples;\r\n\r\ninput  D =  '2018-01-03';  % Wednesday\r\n\r\noutput y = 0\r\n\r\ninput  D =  '5-Jan-2018';  % Friday\r\n\r\noutput y = 1 \r\n\r\ninput  D =  '09/09/2019';  % Monday\r\n\r\noutput y = 0 \r\n","description_html":"\u003cp\u003eI love Friday. Please tell me whether the day is Friday.\u003c/p\u003e\u003cp\u003eDateformat is 'yyyy-mm-dd'  or 'dd-mmm-yyyy' or 'mm/dd/yyyy'.\u003c/p\u003e\u003cp\u003eExamples;\u003c/p\u003e\u003cp\u003einput  D =  '2018-01-03';  % Wednesday\u003c/p\u003e\u003cp\u003eoutput y = 0\u003c/p\u003e\u003cp\u003einput  D =  '5-Jan-2018';  % Friday\u003c/p\u003e\u003cp\u003eoutput y = 1\u003c/p\u003e\u003cp\u003einput  D =  '09/09/2019';  % Monday\u003c/p\u003e\u003cp\u003eoutput y = 0\u003c/p\u003e","function_template":"function y = Fri(D)\r\n  y = 1;\r\nend","test_suite":"%% 1\r\nD = '5-Jan-2018';\r\ny_correct = 1;\r\nassert(isequal(Fri(D),y_correct))\r\n%% 2\r\nD = '09/09/2019';\r\ny_correct = 0;\r\nassert(isequal(Fri(D),y_correct))\r\n%% 3\r\nD = '2000-01-01';\r\ny_correct = 0;\r\nassert(isequal(Fri(D),y_correct))\r\n%% 4\r\nD = '2020-12-25';\r\ny_correct = 1;\r\nassert(isequal(Fri(D),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":137687,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":96,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-01-04T06:58:08.000Z","updated_at":"2026-03-16T12:05:20.000Z","published_at":"2018-01-04T07:28:06.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\u003eI love Friday. Please tell me whether the day is Friday.\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\u003eDateformat is 'yyyy-mm-dd' or 'dd-mmm-yyyy' or 'mm/dd/yyyy'.\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\u003eExamples;\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\u003einput D = '2018-01-03'; % 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eoutput y = 0\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\u003einput D = '5-Jan-2018'; % Friday\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\u003eoutput y = 1\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\u003einput D = '09/09/2019'; % Monday\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\u003eoutput y = 0\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":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":42711,"title":"Find Month \u0026 day for given day number of a year ","description":"Find Month \u0026 day for given day number of a year  (day number is any number ranging from 1 to 366)","description_html":"\u003cp\u003eFind Month \u0026 day for given day number of a year  (day number is any number ranging from 1 to 366)\u003c/p\u003e","function_template":"function vec = your_fcn_name(x)\r\n%%logic\r\nend","test_suite":"%%\r\nx = 23;\r\nvec_crt=[1 23];\r\nassert(isequal(your_fcn_name(x),vec_crt))\r\n%%\r\nx = 54;\r\nvec_crt=[2 23];\r\nassert(isequal(your_fcn_name(x),vec_crt))\r\n%%\r\nx = 231;\r\nvec_crt=[8 18];\r\nassert(isequal(your_fcn_name(x),vec_crt))\r\n%%\r\nx = 300;\r\nvec_crt=[10 26];\r\nassert(isequal(your_fcn_name(x),vec_crt))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":46868,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":96,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-01-15T06:34:44.000Z","updated_at":"2026-01-05T00:10:53.000Z","published_at":"2016-01-15T06:48:57.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 Month \u0026amp; day for given day number of a year (day number is any number ranging from 1 to 366)\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":720,"title":"Find number of days","description":"The input is two date in string format (dd-mm-yyyy)\r\n\r\nfind out the number of days between these two dates.\r\nExample:\r\n\r\ninput: '15-jan-2000' '24-may-2012'\r\n\r\n(if today is 24-may-2012)\r\n\r\noutput: 4509","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 171px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 85.5px; transform-origin: 407px 85.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 336.5px 8px; transform-origin: 336.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe input is two date in string format (dd-mm-yyyy), Find out the number of days between these two dates. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 30.5px 8px; transform-origin: 30.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample: \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 108px 8px; transform-origin: 108px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003einput: '15-jan-2000' '24-may-2012'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 79px 8px; transform-origin: 79px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e(if today is 24-may-2012)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 40px 8px; transform-origin: 40px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eoutput: 4509\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = countDays(x1,x2)\r\n","test_suite":"%%\r\nx1 = '15-jan-2000';\r\nx2 = '24-may-2012';\r\ny_correct = 4513;\r\nassert(isequal(countDays(x1,x2),y_correct))\r\n\r\n%%\r\nx1 = '15-jan-1000';\r\nx2 = '24-may-2012';\r\ny_correct =  369755;\r\nassert(isequal(countDays(x1,x2),y_correct))\r\n\r\n%%\r\nx1 = '24-may-2013';\r\nx2 = '24-may-2012';\r\ny_correct =  365;\r\nassert(isequal(countDays(x1,x2),y_correct))\r\n\r\n%%\r\nx1 = '30-apr-2021';\r\nx2 = '30-apr-2021';\r\nassert(isequal(countDays(x1,x2),0))","published":true,"deleted":false,"likes_count":0,"comments_count":7,"created_by":4320,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":238,"test_suite_updated_at":"2021-04-19T08:49:24.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2012-05-24T12:45:19.000Z","updated_at":"2026-01-05T00:22:17.000Z","published_at":"2012-05-24T12:49:18.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe input is two date in string format (dd-mm-yyyy), Find out the number of days between these two dates. \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\u003eExample: \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\u003einput: '15-jan-2000' '24-may-2012'\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\u003e(if today is 24-may-2012)\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\u003eoutput: 4509\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\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":45381,"title":"Maya long Count","description":"Given a Mayan date, calculate the number of days after the end of the last Great Cycle.\r\n\r\n\u003chttps://en.wikipedia.org/wiki/Maya_calendar\u003e\r\n\r\nNext problem \r\n\r\n\u003chttps://www.mathworks.com/matlabcentral/cody/problems/45380-the-end-of-the-world\u003e\r\n","description_html":"\u003cp\u003eGiven a Mayan date, calculate the number of days after the end of the last Great Cycle.\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\u003eNext problem\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/45380-the-end-of-the-world\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/45380-the-end-of-the-world\u003c/a\u003e\u003c/p\u003e","function_template":"function y = maya_count(x)","test_suite":"%%\r\na='0.0.0.17.19';\r\nassert(isequal(maya_count(a),359))\r\n%%\r\na='0.1.1.0.0';\r\nassert(isequal(maya_count(a),7560))\r\n%%\r\na='9.8.9.13.0';\r\nassert(isequal(maya_count(a),1357100))\r\n%%\r\na='12.8.19.13.2';\r\nassert(isequal(maya_count(a),1792702))\r\n%%\r\na='5.0.1.2.3';\r\nassert(isequal(maya_count(a),720403))\r\n","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":14,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-24T01:02:51.000Z","updated_at":"2025-11-27T19:47:09.000Z","published_at":"2020-03-24T01:02:51.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 Mayan date, calculate the number of days after the end of the last Great Cycle.\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:r\u003e\u003cw:t\u003eNext problem\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://www.mathworks.com/matlabcentral/cody/problems/45380-the-end-of-the-world\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/45380-the-end-of-the-world\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\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":1877,"title":"Friday the 13th","description":"According to superstition, lots of unpleasant stuff happens on Friday the 13th, so you might like to find the next occurence of such a date. Given a date string ('dd/mm/yyyy'), return the next occurence of a Friday the 13th. If the date string is already a Friday the 13th, return the original string. Output should be in the form of a date string ('dd/mm/yyyy').\r\n\r\nExample:\r\ndate = '13/09/2013', nextfri13(date) = '13/09'2013';\r\ndate = '15/12/2013', nextfri13(date) = '13/06/2014';\r\n\r\nAnd so on. Good luck!","description_html":"\u003cp\u003eAccording to superstition, lots of unpleasant stuff happens on Friday the 13th, so you might like to find the next occurence of such a date. Given a date string ('dd/mm/yyyy'), return the next occurence of a Friday the 13th. If the date string is already a Friday the 13th, return the original string. Output should be in the form of a date string ('dd/mm/yyyy').\u003c/p\u003e\u003cp\u003eExample:\r\ndate = '13/09/2013', nextfri13(date) = '13/09'2013';\r\ndate = '15/12/2013', nextfri13(date) = '13/06/2014';\u003c/p\u003e\u003cp\u003eAnd so on. Good luck!\u003c/p\u003e","function_template":"function y = nextfri13(date)\r\n  y = x;\r\nend","test_suite":"%%\r\ndate = '13/09/2013';\r\ny_correct = '13/09/2013';\r\nassert(isequal(nextfri13(date),y_correct))\r\n%%\r\ndate = '15/09/2013';\r\ny_correct = '13/12/2013';\r\nassert(isequal(nextfri13(date),y_correct))\r\n%%\r\ndate = '17/12/2013';\r\ny_correct = '13/06/2014';\r\nassert(isequal(nextfri13(date),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":16311,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":71,"test_suite_updated_at":"2013-09-17T12:01:39.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-16T07:58:38.000Z","updated_at":"2026-04-01T09:51:48.000Z","published_at":"2013-09-16T07:59:41.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\u003eAccording to superstition, lots of unpleasant stuff happens on Friday the 13th, so you might like to find the next occurence of such a date. Given a date string ('dd/mm/yyyy'), return the next occurence of a Friday the 13th. If the date string is already a Friday the 13th, return the original string. Output should be in the form of a date string ('dd/mm/yyyy').\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\u003eExample: date = '13/09/2013', nextfri13(date) = '13/09'2013'; date = '15/12/2013', nextfri13(date) = '13/06/2014';\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\u003eAnd so on. Good luck!\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":45365,"title":"Count the days","description":"Count the occurrence of a particular day (e.g. Monday) for a given duration.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 21px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 10.5px; transform-origin: 407px 10.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 239px 8px; transform-origin: 239px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCount the occurrence of a particular day (e.g. Monday) for a given duration.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = count_days_2(year,day)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(count_days_2([2010:2020],'Fri'),574))\r\n%%\r\nassert(isequal(count_days_2([1910:2020],'Sat'),5792))\r\n%%\r\nassert(isequal( count_days_2([1942:1947],'Sun'),313))\r\n%%\r\nassert(isequal(count_days_2([1899:1912],'Wed'),730))\r\n%%\r\nassert(isequal(count_days_2([1798:1902],'Sun'),5478))\r\n%%\r\nassert(isequal(count_days_2(2012,'Mon'),53))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":65,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-15T19:12:07.000Z","updated_at":"2025-12-14T15:43:27.000Z","published_at":"2020-03-15T19:12:33.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCount the occurrence of a particular day (e.g. Monday) for a given duration.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":216,"title":"Is this date a palindrome?emordnilap a etad siht sI","description":"Take a MATLAB date number as input, and return true if the date is a palindrome, false if the date is not a palindrome.  A date number is a scalar double representing the decimal days since Jan. 1, 0000 (type \"help datenum\").\r\n\r\nThe date shall be considered a palindrome if the \"mmddyy\" form of the date is a palindrome with leading zeros removed from months and days.  Thus, a date number of 706076 corresponds to March 3, 1933, which can be written 03/03/33.  Then the leading zeros are removed to get \"3333\" --\u003e true.  Date number 695118 corresponds to March 3, 1903, i.e. \"030303\" which reduces to \"3303\" --\u003e false.","description_html":"\u003cp\u003eTake a MATLAB date number as input, and return true if the date is a palindrome, false if the date is not a palindrome.  A date number is a scalar double representing the decimal days since Jan. 1, 0000 (type \"help datenum\").\u003c/p\u003e\u003cp\u003eThe date shall be considered a palindrome if the \"mmddyy\" form of the date is a palindrome with leading zeros removed from months and days.  Thus, a date number of 706076 corresponds to March 3, 1933, which can be written 03/03/33.  Then the leading zeros are removed to get \"3333\" --\u003e true.  Date number 695118 corresponds to March 3, 1903, i.e. \"030303\" which reduces to \"3303\" --\u003e false.\u003c/p\u003e","function_template":"function tf = isPalindrome(d)\r\n  tf = false;\r\nend","test_suite":"%%\r\nd = datenum('01-Jan-2011 02:02:02',0);\r\ntf = true;\r\nassert(isequal(isPalindrome(d),tf))\r\n\r\n%%\r\nd = datenum('02/01/12',2);\r\ntf = true;\r\nassert(isequal(isPalindrome(d),tf))\r\n\r\n%%\r\nd = datenum('12-Nov-1943',1);\r\ntf = false;\r\nassert(isequal(isPalindrome(d),tf))\r\n\r\n%%\r\nd = datenum('10/10/01',2);\r\ntf = false;\r\nassert(isequal(isPalindrome(d),tf))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":80,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":90,"test_suite_updated_at":"2018-08-30T16:48:29.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-01T16:08:32.000Z","updated_at":"2026-01-05T00:09:20.000Z","published_at":"2012-02-01T23:06:32.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\u003eTake a MATLAB date number as input, and return true if the date is a palindrome, false if the date is not a palindrome. A date number is a scalar double representing the decimal days since Jan. 1, 0000 (type \\\"help datenum\\\").\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\u003eThe date shall be considered a palindrome if the \\\"mmddyy\\\" form of the date is a palindrome with leading zeros removed from months and days. Thus, a date number of 706076 corresponds to March 3, 1933, which can be written 03/03/33. Then the leading zeros are removed to get \\\"3333\\\" --\u003e true. Date number 695118 corresponds to March 3, 1903, i.e. \\\"030303\\\" which reduces to \\\"3303\\\" --\u003e false.\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":2483,"title":"How long until the weekend?","description":"Write a function a that takes a date vector as an input and returns the number of hours until the weekend begins.  The beginning of the weekend is defined as 5:00 PM on Friday.  For example\r\n\r\n  input=[ 2014 08 04 08 00 00]\r\n  weekend(input) = 105\r\n\r\n  input=[ 2014 08 08 16 30 00]\r\n  weekend(input) = 0.5\r\n\r\nstr2num and other cheat functions are not allowed.","description_html":"\u003cp\u003eWrite a function a that takes a date vector as an input and returns the number of hours until the weekend begins.  The beginning of the weekend is defined as 5:00 PM on Friday.  For example\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003einput=[ 2014 08 04 08 00 00]\r\nweekend(input) = 105\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003einput=[ 2014 08 08 16 30 00]\r\nweekend(input) = 0.5\r\n\u003c/pre\u003e\u003cp\u003estr2num and other cheat functions are not allowed.\u003c/p\u003e","function_template":"function y = weekend(x)\r\n  y = x;\r\nend","test_suite":"%%\r\n%%\r\n% It's going to be a long week\r\na = [2014 8 4 08 00 0];\r\nweekend(a)\r\nb = 105;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n\r\n%%\r\na = [2014 08 05 10 23 34];\r\nweekend(a)\r\nb=78.607222;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n\r\n%%\r\n% Half way there\r\na = [2014 08 06 13 39 15];\r\nb = 51.3458333;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n\r\n%%\r\na = [2014 08 07 23 12 41];\r\nb = 17.788611;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n%%\r\n% Counting down the minutes\r\na = [2014 08 08 16 31 59];\r\nb = 0.466944;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n%%\r\n\r\na = [2013 08 29 15 59 10];\r\nb = 25.013888;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n%%\r\na = [2013 12 30 09 05 9];\r\nb = 103.914166;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n%%\r\na = [2012 02 27 10 32 33];\r\nb = 102.457500;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n\r\n\r\n%%\r\n% Prohibited functions.  List may be added to if more cheats arise\r\nt=evalc('type weekend.m');\r\nbadwords={'str2num'};\r\nassert(~any(cellfun(@(y) any(strfind(t,y)),badwords)));\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":18156,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":75,"test_suite_updated_at":"2014-08-07T12:18:26.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-08-04T19:26:18.000Z","updated_at":"2026-01-06T07:27:25.000Z","published_at":"2014-08-04T19:36:09.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\u003eWrite a function a that takes a date vector as an input and returns the number of hours until the weekend begins. The beginning of the weekend is defined as 5:00 PM on Friday. For 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[input=[ 2014 08 04 08 00 00]\\nweekend(input) = 105\\n\\ninput=[ 2014 08 08 16 30 00]\\nweekend(input) = 0.5]]\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\u003estr2num and other cheat functions are not allowed.\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":2524,"title":"weekday and month ","description":"Given a year and a weekday, determine how many months of that year had five of those weekdays. It is kind of easy to find.\r\nExample:\r\ny = 2014\r\nd = 'Sun'\r\n\r\nresult = 4","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 163.733px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 81.8667px; transform-origin: 407px 81.8667px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 237.5px 8px; transform-origin: 237.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a year and a weekday, determine how many months of that year had \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 13.5px 8px; transform-origin: 13.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003efive\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 125px 8px; transform-origin: 125px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e of those weekdays. It is kind of easy to find.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 32px 8.5px; tab-size: 4; transform-origin: 32px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ey = 2014\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 36px 8.5px; tab-size: 4; transform-origin: 36px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 16px 8.5px; transform-origin: 16px 8.5px; \"\u003ed = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 20px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 20px 8.5px; \"\u003e'Sun'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 8.5px; tab-size: 4; transform-origin: 0px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 40px 8.5px; tab-size: 4; transform-origin: 40px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eresult = 4\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = dd(year,day)\r\n  y = x;\r\nend","test_suite":"%%\r\nyear = 2014;\r\nday = 'Sun'\r\ny_correct = 4;\r\nassert(isequal(dd(year,day),y_correct))\r\n\r\n%%\r\nyear = 2014;\r\nday = 'Wed'\r\ny_correct = 5;\r\nassert(isequal(dd(year,day),y_correct))\r\n\r\n%%\r\nyear = 2025;\r\nday = 'Mon'\r\ny_correct = 4;\r\nassert(isequal(dd(year,day),y_correct))\r\n\r\n%%\r\nyear = 1999;\r\nday = 'Fri'\r\ny_correct = 5;\r\nassert(isequal(dd(year,day),y_correct))\r\n\r\n%%\r\nyear = 2020;\r\nday = 'Thu'\r\ny_correct = 5;\r\nassert(isequal(dd(year,day),y_correct))\r\n\r\n%%\r\nyear = 2000;\r\nday = 'Sat'\r\ny_correct = 5;\r\nassert(isequal(dd(year,day),y_correct))\r\n\r\n%%\r\nyear = 2022;\r\nday = 'Tue'\r\ny_correct = 4;\r\nassert(isequal(dd(year,day),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":17203,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":71,"test_suite_updated_at":"2022-01-28T09:58:21.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-08-20T10:55:40.000Z","updated_at":"2026-01-05T00:00:24.000Z","published_at":"2014-08-20T10:55:40.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a year and a weekday, determine how many months of that year had \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efive\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of those weekdays. It is kind of easy to find.\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\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[y = 2014\\nd = 'Sun'\\n\\nresult = 4]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":2454,"title":"birthday on same day of week","description":"Say, Mr. X's birthday is on 20th July, 2014. It was Sunday. Determine the closest year when his birthday will again be on Sunday. In this case it is, 2025.\r\n\r\nInput is a date string representing Mr. X's birthday. Return the year as double.","description_html":"\u003cp\u003eSay, Mr. X's birthday is on 20th July, 2014. It was Sunday. Determine the closest year when his birthday will again be on Sunday. In this case it is, 2025.\u003c/p\u003e\u003cp\u003eInput is a date string representing Mr. X's birthday. Return the year as double.\u003c/p\u003e","function_template":"function [yeah] = birthDay(date)\r\n\r\n% date will be on 'mm-dd-yyyy' format","test_suite":"%%\r\n% mm-dd-yyyy format\r\n%%\r\nassert(isequal(birthDay('7-20-2014'),2025));\r\n\r\n%%\r\nassert(isequal(birthDay('5-6-2014'),2025));\r\n\r\n%%\r\nassert(isequal(birthDay('1-1-2013'),2019));\r\n\r\n%%\r\nassert(isequal(birthDay('5-1-2010'),2021));\r\n\r\n%%\r\nassert(isequal(birthDay('11-4-1989'),1995));","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":17203,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":82,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-07-20T07:31:12.000Z","updated_at":"2025-12-15T21:53:57.000Z","published_at":"2014-07-20T07:31:12.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\u003eSay, Mr. X's birthday is on 20th July, 2014. It was Sunday. Determine the closest year when his birthday will again be on Sunday. In this case it is, 2025.\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\u003eInput is a date string representing Mr. X's birthday. Return the year as double.\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\"}]}"},{"id":1039,"title":"Get an array of month-ends in a date range","description":"Create a function that would return a list of month-ends falling in a given date range. \r\nIf a start date or end date falls on a month-end, that date should be included in the output (close ended range) \r\n\r\nFor example: \r\n  \r\n  date_start = datenum('10 Nov 2010');\r\n  date_end   = datenum('10 Feb 2011');\r\n  dates_me   = month_ends(date_start, date_end); \r\n  datestr(dates_me)\r\n    \r\n  ans =\r\n    \r\n  30-Nov-2010\r\n  31-Dec-2010\r\n  31-Jan-2011\r\n\r\n  \r\n\r\n","description_html":"\u003cp\u003eCreate a function that would return a list of month-ends falling in a given date range. \r\nIf a start date or end date falls on a month-end, that date should be included in the output (close ended range)\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003edate_start = datenum('10 Nov 2010');\r\ndate_end   = datenum('10 Feb 2011');\r\ndates_me   = month_ends(date_start, date_end); \r\ndatestr(dates_me)\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eans =\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003e30-Nov-2010\r\n31-Dec-2010\r\n31-Jan-2011\r\n\u003c/pre\u003e","function_template":"function y = month_ends(date_start,date_end)\r\n  y = eomdate(date_start);\r\nend","test_suite":"%%\r\nd1 = datenum('10-Nov-2010');\r\nd2 = datenum('10-Feb-2011');\r\ny_correct = datenum({'30-Nov-2010','31-Dec-2010','31-Jan-2011'});\r\nassert(isequal(month_ends(d1,d2),y_correct))\r\n%%\r\n\r\nd1 = datenum('31-Jan-2000');\r\nd2 = datenum('10-Apr-2000');\r\ny_correct = datenum({'31-Jan-2000','29-Feb-2000','31-Mar-2000'});\r\nassert(isequal(month_ends(d1,d2),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":8363,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":117,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-11-19T15:21:20.000Z","updated_at":"2026-02-15T11:36:16.000Z","published_at":"2012-11-19T15:36:36.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\u003eCreate a function that would return a list of month-ends falling in a given date range. If a start date or end date falls on a month-end, that date should be included in the output (close ended range)\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_start = datenum('10 Nov 2010');\\ndate_end   = datenum('10 Feb 2011');\\ndates_me   = month_ends(date_start, date_end); \\ndatestr(dates_me)\\n\\nans =\\n\\n30-Nov-2010\\n31-Dec-2010\\n31-Jan-2011]]\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":45398,"title":"Seconds","description":"Given the number of seconds after 12 am, find the time in the given format (12/24).\r\nIf the format is not mentioned, use 24-hour format.\r\nFor example,\r\n sec = 120s\r\n output = '12:02:00:000 AM'","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"block-size: 127px; display: block; min-width: 0px; padding-block-start: 0px; padding-inline-start: 2px; padding-left: 2px; padding-top: 0px; perspective-origin: 408px 63.5px; transform-origin: 408px 63.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 256.308px 8px; transform-origin: 256.308px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven the number of seconds after 12 am, find the time in the given format (12/24).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 155.567px 8px; transform-origin: 155.567px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf the format is not mentioned, use 24-hour format.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 40.8417px 8px; transform-origin: 40.8417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor example,\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 36px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 404px 18px; transform-origin: 404px 18px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 18px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; line-height: 18px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 9px; text-wrap-mode: nowrap; transform-origin: 404px 9px; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(33, 33, 33); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(33, 33, 33); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(33, 33, 33); border-left-style: none; border-left-width: 0px; border-right-color: rgb(33, 33, 33); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 42.35px 8.5px; tab-size: 4; transform-origin: 42.35px 8.5px; unicode-bidi: normal; white-space-collapse: preserve; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e sec = 120s\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 18px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; line-height: 18px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 9px; text-wrap-mode: nowrap; transform-origin: 404px 9px; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(33, 33, 33); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(33, 33, 33); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(33, 33, 33); border-left-style: none; border-left-width: 0px; border-right-color: rgb(33, 33, 33); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 103.95px 8.5px; tab-size: 4; transform-origin: 103.95px 8.5px; unicode-bidi: normal; white-space-collapse: preserve; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 38.5px 8.5px; transform-origin: 38.5px 8.5px; \"\u003e output = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(133, 22, 209); border-block-start-color: rgb(133, 22, 209); border-bottom-color: rgb(133, 22, 209); border-inline-end-color: rgb(133, 22, 209); border-inline-start-color: rgb(133, 22, 209); border-left-color: rgb(133, 22, 209); border-right-color: rgb(133, 22, 209); border-top-color: rgb(133, 22, 209); caret-color: rgb(133, 22, 209); color: rgb(133, 22, 209); column-rule-color: rgb(133, 22, 209); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(133, 22, 209); perspective-origin: 65.45px 8.5px; text-decoration-color: rgb(133, 22, 209); text-emphasis-color: rgb(133, 22, 209); transform-origin: 65.45px 8.5px; \"\u003e'12:02:00:000 AM'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function t = sec_time(x,format)\r\n\r\nend","test_suite":"%%\r\nassert(isequal(sec_time(12,'12'),'12:00:12:000 AM'))\r\n%%\r\nassert(isequal(sec_time(1200),'00:20:00:000'))\r\n%%\r\nassert(isequal(sec_time(12000,'24'),'03:20:00:000'))\r\n%%\r\nassert(isequal(sec_time(22000.34,'24'),'06:06:40:340'))\r\n%%\r\nassert(isequal(sec_time(88000.34),'00:26:40:340'))\r\n%%\r\nassert(isequal(sec_time(56734,'12'),' 3:45:34:000 PM'))\r\n%%\r\nassert(isequal(sec_time(556734,'12'),'10:38:54:000 AM'))\r\n%%\r\nassert(isequal(sec_time(.999,'12'),'12:00:00:999 AM'))\r\n%%\r\n%Added by Dyuman Joshi, 31/12/2025\r\n%to test against hard-coded solutions\r\nfiletext = fileread('sec_time.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp ''') || ...\r\n          contains(filetext, 'switch') || contains(filetext, '.34') || contains(filetext, '.999'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":363598,"edited_by":223089,"edited_at":"2025-12-31T11:13:00.000Z","deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2025-12-31T11:13:00.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-29T22:43:56.000Z","updated_at":"2025-12-31T11:13:05.000Z","published_at":"2020-03-29T22:43:56.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven the number of seconds after 12 am, find the time in the given format (12/24).\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\u003eIf the format is not mentioned, use 24-hour format.\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\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[ sec = 120s\\n output = '12:02:00:000 AM']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"term":"tag:\"date\"","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:\"date\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"date\"","","\"","date","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f7360ddf970\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f7360ddf8d0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f7360ddf010\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f7360ddfbf0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f7360ddfb50\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f7360ddfab0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f7360ddfa10\u003e":"tag:\"date\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f7360ddfa10\u003e":"tag:\"date\""},"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:\"date\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"date\"","","\"","date","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f7360ddf970\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f7360ddf8d0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f7360ddf010\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f7360ddfbf0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f7360ddfb50\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f7360ddfab0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f7360ddfa10\u003e":"tag:\"date\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f7360ddfa10\u003e":"tag:\"date\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":44479,"difficulty_rating":"easy-medium"},{"id":2362,"difficulty_rating":"easy-medium"},{"id":42711,"difficulty_rating":"easy-medium"},{"id":45378,"difficulty_rating":"easy-medium"},{"id":720,"difficulty_rating":"easy-medium"},{"id":45381,"difficulty_rating":"easy-medium"},{"id":1877,"difficulty_rating":"easy-medium"},{"id":45365,"difficulty_rating":"easy-medium"},{"id":216,"difficulty_rating":"easy-medium"},{"id":2336,"difficulty_rating":"easy-medium"},{"id":2483,"difficulty_rating":"easy-medium"},{"id":2524,"difficulty_rating":"easy-medium"},{"id":2454,"difficulty_rating":"medium"},{"id":45380,"difficulty_rating":"medium"},{"id":1039,"difficulty_rating":"medium"},{"id":45398,"difficulty_rating":"medium-hard"}]}}