{"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":44518,"title":"Good Morning :)","description":"Just submit your solution between 05:00:00 and 10:00:00 (AM = Ante Meridiem = Before Noon).\r\n\r\n_Note : Consider Cody Server Time_\r\n\r\n\r\n*Related Challenges:*\r\n\r\n# \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44514 Happy Free Wednesday!\u003e \r\n# Happy Free 2019!\r\n# Free March!\r\n# Happy Free 15th Day of a Month!\r\n# Good Morning :)\r\n# Good Night :)\r\n# Leap Year","description_html":"\u003cp\u003eJust submit your solution between 05:00:00 and 10:00:00 (AM = Ante Meridiem = Before Noon).\u003c/p\u003e\u003cp\u003e\u003ci\u003eNote : Consider Cody Server Time\u003c/i\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eRelated Challenges:\u003c/b\u003e\u003c/p\u003e\u003col\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44514\"\u003eHappy Free Wednesday!\u003c/a\u003e\u003c/li\u003e\u003cli\u003eHappy Free 2019!\u003c/li\u003e\u003cli\u003eFree March!\u003c/li\u003e\u003cli\u003eHappy Free 15th Day of a Month!\u003c/li\u003e\u003cli\u003eGood Morning :)\u003c/li\u003e\u003cli\u003eGood Night :)\u003c/li\u003e\u003cli\u003eLeap Year\u003c/li\u003e\u003c/ol\u003e","function_template":"function y = goodMorning(x)\r\n    % If you are not sure how many hours left to 5 AM, just click submit button\r\n    if hour(datetime('now'))\u003e=5 \u0026\u0026 hour(datetime('now'))\u003c=10\r\n        disp('Good Morning! Have a Good Day!')\r\n    else\r\n        hoursTill = [4 3 2 1 0 0 0 0 0 0 18:-1:5];\r\n        disp(['Current hour is ' num2str(hour(datetime('now'))) '. You have to wait about ' num2str(hoursTill(hour(datetime('now')))) ' hours to start to solve this problem!'])\r\n    end\r\nend","test_suite":"%%\r\nx = 1;\r\ngoodMorning(x);\r\nassert(hour(datetime('now'))\u003e=5 \u0026\u0026 hour(datetime('now'))\u003c=10)","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":43,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-02-07T14:05:37.000Z","updated_at":"2026-02-10T08:13:01.000Z","published_at":"2018-02-07T14:05:37.000Z","restored_at":"2018-03-24T21:10:39.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"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\u003eJust submit your solution between 05:00:00 and 10:00:00 (AM = Ante Meridiem = Before Noon).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote : Consider Cody Server Time\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eRelated Challenges:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44514\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free Wednesday!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free 2019!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFree March!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free 15th Day of a Month!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGood Morning :)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGood Night :)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eLeap Year\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":1733,"title":"Calculate value of capacitor","description":"Given the value of resistance and time at which capacitor charges to it's 99%. calculate the value of capacitor","description_html":"\u003cp\u003eGiven the value of resistance and time at which capacitor charges to it's 99%. calculate the value of capacitor\u003c/p\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nr = 1;\r\nt = 1;\r\ny_correct = 0.20000;\r\nassert(isequal(your_fcn_name(r,t),y_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":14448,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":97,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-22T11:45:36.000Z","updated_at":"2026-03-09T20:57:20.000Z","published_at":"2013-07-22T11:45: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\",\"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 the value of resistance and time at which capacitor charges to it's 99%. calculate the value of capacitor\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":44514,"title":"Happy Free Wednesday!","description":"Just submit your solution on any Wednesday. \r\n\r\n*Related Challenges:*\r\n\r\n# Happy Free Wednesday!\r\n# Happy Free 2019!\r\n# Happy Free March!\r\n# Happy Free 15th Day of a Month!\r\n# \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44518 Good Morning :)\u003e\r\n# Good Night :)\r\n# Leap Year","description_html":"\u003cp\u003eJust submit your solution on any Wednesday.\u003c/p\u003e\u003cp\u003e\u003cb\u003eRelated Challenges:\u003c/b\u003e\u003c/p\u003e\u003col\u003e\u003cli\u003eHappy Free Wednesday!\u003c/li\u003e\u003cli\u003eHappy Free 2019!\u003c/li\u003e\u003cli\u003eHappy Free March!\u003c/li\u003e\u003cli\u003eHappy Free 15th Day of a Month!\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44518\"\u003eGood Morning :)\u003c/a\u003e\u003c/li\u003e\u003cli\u003eGood Night :)\u003c/li\u003e\u003cli\u003eLeap Year\u003c/li\u003e\u003c/ol\u003e","function_template":"function str = freeWednesday(x)\r\n    % If you're not sure how many days it's been to Wednesday, just click submit button\r\n    if weekday(datetime('today'))==4\r\n        disp('Congrats! It is a happy free Wednesday!')\r\n    else\r\n        daysTill = [3 2 1 0 6 5 4];\r\n        str =  sprintf('You have to wait %d days to solve this problem',daysTill(weekday(datetime('today'))));\r\n    end\r\nend","test_suite":"%%\r\nx = 1;\r\nfreeWednesday(x)\r\nassert(weekday(datetime('today'))==4)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":44,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-02-07T09:30:21.000Z","updated_at":"2026-02-11T11:57:28.000Z","published_at":"2018-02-07T09:30:21.000Z","restored_at":"2018-03-07T18:37:01.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"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\u003eJust submit your solution on any Wednesday.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eRelated Challenges:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free Wednesday!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free 2019!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free March!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free 15th Day of a Month!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44518\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGood Morning :)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGood Night :)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eLeap Year\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":58693,"title":"convert 24 hour time to 12 hour time ","description":"convert 24 hour time to 12 hour time \r\n\r\nInput: '13:12'\r\nOutput: '01:12 PM'\r\n\r\nInput: '06:12'\r\nOutput: '06:12 AM'","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; 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: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 201px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 100.5px; transform-origin: 407px 100.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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003econvert 24 hour time to 12 hour time \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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eInput: '13:12'\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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eOutput: '01:12 PM'\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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eInput: '06:12'\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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eOutput: '06:12 AM'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = convert2412(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx =  '13:12';\r\ny_correct = '01:12 PM';\r\nassert(isequal(convert2412(x),y_correct))\r\n\r\n\r\n%%\r\nx =   '06:13';\r\ny_correct =  '06:13 AM';\r\nassert(isequal(convert2412(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3494818,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":13,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2023-07-18T15:59:40.000Z","updated_at":"2026-02-24T11:03:05.000Z","published_at":"2023-07-18T15:59:40.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\u003econvert 24 hour time to 12 hour time \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\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: '13:12'\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: '01:12 PM'\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\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: '06:12'\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: '06:12 AM'\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":1690,"title":"Return elapsed time","description":"Write a function that returns the amount of time it takes to run the function, as measured by tic and toc. Your answer must be correct to within 5 milliseconds.\r\n\r\nBasic template is:\r\n\r\n  tic\r\n  t = timetorun()\r\n  toc","description_html":"\u003cp\u003eWrite a function that returns the amount of time it takes to run the function, as measured by tic and toc. Your answer must be correct to within 5 milliseconds.\u003c/p\u003e\u003cp\u003eBasic template is:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003etic\r\nt = timetorun()\r\ntoc\r\n\u003c/pre\u003e","function_template":"function t = timetorun()\r\n  t = [];\r\nend","test_suite":"%%\r\ntimetorun();\r\nt0 = tic;\r\npause(1)\r\nt1 = timetorun();\r\nt2 = toc(t0)-(t1+1);\r\nassert(abs(t2)\u003c5e-3)\r\n\r\n%%\r\nt0 = tic;\r\npause(1)\r\nt1 = timetorun();\r\nt2 = toc(t0)-(t1+1);\r\nassert(abs(t2)\u003c5e-3)\r\n\r\n%%\r\nt0 = tic;\r\npause(1)\r\nt1 = timetorun();\r\nt2 = toc(t0)-(t1+1);\r\nassert(abs(t2)\u003c5e-3)\r\n\r\n%%\r\nt0 = tic;\r\npause(1)\r\nt1 = timetorun();\r\nt2 = toc(t0)-(t1+1);\r\nassert(abs(t2)\u003c5e-3)\r\n\r\n%%\r\nt0 = tic;\r\npause(1)\r\nt1 = timetorun();\r\nt2 = toc(t0)-(t1+1);\r\nassert(abs(t2)\u003c5e-3)","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":4793,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":24,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-01T01:22:00.000Z","updated_at":"2026-01-03T13:48:05.000Z","published_at":"2013-07-01T01:22:00.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 that returns the amount of time it takes to run the function, as measured by tic and toc. Your answer must be correct to within 5 milliseconds.\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\u003eBasic template is:\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[tic\\nt = timetorun()\\ntoc]]\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":785,"title":"Mandelbrot Number Test [Real+Imaginary]","description":"The \u003chttp://en.wikipedia.org/wiki/Mandelbrot_set Mandelbrot Set\u003e is built around a simple iterative equation.\r\n\r\n z(1)   = c\r\n z(n+1) = z(n)^2 + c\r\n\r\nMandelbrot numbers remain bounded for n through infinity.\r\nThese numbers have a real and complex component.\r\n\r\nFor a vector of real and complex components determine if each is a Mandelbrot number.\r\n\r\nIf abs(z)\u003e2 then z will escape to infinity and is thus NOT valid.\r\n\r\n*Input:* [-2; 0.22-0.54i ; 0.25-.54i ; 0.26 ;.125+.125i; 0.25]\r\n\r\n*Output:* [1 ; 0 ; 1 ; 0 ; 1 ; 1]\r\n...Where 1 is for a Valid Mandelbrot\r\n\r\nCleve Moler has a whole chapter on the Mandelbrot set in his book Experiments with MATLAB: \u003chttp://www.mathworks.com/moler/exm/chapters/mandelbrot.pdf Chapter 10, Mandelbrot Set (PDF)\u003e\r\n\r\nProblem based upon \u003chttp://www.mathworks.com/matlabcentral/cody/problems/81-mandelbrot-numbers Cody 81: Mandelbrot Numbers\u003e","description_html":"\u003cp\u003eThe \u003ca href=\"http://en.wikipedia.org/wiki/Mandelbrot_set\"\u003eMandelbrot Set\u003c/a\u003e is built around a simple iterative equation.\u003c/p\u003e\u003cpre\u003e z(1)   = c\r\n z(n+1) = z(n)^2 + c\u003c/pre\u003e\u003cp\u003eMandelbrot numbers remain bounded for n through infinity.\r\nThese numbers have a real and complex component.\u003c/p\u003e\u003cp\u003eFor a vector of real and complex components determine if each is a Mandelbrot number.\u003c/p\u003e\u003cp\u003eIf abs(z)\u003e2 then z will escape to infinity and is thus NOT valid.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e [-2; 0.22-0.54i ; 0.25-.54i ; 0.26 ;.125+.125i; 0.25]\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e [1 ; 0 ; 1 ; 0 ; 1 ; 1]\r\n...Where 1 is for a Valid Mandelbrot\u003c/p\u003e\u003cp\u003eCleve Moler has a whole chapter on the Mandelbrot set in his book Experiments with MATLAB: \u003ca href=\"http://www.mathworks.com/moler/exm/chapters/mandelbrot.pdf\"\u003eChapter 10, Mandelbrot Set (PDF)\u003c/a\u003e\u003c/p\u003e\u003cp\u003eProblem based upon \u003ca href=\"http://www.mathworks.com/matlabcentral/cody/problems/81-mandelbrot-numbers\"\u003eCody 81: Mandelbrot Numbers\u003c/a\u003e\u003c/p\u003e","function_template":"function tf = isMandelbrot(v)\r\n  tf=abs(v)\u003c=2;\r\nend","test_suite":"%%\r\nformat long\r\n\r\nv=[-2; 0.22-0.54i ; 0.25-.54i ; 0.26 ;.125+.125i; 0.25];\r\ntf=isMandelbrot(v);\r\ntf_expected=[1 ; 0 ; 1 ; 0 ; 1 ; 1] ;\r\n\r\nassert(isequal(tf,tf_expected),sprintf('\\n%f %f %f %f %f %f',tf,tf_expected))\r\n%%\r\n\r\nv=-.25*ones(6,1)+(rand(6,1)-.5)/2+i*(rand(6,1)-.5)/2\r\n\r\n%v=[-.5-.25i;-.5+.25i;-.25i;.25i;-.25-.25i;-.25+.25i]\r\n% Bounding Cases\r\n\r\ntf=isMandelbrot(v);\r\ntf_expected=[1 ; 1 ; 1 ; 1 ; 1 ; 1] ;\r\n\r\nassert(isequal(tf,tf_expected),sprintf('\\n%f %f %f %f %f %f',tf,tf_expected))\r\n%%\r\n\r\nv=rand(6,1)-0.25\r\ntf=isMandelbrot(v);\r\n\r\ntf_expected=v\u003c=0.25; % non-imaginary range [-2.0,0.25]\r\n\r\nassert(isequal(tf,tf_expected),sprintf('\\n%f %f %f %f %f %f',v,tf,tf_expected))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":28,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-06-22T13:35:21.000Z","updated_at":"2026-03-04T14:19:08.000Z","published_at":"2012-07-05T03:42:07.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\u003eThe\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Mandelbrot_set\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMandelbrot Set\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is built around a simple iterative equation.\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[ z(1)   = c\\n z(n+1) = z(n)^2 + c]]\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\u003eMandelbrot numbers remain bounded for n through infinity. These numbers have a real and complex component.\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 a vector of real and complex components determine if each is a Mandelbrot number.\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\u003eIf abs(z)\u0026gt;2 then z will escape to infinity and is thus NOT valid.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e [-2; 0.22-0.54i ; 0.25-.54i ; 0.26 ;.125+.125i; 0.25]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e [1 ; 0 ; 1 ; 0 ; 1 ; 1] ...Where 1 is for a Valid Mandelbrot\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\u003eCleve Moler has a whole chapter on the Mandelbrot set in his book Experiments with MATLAB:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/moler/exm/chapters/mandelbrot.pdf\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eChapter 10, Mandelbrot Set (PDF)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\u003eProblem based upon\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/81-mandelbrot-numbers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody 81: Mandelbrot Numbers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":44437,"title":"How many days in a month?","description":"Return the number of days in a given month in 2017. If the input is not a valid month number, return -1.\r\n\r\nExamples:\r\n\r\n  Input: m = 1\r\n  Outpu: d = 31\r\n\r\n  Input:  m = 2\r\n  Output: d = 28\r\n\r\n  Input:  m = 13\r\n  Output: d = -1\r\n\r\nYou *cannot* use IF statements","description_html":"\u003cp\u003eReturn the number of days in a given month in 2017. If the input is not a valid month number, return -1.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInput: m = 1\r\nOutpu: d = 31\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eInput:  m = 2\r\nOutput: d = 28\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eInput:  m = 13\r\nOutput: d = -1\r\n\u003c/pre\u003e\u003cp\u003eYou \u003cb\u003ecannot\u003c/b\u003e use IF statements\u003c/p\u003e","function_template":"function d = daysInMonth(m)\r\n  d = 31;\r\nend","test_suite":"%%\r\nfiletext = fileread('daysInMonth.m');\r\nassert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')\r\nassert(isempty(strfind(filetext, 'if')),'IF statements are forbidden')\r\n\r\n%%\r\nm = 1;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 2;\r\nd_correct = 28;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 3;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 4;\r\nd_correct = 30;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 5;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 6;\r\nd_correct = 30;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 7;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 8;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 9;\r\nd_correct = 30;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 10;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 11;\r\nd_correct = 30;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 12;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 13;\r\nd_correct = -1;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = randi([-100 0]);\r\nd_correct = -1;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":140356,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":495,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-12-03T20:28:10.000Z","updated_at":"2026-04-02T12:47:30.000Z","published_at":"2017-12-03T20:28:10.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 the number of days in a given month in 2017. If the input is not a valid month number, return -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\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[Input: m = 1\\nOutpu: d = 31\\n\\nInput:  m = 2\\nOutput: d = 28\\n\\nInput:  m = 13\\nOutput: d = -1]]\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\u003eYou\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecannot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e use IF statements\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":326,"title":"Tricky timing","description":"Write a function that takes between 0.5 seconds and 0.6 seconds to run.","description_html":"\u003cp\u003eWrite a function that takes between 0.5 seconds and 0.6 seconds to run.\u003c/p\u003e","function_template":"function y=timing(x)\r\ny=0;\r\nend","test_suite":"%%\r\ntic;\r\ny=foo(1);\r\nt2=toc\r\nassert((t2\u003e.5)\u0026\u0026(t2\u003c.6))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":5,"created_by":1022,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":184,"test_suite_updated_at":"2012-02-16T05:53:51.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-16T05:53:51.000Z","updated_at":"2026-02-10T21:42:59.000Z","published_at":"2012-02-16T05:53: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\",\"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\u003eWrite a function that takes between 0.5 seconds and 0.6 seconds to run.\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":56578,"title":"Check if a year is a leap year or not","description":"Return 1 if a given year is a leap year or 0 if it is not","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; 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: none solid 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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eReturn 1 if a given year is a leap year or 0 if it is not\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 2005;\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = 1800;\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 2000;\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 2400;\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":2801458,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":31,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-11-10T13:59:55.000Z","updated_at":"2026-01-11T20:06:55.000Z","published_at":"2022-11-10T13:59:55.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\u003eReturn 1 if a given year is a leap year or 0 if it is not\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":328,"title":"Trickier Timing","description":"You solution should return control to main program only when the current time ends in either a 5 or 0 (e.g. the current seconds are 0 or a multiple of 5)","description_html":"\u003cp\u003eYou solution should return control to main program only when the current time ends in either a 5 or 0 (e.g. the current seconds are 0 or a multiple of 5)\u003c/p\u003e","function_template":"function y = timing(x)\r\n  y = x;\r\nend","test_suite":"%%\r\ny=timing(1);\r\ny = datevec(now);\r\ny=mod(round(y(6)),5);\r\nassert(isequal(y,0))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":1022,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":78,"test_suite_updated_at":"2012-02-16T13:40:18.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-16T13:40:18.000Z","updated_at":"2025-09-17T17:00:55.000Z","published_at":"2012-02-16T13:40: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\u003eYou solution should return control to main program only when the current time ends in either a 5 or 0 (e.g. the current seconds are 0 or a multiple of 5)\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":45848,"title":"What is the current time in Darwin, Australia?","description":"Traders need to track exchange calendars and trading hours in detail, and account for time zone differences and daylight savings offsets. These can be tricky in cities with half-hour and quarter-hour offset to UTC. \u003chttps://en.wikipedia.org/wiki/List_of_stock_exchange_trading_hours\u003e\r\n\r\nMATLAB comes to rescue!\r\n\u003chttps://www.mathworks.com/help/matlab/ref/datetime.html\u003e\r\n\r\nYou are given an array with UTC date and time as *[year, month, day, hour, minute]* and a char array with the name of the time zone.\r\nReturn a char array with the current date and time in the specified time zone, in the format *'MMM-dd-yyyy HH:mm'*.\r\n\r\nFor example, for inputs *[2020 6 9 21 50 0]* and *'Australia/Dawin'*, you should get *'Jun-10-2020 07:20'* in return.","description_html":"\u003cp\u003eTraders need to track exchange calendars and trading hours in detail, and account for time zone differences and daylight savings offsets. These can be tricky in cities with half-hour and quarter-hour offset to UTC. \u003ca href = \"https://en.wikipedia.org/wiki/List_of_stock_exchange_trading_hours\"\u003ehttps://en.wikipedia.org/wiki/List_of_stock_exchange_trading_hours\u003c/a\u003e\u003c/p\u003e\u003cp\u003eMATLAB comes to rescue! \u003ca href = \"https://www.mathworks.com/help/matlab/ref/datetime.html\"\u003ehttps://www.mathworks.com/help/matlab/ref/datetime.html\u003c/a\u003e\u003c/p\u003e\u003cp\u003eYou are given an array with UTC date and time as \u003cb\u003e[year, month, day, hour, minute]\u003c/b\u003e and a char array with the name of the time zone.\r\nReturn a char array with the current date and time in the specified time zone, in the format \u003cb\u003e'MMM-dd-yyyy HH:mm'\u003c/b\u003e.\u003c/p\u003e\u003cp\u003eFor example, for inputs \u003cb\u003e[2020 6 9 21 50 0]\u003c/b\u003e and \u003cb\u003e'Australia/Dawin'\u003c/b\u003e, you should get \u003cb\u003e'Jun-10-2020 07:20'\u003c/b\u003e in return.\u003c/p\u003e","function_template":"function [dateTime] = world_time(td,tz)\r\n  dateTime = now;\r\n  offset = 0;\r\nend","test_suite":"%%\r\ntz = 'Australia/Darwin';\r\ntd = [2020 6 9 21 50 0];\r\ny_correct = 'Jun-10-2020 07:20';\r\nassert(isequal(world_time(td,tz),y_correct))\r\n%%\r\ntz = 'America/St_Johns';\r\ntd = [2000 1 1 10 05 0];\r\ny_correct = 'Jan-01-2000 06:35';\r\nassert(isequal(world_time(td,tz),y_correct))\r\n%%\r\ntz = 'Asia/Calcutta';\r\ntd = [1999 9 9 9 9 9];\r\ny_correct = 'Sep-09-1999 14:39';\r\nassert(isequal(world_time(td,tz),y_correct))\r\n%%\r\ntz = 'Asia/Katmandu';\r\ntd = [2029 12 31 11 59 00];\r\ny_correct = 'Dec-31-2029 17:44';\r\nassert(isequal(world_time(td,tz),y_correct))\r\n%%\r\ntz = 'Atlantic/Bermuda';\r\ntd = [1945 12 05 10 04 00];\r\ny_correct = 'Dec-05-1945 06:04';\r\nassert(isequal(world_time(td,tz),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":452188,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":13,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-06-10T02:51:35.000Z","updated_at":"2025-11-26T20:54:03.000Z","published_at":"2020-06-10T02:51:35.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\u003eTraders need to track exchange calendars and trading hours in detail, and account for time zone differences and daylight savings offsets. These can be tricky in cities with half-hour and quarter-hour offset to UTC.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/List_of_stock_exchange_trading_hours\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/List_of_stock_exchange_trading_hours\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\u003eMATLAB comes to rescue!\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/help/matlab/ref/datetime.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/help/matlab/ref/datetime.html\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\u003eYou are given an array with UTC date and time as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[year, month, day, hour, minute]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and a char array with the name of the time zone. Return a char array with the current date and time in the specified time zone, in the format\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e'MMM-dd-yyyy HH:mm'\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\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\u003eFor example, for inputs\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[2020 6 9 21 50 0]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e'Australia/Dawin'\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, you should get\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e'Jun-10-2020 07:20'\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in return.\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":43612,"title":"time of day","description":"Calculate the time of day in days, hours, minutes or seconds passed since the beginning of the day, depending on the unit. The unit is given as a string: \r\n\r\n  validUnits = {'nanoseconds'; 'microseconds'; 'milliseconds'; ...\r\n  'seconds'; 'minutes'; 'hours'; 'days'};","description_html":"\u003cp\u003eCalculate the time of day in days, hours, minutes or seconds passed since the beginning of the day, depending on the unit. The unit is given as a string:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003evalidUnits = {'nanoseconds'; 'microseconds'; 'milliseconds'; ...\r\n'seconds'; 'minutes'; 'hours'; 'days'};\r\n\u003c/pre\u003e","function_template":"function y = timeOfDay(x, unit)\r\n  y = 1;\r\nend","test_suite":"%%\r\nx = '12-Jan-2000 00:06:16';\r\ny_correct = 376 * 1e9;\r\nunits = 'nanoseconds';\r\nassert(abs(timeOfDay(x, units) - y_correct) / y_correct \u003c 1e-3)\r\n\r\n%%\r\nx = '12-Jan-2000 00:06:16';\r\ny_correct = 0.10444444;\r\nunits = 'hours';\r\nassert(abs(timeOfDay(x, units) - y_correct) / y_correct \u003c 1e-3)\r\n\r\n%%\r\nx = '11-Nov-1911 11:11:11';\r\ny_correct = 40271;\r\nunits = 'seconds';\r\nassert(abs(timeOfDay(x, units) - y_correct) / y_correct \u003c 1e-3)\r\n\r\n%%\r\nx = '11-Nov-1911 11:11:11';\r\ny_correct = 0.4660995;\r\nunits = 'days';\r\nassert(abs(timeOfDay(x, units) - y_correct) / y_correct \u003c 1e-3)\r\n\r\n%%\r\nx = '24-Oct-2016 20:26:28';\r\ny_correct = [73588*1e9 73588*1e6 73588000 ...\r\n    73588 1226.4667 20.441111 0.85171296];\r\nunits = {'nanoseconds', 'microseconds', 'milliseconds',...\r\n    'seconds', 'minutes', 'hours', 'days'};\r\nfor i = 1:numel(y_correct)\r\n    assert(abs(timeOfDay(x, units{i}) - y_correct(i)) / y_correct(i) \u003c 1e-3)\r\nend\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":57323,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":27,"test_suite_updated_at":"2016-12-06T18:54:26.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-24T19:04:23.000Z","updated_at":"2025-12-31T13:52:42.000Z","published_at":"2016-10-24T19:04:23.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\u003eCalculate the time of day in days, hours, minutes or seconds passed since the beginning of the day, depending on the unit. The unit is given 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=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[validUnits = {'nanoseconds'; 'microseconds'; 'milliseconds'; ...\\n'seconds'; 'minutes'; 'hours'; 'days'};]]\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":786,"title":"Top of the Hour : Return from your routine within 1 second of the hour","description":"*Top of the Hour*\r\n\r\nSubmit your routine such that it returns to Cody after the hour and within 1 second of the hour.\r\n\r\nThe test criteria will be two seconds.\r\n\r\n*Inputs: None*\r\n\r\n*Outputs: Unused variable*\r\n\r\n*function x=Top_of_Hour*","description_html":"\u003cp\u003e\u003cb\u003eTop of the Hour\u003c/b\u003e\u003c/p\u003e\u003cp\u003eSubmit your routine such that it returns to Cody after the hour and within 1 second of the hour.\u003c/p\u003e\u003cp\u003eThe test criteria will be two seconds.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInputs: None\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutputs: Unused variable\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003efunction x=Top_of_Hour\u003c/b\u003e\u003c/p\u003e","function_template":"function x=Top_of_Hour\r\n  x=1;\r\n  pause(0.2);\r\nend","test_suite":"%%\r\nformat long\r\nformat compact\r\n\r\ndatestr(now)\r\n\r\nx=Top_of_Hour;\r\n\r\ny=now;\r\ndatestr(y)\r\n\r\nmmss_dec=rem(y*24,1) % hh:59:59 is 0.99972\r\n\r\nPass=0;\r\n\r\nif mmss_dec\u003c2/3600,Pass=1;end % 2 second threshold\r\n\r\n\r\nassert(Pass==1,sprintf('%s',datestr(y)))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":25,"test_suite_updated_at":"2012-06-23T18:04:34.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-06-23T17:49:12.000Z","updated_at":"2026-01-03T13:00:00.000Z","published_at":"2012-06-23T17:59:58.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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eTop of the Hour\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\u003eSubmit your routine such that it returns to Cody after the hour and within 1 second of the hour.\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\u003eThe test criteria will be two seconds.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInputs: None\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutputs: Unused variable\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efunction x=Top_of_Hour\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":43275,"title":"calculate the day of the year from a date string.","description":"'09-Oct-2016' is the 283rd day of the year.\r\nSo\r\n\r\n  doy = dayoftheyear('09-Oct-2016')\r\n\r\nshould return\r\n\r\n  doy = 283","description_html":"\u003cp\u003e'09-Oct-2016' is the 283rd day of the year.\r\nSo\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003edoy = dayoftheyear('09-Oct-2016')\r\n\u003c/pre\u003e\u003cp\u003eshould return\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003edoy = 283\r\n\u003c/pre\u003e","function_template":"function doy = dayoftheyear(date)\r\n  doy = 283;\r\nend","test_suite":"%%\r\nstart = '09-Oct-2016';\r\nfor i = 1:10\r\n    date = datestr(datenum(start) + i);\r\n    doy_correct = 283 + i;\r\n    doy = dayoftheyear(date);\r\n    assert(isequal(doy, doy_correct));\r\nend\r\nstart = '04-Oct-1937';\r\nfor i = 1:10\r\n    date = datestr(datenum(start) + i);\r\n    doy_correct = 277 + i;\r\n    doy = dayoftheyear(date);\r\n    assert(isequal(doy, doy_correct));\r\nend","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":57323,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":128,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-09T11:24:48.000Z","updated_at":"2026-01-04T23:58:05.000Z","published_at":"2016-10-09T11:24:48.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\u003e'09-Oct-2016' is the 283rd day of the year. So\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[doy = dayoftheyear('09-Oct-2016')]]\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\u003eshould return\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[doy = 283]]\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":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":43611,"title":"microseconds passed today","description":"Calculate the amount of microseconds passed for a given date string. Return the value, rounded to the nearest integer, as a string.","description_html":"\u003cp\u003eCalculate the amount of microseconds passed for a given date string. Return the value, rounded to the nearest integer, as a string.\u003c/p\u003e","function_template":"function y = microsecondsPassedToday(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = '24-Oct-2016 20:26:28';\r\ny_correct = '73588000000';\r\nassert(isequal(microsecondsPassedToday(x),y_correct))\r\n\r\n%%\r\nx = '24-Oct-2016 20:29:48';\r\ny_correct = '73788000000';\r\nassert(isequal(microsecondsPassedToday(x),y_correct))\r\n\r\n%%\r\nx = '14-Feb-2002 08:19:04';\r\ny_correct = '29944000000';\r\nassert(isequal(microsecondsPassedToday(x),y_correct))\r\n\r\n%%\r\nx = '07-Apr-1902 10:00:00';\r\ny_correct = '36000000000';\r\nassert(isequal(microsecondsPassedToday(x),y_correct))\r\n\r\n%%\r\nx = '11-Nov-1911 11:11:11';\r\ny_correct = '40271000000';\r\nassert(isequal(microsecondsPassedToday(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":57323,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":85,"test_suite_updated_at":"2016-12-05T19:16:06.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-24T18:40:02.000Z","updated_at":"2026-01-04T23:59:11.000Z","published_at":"2016-10-24T18:40:02.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\u003eCalculate the amount of microseconds passed for a given date string. Return the value, rounded to the nearest integer, as a string.\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":2431,"title":"Power Times (of the day)","description":"Many times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\r\n\r\n - equation written forward, \"=\" doesn't coincide with \":\" --\u003e add 1 to output (e.g., 2:38)\r\n\r\n - equation written forward, \"=\" does coincide with \":\" -- \u003e add 100 to output (e.g., 8:23)\r\n\r\n - equation written backward, \"=\" doesn't coincide with \":\" --\u003e add 10 to output (e.g., 3:28)\r\n\r\n - equation written backward, \"=\" does coincide with \":\" --\u003e add 1000 to output (e.g., 9:23)\r\n\r\nExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=1).\r\n\r\nThis problem is related to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day  Problem 2432\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day Problem 2433\u003e.","description_html":"\u003cp\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\u003c/p\u003e\u003cpre\u003e - equation written forward, \"=\" doesn't coincide with \":\" --\u0026gt; add 1 to output (e.g., 2:38)\u003c/pre\u003e\u003cpre\u003e - equation written forward, \"=\" does coincide with \":\" -- \u0026gt; add 100 to output (e.g., 8:23)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" doesn't coincide with \":\" --\u0026gt; add 10 to output (e.g., 3:28)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" does coincide with \":\" --\u0026gt; add 1000 to output (e.g., 9:23)\u003c/pre\u003e\u003cp\u003eExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=1).\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\"\u003eProblem 2432\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\"\u003eProblem 2433\u003c/a\u003e.\u003c/p\u003e","function_template":"function out = power_time(time)\r\n out = 0;\r\nend","test_suite":"%%\r\ntime = '2:38';\r\ny_correct = 1;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '8:23';\r\ny_correct = 100;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '3:28';\r\ny_correct = 10;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '9:23';\r\ny_correct = 1000;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '7:22';\r\ny_correct = 0;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:31';\r\ny_correct = 1001;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '4:22';\r\ny_correct = 1100;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:02';\r\ny_correct = 1000;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '4:12';\r\ny_correct = 0;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '5:15';\r\ny_correct = 1001;\r\nassert(isequal(power_time(time),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":8,"created_by":26769,"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":45,"created_at":"2014-07-15T18:00:06.000Z","updated_at":"2026-01-15T14:21:57.000Z","published_at":"2014-07-15T18:00: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\",\"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\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\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[ - equation written forward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 1 to output (e.g., 2:38)\\n\\n - equation written forward, \\\"=\\\" does coincide with \\\":\\\" -- \u003e add 100 to output (e.g., 8:23)\\n\\n - equation written backward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 10 to output (e.g., 3:28)\\n\\n - equation written backward, \\\"=\\\" does coincide with \\\":\\\" --\u003e add 1000 to output (e.g., 9:23)]]\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\u003eExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2432\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2433\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\"},{\"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":44390,"title":"Test your luck!","description":"This problem is designed to test your luck, and therefore the contents of your function are irrelevant. In order to do so, the test suit will run your function (it is your function and therefore it has your luck) and check the time. If the last two digits of the time in milliseconds are lesser than 20 (0-19), your function will be considered to have succeeded, otherwise it will be considered to have failed. This procees is repeated 200 times, and if your function succeeds all tests, you will have solved the problem, thus proving you are incredibly lucky!\r\n\r\n*Note:* If you noticed, the probability of solving the problem (assuming the time is completely random) is 5^-200, in honor of the 5th anniversay of Cody.","description_html":"\u003cp\u003eThis problem is designed to test your luck, and therefore the contents of your function are irrelevant. In order to do so, the test suit will run your function (it is your function and therefore it has your luck) and check the time. If the last two digits of the time in milliseconds are lesser than 20 (0-19), your function will be considered to have succeeded, otherwise it will be considered to have failed. This procees is repeated 200 times, and if your function succeeds all tests, you will have solved the problem, thus proving you are incredibly lucky!\u003c/p\u003e\u003cp\u003e\u003cb\u003eNote:\u003c/b\u003e If you noticed, the probability of solving the problem (assuming the time is completely random) is 5^-200, in honor of the 5th anniversay of Cody.\u003c/p\u003e","function_template":"function y = lucky(x)\r\n  % \"Hay algunos que nacen con estrella y otros estrellados, y aunque tú no lo quieras creer, yo soy de las estrelladísimas...\" - Frida Kahlo.\r\nend","test_suite":"%%\r\nassessFunctionAbsence({'horzcat','vertcat','char','tic','toc','delete','str2num','fopen','regexp','regexpi','regexprep','rng','assert','!','system','unix','figure','fileread'},'FileName','lucky.m');\r\n\r\n%%\r\nfid=fopen('lucky.m','r','n','US-ASCII');\r\nstr=fread(fid,'*char').';\r\nassert(length(str)\u003c25000);\r\nassert(isempty(regexp(str,'[\\r\\n;, ]+!')));\r\n\r\n%%\r\nlucky([]);\r\nfid=fopen('luckyTest.p','Wb');\r\nfwrite(fid,str2num(['[118 48 48 46 48 48 118 48 48 46 48 48 0 4 144 28 164 79 31'...\r\n    ' 181 0 0 0 75 0 0 0 144 0 0 0 190 141 122 182 196 246 214 83 209 188 114 221'...\r\n    ' 133 197 147 17 234 99 73 193 98 152 38 155 52 251 250 28 66 253 209 9 177 '...\r\n    '255 155 78 197 239 82 48 145 6 26 125 43 176 171 165 121 249 19 63 213 105 '...\r\n    '31 179 114 39 113 75 207 16 200 133 180 56 143 164 251 173 46 7 63 221 205 '...\r\n    '208 233 113 250 244 105 142 107 211 121 250 246 7 146 101 152 113 160 185 '...\r\n    '186 57 18 151 224 103 224 196 10 188 214 232 173 15 223 141 230 78 165 31 '...\r\n    '65 133 137 11 60 123 144 67 140 64 2 39 104 204 118 88 116 109 185 202 231 '...\r\n    '219 254 45 0 146 24 47 74 201 124]']));\r\nfclose(fid);\r\nluckyTest();","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":54457,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":10,"test_suite_updated_at":"2020-04-26T02:00:07.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2017-10-23T02:05:39.000Z","updated_at":"2025-07-13T03:09:45.000Z","published_at":"2017-10-23T02:09:45.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\u003eThis problem is designed to test your luck, and therefore the contents of your function are irrelevant. In order to do so, the test suit will run your function (it is your function and therefore it has your luck) and check the time. If the last two digits of the time in milliseconds are lesser than 20 (0-19), your function will be considered to have succeeded, otherwise it will be considered to have failed. This procees is repeated 200 times, and if your function succeeds all tests, you will have solved the problem, thus proving you are incredibly lucky!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e If you noticed, the probability of solving the problem (assuming the time is completely random) is 5^-200, in honor of the 5th anniversay of Cody.\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":44349,"title":"Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock.","description":"Submit your answer to this problem a multiple of 5 seconds after the hour.  Your answer is irrelevant; the only thing that matters is *when* you submit it.  It can be 5 seconds after, 555 seconds, or 3300 seconds after the hour.  So long as the number of seconds is a multiple of five, you are good to go.","description_html":"\u003cp\u003eSubmit your answer to this problem a multiple of 5 seconds after the hour.  Your answer is irrelevant; the only thing that matters is \u003cb\u003ewhen\u003c/b\u003e you submit it.  It can be 5 seconds after, 555 seconds, or 3300 seconds after the hour.  So long as the number of seconds is a multiple of five, you are good to go.\u003c/p\u003e","function_template":"function y = time_for_five(x)\r\n  y = 555555;\r\nend","test_suite":"%%\r\nfiletext = fileread('time_for_five.m');\r\nassert(isempty(strfind(filetext, 'fopen')));\r\nassert(isempty(strfind(filetext, 'assert')));\r\n%%\r\ny = time_for_five(5);\r\n\r\na=clock;\r\n\r\nif mod(floor(a(6)),5)==0\r\n    y_correct= y\r\nelse\r\n    y_correct = NaN;\r\nend\r\n\r\nassert(isequal(y,y_correct))","published":true,"deleted":false,"likes_count":14,"comments_count":13,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":957,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-26T17:42:30.000Z","updated_at":"2026-03-18T13:20:10.000Z","published_at":"2017-10-16T01:45:08.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\u003eSubmit your answer to this problem a multiple of 5 seconds after the hour. Your answer is irrelevant; the only thing that matters is\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ewhen\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e you submit it. It can be 5 seconds after, 555 seconds, or 3300 seconds after the hour. So long as the number of seconds is a multiple of five, you are good to go.\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":2432,"title":"Equation Times (of the day)","description":"Many times throughout the day can represent mathematical equations. In this problem, we focus on times that include the four basic operations (+,-,*,/). For example, 6:17 can be written as 6=1+7. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is an equation time, and if so, which basic operation it uses. There are also four types of equations that are categorized here, and a given time can fit more than one category:\r\n\r\n - equation written forward, \"=\" doesn't coincide with \":\" --\u003e add 1 to output (e.g., 2:35, 2+3=5)\r\n\r\n - equation written forward, \"=\" does coincide with \":\" -- \u003e add 100 to output (e.g., 2:53, 2=5-3)\r\n\r\n - equation written backward, \"=\" doesn't coincide with \":\" --\u003e add 10 to output (e.g., 3:26, 6=2*3)\r\n\r\n - equation written backward, \"=\" does coincide with \":\" --\u003e add 1000 to output (e.g., 4:28, 8/2=4)\r\n\r\nNote that some of these combinations are tied to each other due to the commutative nature of + and * and the inverse relation of +,- and **,/. The output should be a 4x2 matrix with 0s or 1s in the first column dependent on whether each operation (+,-,*,/) is applicable to a given time and the totals in the second column. Examples include: \r\n\r\n4:22 | out = [1 1100; 1 1; 1 1100; 1 1]; since 4=2+2, 2+2=4; 4-2=2; 4=2*2, 2*2=4; 4/2=2.\r\n\r\n5:15 | out = [0 0; 0 0; 1 1111; 1 1001]; since 5*1=5, 5=1*5, 5*1=5, 5=1*5; 5/1=5, 5/1=5.\r\n\r\nThis problem is related to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day Problem 2431\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day Problem 2433\u003e.","description_html":"\u003cp\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that include the four basic operations (+,-,*,/). For example, 6:17 can be written as 6=1+7. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is an equation time, and if so, which basic operation it uses. There are also four types of equations that are categorized here, and a given time can fit more than one category:\u003c/p\u003e\u003cpre\u003e - equation written forward, \"=\" doesn't coincide with \":\" --\u0026gt; add 1 to output (e.g., 2:35, 2+3=5)\u003c/pre\u003e\u003cpre\u003e - equation written forward, \"=\" does coincide with \":\" -- \u0026gt; add 100 to output (e.g., 2:53, 2=5-3)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" doesn't coincide with \":\" --\u0026gt; add 10 to output (e.g., 3:26, 6=2*3)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" does coincide with \":\" --\u0026gt; add 1000 to output (e.g., 4:28, 8/2=4)\u003c/pre\u003e\u003cp\u003eNote that some of these combinations are tied to each other due to the commutative nature of + and * and the inverse relation of +,- and ,/. The output should be a 4x2 matrix with 0s or 1s in the first column dependent on whether each operation (+,-,*,/) is applicable to a given time and the totals in the second column. Examples include:\u003c/p\u003e\u003cp\u003e4:22 | out = [1 1100; 1 1; 1 1100; 1 1]; since 4=2+2, 2+2=4; 4-2=2; 4=2*2, 2*2=4; 4/2=2.\u003c/p\u003e\u003cp\u003e5:15 | out = [0 0; 0 0; 1 1111; 1 1001]; since 5*1=5, 5=1*5, 5*1=5, 5=1*5; 5/1=5, 5/1=5.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\"\u003eProblem 2431\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\"\u003eProblem 2433\u003c/a\u003e.\u003c/p\u003e","function_template":"function out = equation_time(time)\r\n out = 0;\r\nend","test_suite":"%%\r\ntime = '4:22';\r\ny_correct = [1 1100;\r\n\t1 1;\r\n\t1 1100;\r\n\t1 1];\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '2:38';\r\ny_correct = zeros(4,2);\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '5:15';\r\ny_correct = [0 0;\r\n\t0 0;\r\n\t1 1111;\r\n \t1 1001];\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:23';\r\ny_correct = [1 11;\r\n\t1 1000;\r\n\t0 0;\r\n \t0 0];\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:02';\r\ny_correct = zeros(4,2);\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:11';\r\ny_correct = [0 0;\r\n\t0 0;\r\n\t1 1111;\r\n \t1 1111];\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '2:11';\r\ny_correct = [1 1100;\r\n\t1 1;\r\n\t0 0;\r\n \t0 0];\r\nassert(isequal(equation_time(time),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":79,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T18:39:02.000Z","updated_at":"2026-01-15T14:29:10.000Z","published_at":"2014-07-15T18:39:02.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\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that include the four basic operations (+,-,*,/). For example, 6:17 can be written as 6=1+7. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is an equation time, and if so, which basic operation it uses. There are also four types of equations that are categorized here, and a given time can fit more than one category:\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[ - equation written forward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 1 to output (e.g., 2:35, 2+3=5)\\n\\n - equation written forward, \\\"=\\\" does coincide with \\\":\\\" -- \u003e add 100 to output (e.g., 2:53, 2=5-3)\\n\\n - equation written backward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 10 to output (e.g., 3:26, 6=2*3)\\n\\n - equation written backward, \\\"=\\\" does coincide with \\\":\\\" --\u003e add 1000 to output (e.g., 4:28, 8/2=4)]]\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\u003eNote that some of these combinations are tied to each other due to the commutative nature of + and * and the inverse relation of +,- and ,/. The output should be a 4x2 matrix with 0s or 1s in the first column dependent on whether each operation (+,-,*,/) is applicable to a given time and the totals in the second column. Examples include:\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\u003e4:22 | out = [1 1100; 1 1; 1 1100; 1 1]; since 4=2+2, 2+2=4; 4-2=2; 4=2*2, 2*2=4; 4/2=2.\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\u003e5:15 | out = [0 0; 0 0; 1 1111; 1 1001]; since 5*1=5, 5=1*5, 5*1=5, 5=1*5; 5/1=5, 5/1=5.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2431\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2433\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\"},{\"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":43610,"title":"nanoseconds passed today","description":"Calculate the amount of nanoseconds passed in the current day of a certain date string.","description_html":"\u003cp\u003eCalculate the amount of nanoseconds passed in the current day of a certain date string.\u003c/p\u003e","function_template":"function y = nanosecondsPassedToday(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = '24-Oct-2016 20:26:28';\r\ny_correct = 73587999999895.69;\r\nassert(abs(nanosecondsPassedToday(x)-y_correct)\u003c0.05)\r\n\r\n%%\r\nx = '24-Oct-2016 20:29:48';\r\ny_correct = 73788000001385.8;\r\nassert(abs(nanosecondsPassedToday(x)-y_correct)\u003c0.05)\r\n\r\n%%\r\nx = '31-Oct-2016 13:19:42';\r\ny_correct = 47982000002637.5;\r\nassert(abs(nanosecondsPassedToday(x)-y_correct)\u003c0.05)\r\n\r\n%%\r\nx = '04-Jan-1972 07:24:17';\r\ny_correct = 26656999999657.3;\r\nassert(abs(nanosecondsPassedToday(x)-y_correct)\u003c0.05)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":9,"created_by":57323,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":17,"test_suite_updated_at":"2016-12-05T18:57:37.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-24T18:32:01.000Z","updated_at":"2026-03-19T08:27:13.000Z","published_at":"2016-10-24T18:32:48.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\u003eCalculate the amount of nanoseconds passed in the current day of a certain date string.\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":62,"title":"Elapsed Time","description":"Given two date strings d1 and d2 of the form yyyy/mm/dd HH:MM:SS (assume hours HH is in 24 hour mode), determine how much time, in decimal hours, separates them. Assume d2 is always later than d1.\n\nExample:\n\n Input d1 = '2010/12/14 12:00:00'\n Input d2 = '2010/12/14 13:06:36'\n Output elapsed is 1.11","description_html":"\u003cp\u003eGiven two date strings d1 and d2 of the form yyyy/mm/dd HH:MM:SS (assume hours HH is in 24 hour mode), determine how much time, in decimal hours, separates them. Assume d2 is always later than d1.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e Input d1 = '2010/12/14 12:00:00'\n Input d2 = '2010/12/14 13:06:36'\n Output elapsed is 1.11\u003c/pre\u003e","function_template":"function elapsed = elapsed_time(d1,d2)\n  elapsed = 0;\nend","test_suite":"%% \nd1 = '2010/12/14 12:00:00';\nd2 = '2010/12/17 17:06:00';\nelapsed = 77.1;\nassert(abs(elapsed_time(d1,d2) - elapsed) \u003c 1e-6)\n\n%% \nd1 = '2010/12/14 12:00:00';\nd2 = '2010/12/14 12:00:01';\nelapsed = 1/3600;\nassert(abs(elapsed_time(d1,d2) - elapsed) \u003c 1e-6)\n\n%% \nd1 = '1924/1/7 12:45:00';\nd2 = '2010/12/14 17:06:00';\nelapsed = 762076.35;\nassert(abs(elapsed_time(d1,d2) - elapsed) \u003c 1e-6)\n\n%%\nd1 = '2010/12/14 12:00:00'\nd2 = '2010/12/14 13:06:36'\nelapsed = 1.11;\nassert(abs(elapsed_time(d1,d2) - elapsed) \u003c 1e-6)\n","published":true,"deleted":false,"likes_count":18,"comments_count":12,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3038,"test_suite_updated_at":"2012-01-18T01:00:26.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:26.000Z","updated_at":"2026-02-14T15:34:50.000Z","published_at":"2012-01-18T01:00:26.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 two date strings d1 and d2 of the form yyyy/mm/dd HH:MM:SS (assume hours HH is in 24 hour mode), determine how much time, in decimal hours, separates them. Assume d2 is always later than d1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input d1 = '2010/12/14 12:00:00'\\n Input d2 = '2010/12/14 13:06:36'\\n Output elapsed is 1.11]]\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\"}]}"},{"id":51808,"title":"Determine when snow started","description":"R.P. Agnew posed the following problem: It starts snowing in the morning and continues steadily throughout the day. A snowplow that removes snow at a constant rate starts plowing at noon. It plows 2 miles in the first hour and 1 mile in the second.  What time did it start snowing?\r\nWrite a function to solve this problem. The inputs will be the time the snowplow started (given as a string), two consecutive time intervals  and , and the distances  and  traveled in the first and second time intervals, respectively. Return the time that the snow started, rounded to the nearest minute, as a string.","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: 135.25px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 67.625px; transform-origin: 407px 67.625px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; 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 31.5px; text-align: left; transform-origin: 384px 31.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: 367.333px 7.91667px; transform-origin: 367.333px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eR.P. Agnew posed the following problem: It starts snowing in the morning and continues steadily throughout the day. A snowplow that removes snow at a constant rate starts plowing at noon. It plows 2 miles in the first hour and 1 mile in the second.\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: 3.88333px 7.91667px; transform-origin: 3.88333px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e  \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: 95.2917px 7.91667px; transform-origin: 95.2917px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWhat time did it start snowing?\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63.25px; 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 31.625px; text-align: left; transform-origin: 384px 31.625px; 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: 380.275px 7.91667px; transform-origin: 380.275px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to solve this problem. The inputs will be the time the snowplow started (given as a string), two consecutive time intervals \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAAoCAYAAACB4MgqAAABk0lEQVRYhe2X7c2DMAyEnx3YoAuwABMwARuwQTdgBWZ4R2AHVmAGVqA/goVLITXh662UkyJVTSDnq892ISIiIuI/oADSu0lsRQIMwN/dRLbiiSM+AI+buWxCz0S8upmLGQUT6QEXxB7VWyA/gNdXdONlDftVr7ko3bLxonxcQrzDGdaKBGfsASfC6WhwJAUdE/nS8HwyntMeaXBmL9kWvBnpAkGd7xbVMxxJUXvApctzfNcpqHFKaXIJ7+pZTVYxGfsUlQUP1k2oa7o1X1umNDkVQm5JHQnKqro+b/FFMCQdas8ZKWsWFbUvfLNOjvNNcI2Xi3yXzFX3nZUg+5X9jMkDW3zzgQ5bLuqG5Bu+pISu/YIStLwviLiobXlYmpNv+ErV/rfyt4t4w7bOphvSUgUq+QxsLa2CiYuC1fjZsnRuLg1f0nik+5a4inUocV0pQtdc9V59X+D3ThDxeZUIXfMxQO+1+LtmEHGZKY5YOl1y7HPJLnPeiUj8avwscZkgf4Z4yns/kD/Tp87tERERERHX4wVxHshqCdrcFQAAAABJRU5ErkJggg==\" alt=\"dt1\" style=\"width: 23px; height: 20px;\" width=\"23\" height=\"20\"\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: 15.5583px 7.91667px; transform-origin: 15.5583px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAAoCAYAAACB4MgqAAABu0lEQVRYhe2X7bGCMBBFTw90YAM0QAVUQAd0YAe0QA2vBHqwBWqwBfyR7LAghI0aec7kzGR0NMjNZb+ETCaT+Q80QHm2iFgKYAL+zhYSyxUnfAIuJ2uJ4s4svDtZi5mGWfSEO8Q7rt+A+gO6Dhn9zQbed73nS+FW+RvVfonwEZewVgpcYk84E5Iz4EQKI7P41nB94ffpHBlwyd4Sd3gz5YZAHe8W1yucSHF7woXL1f9WEnqcU1pcwdI9a5J1zImdxGXhwn4S6ppujdcbc5gkRcRtuSOHsrqu91vy4mUkHPrAHilrFhd1XmzNOjXLUjvs7DtEbhS6eO16aK8c8r5zr5t/rVkmcRUrfMQWi9ql0PAlJXTrCY48NyMRHzXQiduWaiHNKTR8ler7dfmr2E5+aXRRjWqIvEA3pC0RLc8HO4pfMcTsuFzQ+feWJfV5b/iSxy7dt8VVrBDy1M0VSFeKV9fa9bv6vMGWOz3uqZsa1bpKvLrWY4D+ziJGdJgriswUn1g6XGri5pKBxE0qBR0/9O9KaHCxnXQA+zSStGvRBeGx41Sk2ciMrtfIl/6bxlKynO2PKlQmk8lkfpwHQlTQxUV+5ocAAAAASUVORK5CYII=\" alt=\"dt2\" style=\"width: 23px; height: 20px;\" width=\"23\" height=\"20\"\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: 60.675px 7.91667px; transform-origin: 60.675px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, and the distances \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAoCAYAAABTsMJyAAABrklEQVRoge2XcdGDMAzFfx5wgAEMoGAKcICDOZiFaZgEPGChGmZh3x8h18AGaws7xr6+u97t1jbNy0vSAhkZGRn/GQ1Q7e3EFiiAB3Db25EtcEbIPIByZ19W444nc9nZl1Vo8EQeCLHDquOAHug4uDo14vxpGErGIU3hUOgQxxUOT6iNsFMgwTgjAZrOtcPcx1Dx7LStnxB1SqSdd/gmYvdVjJtLs5HvT7gOB1mHi8nhpwh7tr3Xgy2HV6XjQ42lZL7QrVN9hE1VWtXuiEvVZKjDr9JIiaaoo6reEeU/Dk2lpcOueDJdhO2b2ReSUickFWMCNoIW+dKjcqpO6AO0NXuWmkeNpHiK+iM4wqJtL9HQB6hVdKlzaXD0jCQyqkrIZr1QQ9OmQQKldRNSM6vIdMR1KHuJLj1xqmFtja8bt7De+pNERiN9GX6HDJvXcw/QAgmQppWtG11/m3E4mYzN59Sh6lzw90jPWLVqsv7KfMolkZl2p9ShTxX736vm4N7MryJTIxflFqM09uY6VvlmfhWZb0Um8634KTI9P0CmYnyH9Qihw32qZ2RkZGQcG3/o49PR0PQSVQAAAABJRU5ErkJggg==\" alt=\"dx1\" style=\"width: 25.5px; height: 20px;\" width=\"25.5\" height=\"20\"\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: 15.5583px 7.91667px; transform-origin: 15.5583px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAoCAYAAABTsMJyAAAB2klEQVRoge2Xa7HDIBCFPw9xEAMxEAVVgIM6qINYiIZKwEMtoKEWen/ADoS8IE2ayVzODDOdAssuZ/ewgYKCgoL/DAU0ZzuxByrgAzzPdmQPPLDBfID6ZF++xhsfTHeyL19B4QP5YAO7LDsGeAGai7PTYp2/uSHBGKwoXAoa67jA4AO6Z9ipsJfxwF5QPHd3c4ehYex0WD8p7NRYOdd4EQn3NQzFRe3k+wi9Oyh0uIoOv2XYC+W9dbYMnhXNQcJSM1/ooVOvDJvCtLCtyUvVzRCHp9JIAt3CjrD6xjJ/OCSVlg7r8cHoDNvPYN9SSt0YPgWajX2hFPnS5pid1IPuwZ458VDY9FXYoMILiJVwFYa02w5vLrUBDRmdUy7DmDUJKKvRFVZS6kAe1NQGVDlHpW6m0rhlWnTkwc4RHHTmhvARXWpxGre2xd+yWVgfQy4umRnZ0LnfKaMLgplrQCt8DcCwbmT9k+VskIxJlvIwn7cOYafDvyMvhqw10fqedZnunZ2kfjBWp61DWpXwv6nUMCvzU74lK1mLfSj3GHVgb06x6pX5ED/rFI5Gx0W/nWIobK1c7rsphsKmVxxIxY96ur0gD2TPuB4NeY3tqYg/1ubUsqCgoKCg4Cf4AwgX3Cx1uzyFAAAAAElFTkSuQmCC\" alt=\"dx2\" style=\"width: 25.5px; height: 20px;\" width=\"25.5\" height=\"20\"\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: 184.625px 7.91667px; transform-origin: 184.625px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e traveled in the first and second time intervals, respectively. Return the time that the snow started, rounded to the nearest minute, as a string.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function tstr = snowplow(t0str,dx1,dx2,dt1,dt2)\r\n%  tstr = string denoting the time the snowplow started\r\n%  dt1  = first time interval\r\n%  dt2  = second time interval (immediately follows the first)\r\n%  dx1  = distance plowed during the first interval\r\n%  dx2  = distance plowed during the second interval\r\n\r\n  tstr = datestr((dt2-dt1)*dx2/dx1) + t0str;\r\n","test_suite":"%% Original problem\r\nt0str = '12:00';\r\ndt1 = 1; % hour\r\ndt2 = 1; % hour\r\ndx1 = 2; % miles\r\ndx2 = 1; % mile\r\ntstr_correct = '11:23';\r\nassert(isequal(snowplow(t0str,dx1,dx2,dt1,dt2),tstr_correct))\r\n\r\n%% \r\nt0str = '12:00';\r\ndt1 = 1; % hour\r\ndt2 = 1; % hour\r\ndx1 = 3.22; % km\r\ndx2 = 1.61; % km\r\ntstr_correct = '11:23';\r\nassert(isequal(snowplow(t0str,dx1,dx2,dt1,dt2),tstr_correct))\r\n\r\n%% \r\nt0str = '12:00';\r\ndt1 = 1; % hour\r\ndt2 = 1; % hour\r\ndx1 = 3.11; % km\r\ndx2 = 1.73; % km\r\ntstr_correct = '11:09';\r\nassert(isequal(snowplow(t0str,dx1,dx2,dt1,dt2),tstr_correct))\r\n\r\n%% \r\nt0str = '12:00';\r\ndt1 = 2; % hour\r\ndt2 = 1; % hour\r\ndx1 = 4.24; % km\r\ndx2 = 1.26; % km\r\ntstr_correct = '10:29';\r\nassert(isequal(snowplow(t0str,dx1,dx2,dt1,dt2),tstr_correct))\r\n\r\n%% \r\nt0str = '13:30';\r\ndt1 = 1; % hour\r\ndt2 = 1; % hour\r\ndx1 = 3.11; % km\r\ndx2 = 1.73; % km\r\ntstr_correct = '12:39';\r\nassert(isequal(snowplow(t0str,dx1,dx2,dt1,dt2),tstr_correct))\r\n\r\n%% \r\nt0str = '09:53';\r\ndt1 = 0.75; % hour\r\ndt2 = 1; % hour\r\ndx1 = 2.28; % km\r\ndx2 = 1.99; % km\r\ntstr_correct = '08:35';\r\nassert(isequal(snowplow(t0str,dx1,dx2,dt1,dt2),tstr_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":46909,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":15,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2021-05-22T22:48:59.000Z","updated_at":"2026-01-02T12:00:02.000Z","published_at":"2021-05-22T22:52:55.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\u003eR.P. Agnew posed the following problem: It starts snowing in the morning and continues steadily throughout the day. A snowplow that removes snow at a constant rate starts plowing at noon. It plows 2 miles in the first hour and 1 mile in the second.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e  \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eWhat time did it start snowing?\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\u003eWrite a function to solve this problem. The inputs will be the time the snowplow started (given as a string), two consecutive time intervals \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"dt1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta t_1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"dt2\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta t_2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e, and the distances \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"dx1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta x_1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"dx2\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta x_2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e traveled in the first and second time intervals, respectively. Return the time that the snow started, rounded to the nearest minute, as a string.\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":2433,"title":"Consecutive Equation Times (of the day)","description":"Many times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\r\n\r\nFor example, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that range.\r\n\r\nThis problem is related to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day Problem 2431\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day  Problem 2432\u003e.","description_html":"\u003cp\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\u003c/p\u003e\u003cp\u003eFor example, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that range.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\"\u003eProblem 2431\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\"\u003eProblem 2432\u003c/a\u003e.\u003c/p\u003e","function_template":"function [t_s,num] = equation_times_run(times)\r\n t_s = '0:00';\r\n num = 0;\r\nend","test_suite":"%%\r\ntimes = {'1:00' '1:59'};\r\ny_correct = ['1:00' 24];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'2:07' '2:29'};\r\ny_correct = ['2:11' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'3:03' '4:04'};\r\ny_correct = ['3:11' 4];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'5:55' '7:11'};\r\ny_correct = ['6:15' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'7:17' '9:00'};\r\ny_correct = ['8:17' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'5:55' '9:00'};\r\ny_correct = ['6:15' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'1:00' '9:59'};\r\ny_correct = ['1:00' 24];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T19:39:50.000Z","updated_at":"2026-01-15T14:27:21.000Z","published_at":"2014-07-15T19:39: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\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\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, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that 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\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2431\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2432\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\"},{\"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":44389,"title":"Just take it easy for a second or two!","description":"Your code needs to take 'exactly' one second or 'exactly' two seconds to run (depending on the input) — accurate to ±0.5 milliseconds.\r\n\r\nThe input will be the number of milliseconds to wait (i.e. 1000 or 2000). No output is required.\r\n\r\nBut the catch is that while waiting you have to 'take it easy'.  In other words, you're not supposed to be working, so the CPU time should account for less than 5% of the time you've waited.  \r\n\r\n-----\r\n\r\nPrevious:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44388 Wait a second!\u003e","description_html":"\u003cp\u003eYour code needs to take 'exactly' one second or 'exactly' two seconds to run (depending on the input) — accurate to ±0.5 milliseconds.\u003c/p\u003e\u003cp\u003eThe input will be the number of milliseconds to wait (i.e. 1000 or 2000). No output is required.\u003c/p\u003e\u003cp\u003eBut the catch is that while waiting you have to 'take it easy'.  In other words, you're not supposed to be working, so the CPU time should account for less than 5% of the time you've waited.\u003c/p\u003e\u003cp\u003e-----\u003c/p\u003e\u003cp\u003ePrevious:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44388\"\u003eWait a second!\u003c/a\u003e\u003c/p\u003e","function_template":"function [a, b, c, d, e, f, g, h, i, j, k] = waitForMe(x, y, z)\r\n\r\nend","test_suite":"%% Anti-hacking code\r\n% Hacking of the Test Suite is not allowed!  \r\n% Additional restrictions will be added if necessary.  \r\nassessFunctionAbsence({'!', 'assert', 'evalin', 'assignin', 'system', 'dos', 'unix'}, 'FileName', 'waitForMe.m')\r\nassert( isempty( regexp(fileread('waitForMe.m'),'[!]+','match') ) , 'No exclamation marks (!) allowed!!!')\r\n\r\n\r\n%% Can you do it once, for a second?\r\nt_correct = 1000;\r\nc = cputime;\r\ntic;\r\nwaitForMe(t_correct);\r\nt = toc\r\ne = cputime - c\r\nassert( abs(t_correct - t*1000) \u003c= 0.5 )\r\nassert( e*1000 / t_correct \u003c= 0.05 )\r\n\r\n\r\n%% Can you do it once, for two seconds?\r\nt_correct = 2000;\r\nc = cputime;\r\ntic;\r\nwaitForMe(t_correct);\r\nt = toc\r\ne = cputime - c\r\nassert( abs(t_correct - t*1000) \u003c= 0.5 )\r\nassert( e*1000 / t_correct \u003c= 0.05 )\r\n\r\n\r\n%% OK, maybe you can do it once, but can you do it more than once?\r\nt_correct = 1000;\r\nfor r = 1 : 3\r\n    c = cputime;\r\n    tic;\r\n    waitForMe(t_correct);\r\n    t = toc\r\n    e = cputime - c\r\n    assert( abs(t_correct - t*1000) \u003c= 0.5 )\r\n    assert( e*1000 / t_correct \u003c= 0.05 )\r\nend;\r\n\r\n\r\n%% OK, maybe you can do it once, but can you do it more than once?\r\nt_correct = 2000;\r\nfor r = 1 : 2\r\n    c = cputime;\r\n    tic;\r\n    waitForMe(t_correct);\r\n    t = toc\r\n    e = cputime - c\r\n    assert( abs(t_correct - t*1000) \u003c= 0.5 )\r\n    assert( e*1000 / t_correct \u003c= 0.05 )\r\nend;\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":9,"test_suite_updated_at":"2017-11-09T13:14:22.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2017-10-19T14:02:48.000Z","updated_at":"2017-11-09T13:14:22.000Z","published_at":"2017-10-19T14:18:48.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\u003eYour code needs to take 'exactly' one second or 'exactly' two seconds to run (depending on the input) — accurate to ±0.5 milliseconds.\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\u003eThe input will be the number of milliseconds to wait (i.e. 1000 or 2000). No output is required.\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\u003eBut the catch is that while waiting you have to 'take it easy'. In other words, you're not supposed to be working, so the CPU time should account for less than 5% of the time you've waited.\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\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\u003ePrevious: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44388\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWait a second!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":44388,"title":"Wait a second!","description":"Your code needs to take 'exactly' one second to run — accurate to ±0.5 milliseconds.  \r\n\r\nThe input will be the number of milliseconds to wait (i.e. 1000).  \r\nNo output is required.  \r\n\r\n-----\r\n\r\n\r\nNext:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44389 Just take it easy for a second or two!\u003e","description_html":"\u003cp\u003eYour code needs to take 'exactly' one second to run — accurate to ±0.5 milliseconds.\u003c/p\u003e\u003cp\u003eThe input will be the number of milliseconds to wait (i.e. 1000).  \r\nNo output is required.\u003c/p\u003e\u003cp\u003e-----\u003c/p\u003e\u003cp\u003eNext:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44389\"\u003eJust take it easy for a second or two!\u003c/a\u003e\u003c/p\u003e","function_template":"function [a, b, c, d, e, f, g, h] = waitForMe(x)\r\n\r\nend","test_suite":"%% Can you do it once?\r\nt_correct = 1000;\r\ntic;\r\nwaitForMe(t_correct);\r\nt = toc\r\nassert( abs(t_correct - t*1000) \u003c= 0.5 )\r\n\r\n\r\n%% OK, maybe you can do it once, but can you do it more than once?\r\nt_correct = 1000;\r\nfor r = 1 : 9\r\n    tic;\r\n    waitForMe(t_correct);\r\n    t = toc\r\n    assert( abs(t_correct - t*1000) \u003c= 0.5 )\r\nend;\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":16,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-10-16T13:43:40.000Z","updated_at":"2026-03-19T09:16:08.000Z","published_at":"2017-10-16T14:02:13.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\u003eYour code needs to take 'exactly' one second to run — accurate to ±0.5 milliseconds.\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\u003eThe input will be the number of milliseconds to wait (i.e. 1000). No output is required.\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\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\u003eNext: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44389\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eJust take it easy for a second or two!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":44518,"title":"Good Morning :)","description":"Just submit your solution between 05:00:00 and 10:00:00 (AM = Ante Meridiem = Before Noon).\r\n\r\n_Note : Consider Cody Server Time_\r\n\r\n\r\n*Related Challenges:*\r\n\r\n# \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44514 Happy Free Wednesday!\u003e \r\n# Happy Free 2019!\r\n# Free March!\r\n# Happy Free 15th Day of a Month!\r\n# Good Morning :)\r\n# Good Night :)\r\n# Leap Year","description_html":"\u003cp\u003eJust submit your solution between 05:00:00 and 10:00:00 (AM = Ante Meridiem = Before Noon).\u003c/p\u003e\u003cp\u003e\u003ci\u003eNote : Consider Cody Server Time\u003c/i\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eRelated Challenges:\u003c/b\u003e\u003c/p\u003e\u003col\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44514\"\u003eHappy Free Wednesday!\u003c/a\u003e\u003c/li\u003e\u003cli\u003eHappy Free 2019!\u003c/li\u003e\u003cli\u003eFree March!\u003c/li\u003e\u003cli\u003eHappy Free 15th Day of a Month!\u003c/li\u003e\u003cli\u003eGood Morning :)\u003c/li\u003e\u003cli\u003eGood Night :)\u003c/li\u003e\u003cli\u003eLeap Year\u003c/li\u003e\u003c/ol\u003e","function_template":"function y = goodMorning(x)\r\n    % If you are not sure how many hours left to 5 AM, just click submit button\r\n    if hour(datetime('now'))\u003e=5 \u0026\u0026 hour(datetime('now'))\u003c=10\r\n        disp('Good Morning! Have a Good Day!')\r\n    else\r\n        hoursTill = [4 3 2 1 0 0 0 0 0 0 18:-1:5];\r\n        disp(['Current hour is ' num2str(hour(datetime('now'))) '. You have to wait about ' num2str(hoursTill(hour(datetime('now')))) ' hours to start to solve this problem!'])\r\n    end\r\nend","test_suite":"%%\r\nx = 1;\r\ngoodMorning(x);\r\nassert(hour(datetime('now'))\u003e=5 \u0026\u0026 hour(datetime('now'))\u003c=10)","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":43,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-02-07T14:05:37.000Z","updated_at":"2026-02-10T08:13:01.000Z","published_at":"2018-02-07T14:05:37.000Z","restored_at":"2018-03-24T21:10:39.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"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\u003eJust submit your solution between 05:00:00 and 10:00:00 (AM = Ante Meridiem = Before Noon).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote : Consider Cody Server Time\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eRelated Challenges:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44514\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free Wednesday!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free 2019!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFree March!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free 15th Day of a Month!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGood Morning :)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGood Night :)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eLeap Year\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":1733,"title":"Calculate value of capacitor","description":"Given the value of resistance and time at which capacitor charges to it's 99%. calculate the value of capacitor","description_html":"\u003cp\u003eGiven the value of resistance and time at which capacitor charges to it's 99%. calculate the value of capacitor\u003c/p\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nr = 1;\r\nt = 1;\r\ny_correct = 0.20000;\r\nassert(isequal(your_fcn_name(r,t),y_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":14448,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":97,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-22T11:45:36.000Z","updated_at":"2026-03-09T20:57:20.000Z","published_at":"2013-07-22T11:45: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\",\"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 the value of resistance and time at which capacitor charges to it's 99%. calculate the value of capacitor\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":44514,"title":"Happy Free Wednesday!","description":"Just submit your solution on any Wednesday. \r\n\r\n*Related Challenges:*\r\n\r\n# Happy Free Wednesday!\r\n# Happy Free 2019!\r\n# Happy Free March!\r\n# Happy Free 15th Day of a Month!\r\n# \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44518 Good Morning :)\u003e\r\n# Good Night :)\r\n# Leap Year","description_html":"\u003cp\u003eJust submit your solution on any Wednesday.\u003c/p\u003e\u003cp\u003e\u003cb\u003eRelated Challenges:\u003c/b\u003e\u003c/p\u003e\u003col\u003e\u003cli\u003eHappy Free Wednesday!\u003c/li\u003e\u003cli\u003eHappy Free 2019!\u003c/li\u003e\u003cli\u003eHappy Free March!\u003c/li\u003e\u003cli\u003eHappy Free 15th Day of a Month!\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44518\"\u003eGood Morning :)\u003c/a\u003e\u003c/li\u003e\u003cli\u003eGood Night :)\u003c/li\u003e\u003cli\u003eLeap Year\u003c/li\u003e\u003c/ol\u003e","function_template":"function str = freeWednesday(x)\r\n    % If you're not sure how many days it's been to Wednesday, just click submit button\r\n    if weekday(datetime('today'))==4\r\n        disp('Congrats! It is a happy free Wednesday!')\r\n    else\r\n        daysTill = [3 2 1 0 6 5 4];\r\n        str =  sprintf('You have to wait %d days to solve this problem',daysTill(weekday(datetime('today'))));\r\n    end\r\nend","test_suite":"%%\r\nx = 1;\r\nfreeWednesday(x)\r\nassert(weekday(datetime('today'))==4)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":44,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-02-07T09:30:21.000Z","updated_at":"2026-02-11T11:57:28.000Z","published_at":"2018-02-07T09:30:21.000Z","restored_at":"2018-03-07T18:37:01.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"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\u003eJust submit your solution on any Wednesday.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eRelated Challenges:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free Wednesday!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free 2019!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free March!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHappy Free 15th Day of a Month!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44518\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGood Morning :)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGood Night :)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eLeap Year\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":58693,"title":"convert 24 hour time to 12 hour time ","description":"convert 24 hour time to 12 hour time \r\n\r\nInput: '13:12'\r\nOutput: '01:12 PM'\r\n\r\nInput: '06:12'\r\nOutput: '06:12 AM'","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; 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: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 201px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 100.5px; transform-origin: 407px 100.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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003econvert 24 hour time to 12 hour time \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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eInput: '13:12'\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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eOutput: '01:12 PM'\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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eInput: '06:12'\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-collapse: preserve; 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 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eOutput: '06:12 AM'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = convert2412(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx =  '13:12';\r\ny_correct = '01:12 PM';\r\nassert(isequal(convert2412(x),y_correct))\r\n\r\n\r\n%%\r\nx =   '06:13';\r\ny_correct =  '06:13 AM';\r\nassert(isequal(convert2412(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3494818,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":13,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2023-07-18T15:59:40.000Z","updated_at":"2026-02-24T11:03:05.000Z","published_at":"2023-07-18T15:59:40.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\u003econvert 24 hour time to 12 hour time \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\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: '13:12'\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: '01:12 PM'\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\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: '06:12'\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: '06:12 AM'\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":1690,"title":"Return elapsed time","description":"Write a function that returns the amount of time it takes to run the function, as measured by tic and toc. Your answer must be correct to within 5 milliseconds.\r\n\r\nBasic template is:\r\n\r\n  tic\r\n  t = timetorun()\r\n  toc","description_html":"\u003cp\u003eWrite a function that returns the amount of time it takes to run the function, as measured by tic and toc. Your answer must be correct to within 5 milliseconds.\u003c/p\u003e\u003cp\u003eBasic template is:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003etic\r\nt = timetorun()\r\ntoc\r\n\u003c/pre\u003e","function_template":"function t = timetorun()\r\n  t = [];\r\nend","test_suite":"%%\r\ntimetorun();\r\nt0 = tic;\r\npause(1)\r\nt1 = timetorun();\r\nt2 = toc(t0)-(t1+1);\r\nassert(abs(t2)\u003c5e-3)\r\n\r\n%%\r\nt0 = tic;\r\npause(1)\r\nt1 = timetorun();\r\nt2 = toc(t0)-(t1+1);\r\nassert(abs(t2)\u003c5e-3)\r\n\r\n%%\r\nt0 = tic;\r\npause(1)\r\nt1 = timetorun();\r\nt2 = toc(t0)-(t1+1);\r\nassert(abs(t2)\u003c5e-3)\r\n\r\n%%\r\nt0 = tic;\r\npause(1)\r\nt1 = timetorun();\r\nt2 = toc(t0)-(t1+1);\r\nassert(abs(t2)\u003c5e-3)\r\n\r\n%%\r\nt0 = tic;\r\npause(1)\r\nt1 = timetorun();\r\nt2 = toc(t0)-(t1+1);\r\nassert(abs(t2)\u003c5e-3)","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":4793,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":24,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-01T01:22:00.000Z","updated_at":"2026-01-03T13:48:05.000Z","published_at":"2013-07-01T01:22:00.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 that returns the amount of time it takes to run the function, as measured by tic and toc. Your answer must be correct to within 5 milliseconds.\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\u003eBasic template is:\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[tic\\nt = timetorun()\\ntoc]]\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":785,"title":"Mandelbrot Number Test [Real+Imaginary]","description":"The \u003chttp://en.wikipedia.org/wiki/Mandelbrot_set Mandelbrot Set\u003e is built around a simple iterative equation.\r\n\r\n z(1)   = c\r\n z(n+1) = z(n)^2 + c\r\n\r\nMandelbrot numbers remain bounded for n through infinity.\r\nThese numbers have a real and complex component.\r\n\r\nFor a vector of real and complex components determine if each is a Mandelbrot number.\r\n\r\nIf abs(z)\u003e2 then z will escape to infinity and is thus NOT valid.\r\n\r\n*Input:* [-2; 0.22-0.54i ; 0.25-.54i ; 0.26 ;.125+.125i; 0.25]\r\n\r\n*Output:* [1 ; 0 ; 1 ; 0 ; 1 ; 1]\r\n...Where 1 is for a Valid Mandelbrot\r\n\r\nCleve Moler has a whole chapter on the Mandelbrot set in his book Experiments with MATLAB: \u003chttp://www.mathworks.com/moler/exm/chapters/mandelbrot.pdf Chapter 10, Mandelbrot Set (PDF)\u003e\r\n\r\nProblem based upon \u003chttp://www.mathworks.com/matlabcentral/cody/problems/81-mandelbrot-numbers Cody 81: Mandelbrot Numbers\u003e","description_html":"\u003cp\u003eThe \u003ca href=\"http://en.wikipedia.org/wiki/Mandelbrot_set\"\u003eMandelbrot Set\u003c/a\u003e is built around a simple iterative equation.\u003c/p\u003e\u003cpre\u003e z(1)   = c\r\n z(n+1) = z(n)^2 + c\u003c/pre\u003e\u003cp\u003eMandelbrot numbers remain bounded for n through infinity.\r\nThese numbers have a real and complex component.\u003c/p\u003e\u003cp\u003eFor a vector of real and complex components determine if each is a Mandelbrot number.\u003c/p\u003e\u003cp\u003eIf abs(z)\u003e2 then z will escape to infinity and is thus NOT valid.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e [-2; 0.22-0.54i ; 0.25-.54i ; 0.26 ;.125+.125i; 0.25]\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e [1 ; 0 ; 1 ; 0 ; 1 ; 1]\r\n...Where 1 is for a Valid Mandelbrot\u003c/p\u003e\u003cp\u003eCleve Moler has a whole chapter on the Mandelbrot set in his book Experiments with MATLAB: \u003ca href=\"http://www.mathworks.com/moler/exm/chapters/mandelbrot.pdf\"\u003eChapter 10, Mandelbrot Set (PDF)\u003c/a\u003e\u003c/p\u003e\u003cp\u003eProblem based upon \u003ca href=\"http://www.mathworks.com/matlabcentral/cody/problems/81-mandelbrot-numbers\"\u003eCody 81: Mandelbrot Numbers\u003c/a\u003e\u003c/p\u003e","function_template":"function tf = isMandelbrot(v)\r\n  tf=abs(v)\u003c=2;\r\nend","test_suite":"%%\r\nformat long\r\n\r\nv=[-2; 0.22-0.54i ; 0.25-.54i ; 0.26 ;.125+.125i; 0.25];\r\ntf=isMandelbrot(v);\r\ntf_expected=[1 ; 0 ; 1 ; 0 ; 1 ; 1] ;\r\n\r\nassert(isequal(tf,tf_expected),sprintf('\\n%f %f %f %f %f %f',tf,tf_expected))\r\n%%\r\n\r\nv=-.25*ones(6,1)+(rand(6,1)-.5)/2+i*(rand(6,1)-.5)/2\r\n\r\n%v=[-.5-.25i;-.5+.25i;-.25i;.25i;-.25-.25i;-.25+.25i]\r\n% Bounding Cases\r\n\r\ntf=isMandelbrot(v);\r\ntf_expected=[1 ; 1 ; 1 ; 1 ; 1 ; 1] ;\r\n\r\nassert(isequal(tf,tf_expected),sprintf('\\n%f %f %f %f %f %f',tf,tf_expected))\r\n%%\r\n\r\nv=rand(6,1)-0.25\r\ntf=isMandelbrot(v);\r\n\r\ntf_expected=v\u003c=0.25; % non-imaginary range [-2.0,0.25]\r\n\r\nassert(isequal(tf,tf_expected),sprintf('\\n%f %f %f %f %f %f',v,tf,tf_expected))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":28,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-06-22T13:35:21.000Z","updated_at":"2026-03-04T14:19:08.000Z","published_at":"2012-07-05T03:42:07.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\u003eThe\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Mandelbrot_set\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMandelbrot Set\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is built around a simple iterative equation.\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[ z(1)   = c\\n z(n+1) = z(n)^2 + c]]\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\u003eMandelbrot numbers remain bounded for n through infinity. These numbers have a real and complex component.\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 a vector of real and complex components determine if each is a Mandelbrot number.\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\u003eIf abs(z)\u0026gt;2 then z will escape to infinity and is thus NOT valid.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e [-2; 0.22-0.54i ; 0.25-.54i ; 0.26 ;.125+.125i; 0.25]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e [1 ; 0 ; 1 ; 0 ; 1 ; 1] ...Where 1 is for a Valid Mandelbrot\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\u003eCleve Moler has a whole chapter on the Mandelbrot set in his book Experiments with MATLAB:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/moler/exm/chapters/mandelbrot.pdf\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eChapter 10, Mandelbrot Set (PDF)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\u003eProblem based upon\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/81-mandelbrot-numbers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody 81: Mandelbrot Numbers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":44437,"title":"How many days in a month?","description":"Return the number of days in a given month in 2017. If the input is not a valid month number, return -1.\r\n\r\nExamples:\r\n\r\n  Input: m = 1\r\n  Outpu: d = 31\r\n\r\n  Input:  m = 2\r\n  Output: d = 28\r\n\r\n  Input:  m = 13\r\n  Output: d = -1\r\n\r\nYou *cannot* use IF statements","description_html":"\u003cp\u003eReturn the number of days in a given month in 2017. If the input is not a valid month number, return -1.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInput: m = 1\r\nOutpu: d = 31\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eInput:  m = 2\r\nOutput: d = 28\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eInput:  m = 13\r\nOutput: d = -1\r\n\u003c/pre\u003e\u003cp\u003eYou \u003cb\u003ecannot\u003c/b\u003e use IF statements\u003c/p\u003e","function_template":"function d = daysInMonth(m)\r\n  d = 31;\r\nend","test_suite":"%%\r\nfiletext = fileread('daysInMonth.m');\r\nassert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')\r\nassert(isempty(strfind(filetext, 'if')),'IF statements are forbidden')\r\n\r\n%%\r\nm = 1;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 2;\r\nd_correct = 28;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 3;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 4;\r\nd_correct = 30;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 5;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 6;\r\nd_correct = 30;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 7;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 8;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 9;\r\nd_correct = 30;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 10;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 11;\r\nd_correct = 30;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 12;\r\nd_correct = 31;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = 13;\r\nd_correct = -1;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n%%\r\nm = randi([-100 0]);\r\nd_correct = -1;\r\nassert(isequal(daysInMonth(m),d_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":140356,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":495,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-12-03T20:28:10.000Z","updated_at":"2026-04-02T12:47:30.000Z","published_at":"2017-12-03T20:28:10.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 the number of days in a given month in 2017. If the input is not a valid month number, return -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\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[Input: m = 1\\nOutpu: d = 31\\n\\nInput:  m = 2\\nOutput: d = 28\\n\\nInput:  m = 13\\nOutput: d = -1]]\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\u003eYou\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecannot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e use IF statements\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":326,"title":"Tricky timing","description":"Write a function that takes between 0.5 seconds and 0.6 seconds to run.","description_html":"\u003cp\u003eWrite a function that takes between 0.5 seconds and 0.6 seconds to run.\u003c/p\u003e","function_template":"function y=timing(x)\r\ny=0;\r\nend","test_suite":"%%\r\ntic;\r\ny=foo(1);\r\nt2=toc\r\nassert((t2\u003e.5)\u0026\u0026(t2\u003c.6))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":5,"created_by":1022,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":184,"test_suite_updated_at":"2012-02-16T05:53:51.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-16T05:53:51.000Z","updated_at":"2026-02-10T21:42:59.000Z","published_at":"2012-02-16T05:53: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\",\"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\u003eWrite a function that takes between 0.5 seconds and 0.6 seconds to run.\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":56578,"title":"Check if a year is a leap year or not","description":"Return 1 if a given year is a leap year or 0 if it is not","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; 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: none solid 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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eReturn 1 if a given year is a leap year or 0 if it is not\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 2005;\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = 1800;\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 2000;\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 2400;\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":2801458,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":31,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-11-10T13:59:55.000Z","updated_at":"2026-01-11T20:06:55.000Z","published_at":"2022-11-10T13:59:55.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\u003eReturn 1 if a given year is a leap year or 0 if it is not\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":328,"title":"Trickier Timing","description":"You solution should return control to main program only when the current time ends in either a 5 or 0 (e.g. the current seconds are 0 or a multiple of 5)","description_html":"\u003cp\u003eYou solution should return control to main program only when the current time ends in either a 5 or 0 (e.g. the current seconds are 0 or a multiple of 5)\u003c/p\u003e","function_template":"function y = timing(x)\r\n  y = x;\r\nend","test_suite":"%%\r\ny=timing(1);\r\ny = datevec(now);\r\ny=mod(round(y(6)),5);\r\nassert(isequal(y,0))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":1022,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":78,"test_suite_updated_at":"2012-02-16T13:40:18.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-16T13:40:18.000Z","updated_at":"2025-09-17T17:00:55.000Z","published_at":"2012-02-16T13:40: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\u003eYou solution should return control to main program only when the current time ends in either a 5 or 0 (e.g. the current seconds are 0 or a multiple of 5)\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":45848,"title":"What is the current time in Darwin, Australia?","description":"Traders need to track exchange calendars and trading hours in detail, and account for time zone differences and daylight savings offsets. These can be tricky in cities with half-hour and quarter-hour offset to UTC. \u003chttps://en.wikipedia.org/wiki/List_of_stock_exchange_trading_hours\u003e\r\n\r\nMATLAB comes to rescue!\r\n\u003chttps://www.mathworks.com/help/matlab/ref/datetime.html\u003e\r\n\r\nYou are given an array with UTC date and time as *[year, month, day, hour, minute]* and a char array with the name of the time zone.\r\nReturn a char array with the current date and time in the specified time zone, in the format *'MMM-dd-yyyy HH:mm'*.\r\n\r\nFor example, for inputs *[2020 6 9 21 50 0]* and *'Australia/Dawin'*, you should get *'Jun-10-2020 07:20'* in return.","description_html":"\u003cp\u003eTraders need to track exchange calendars and trading hours in detail, and account for time zone differences and daylight savings offsets. These can be tricky in cities with half-hour and quarter-hour offset to UTC. \u003ca href = \"https://en.wikipedia.org/wiki/List_of_stock_exchange_trading_hours\"\u003ehttps://en.wikipedia.org/wiki/List_of_stock_exchange_trading_hours\u003c/a\u003e\u003c/p\u003e\u003cp\u003eMATLAB comes to rescue! \u003ca href = \"https://www.mathworks.com/help/matlab/ref/datetime.html\"\u003ehttps://www.mathworks.com/help/matlab/ref/datetime.html\u003c/a\u003e\u003c/p\u003e\u003cp\u003eYou are given an array with UTC date and time as \u003cb\u003e[year, month, day, hour, minute]\u003c/b\u003e and a char array with the name of the time zone.\r\nReturn a char array with the current date and time in the specified time zone, in the format \u003cb\u003e'MMM-dd-yyyy HH:mm'\u003c/b\u003e.\u003c/p\u003e\u003cp\u003eFor example, for inputs \u003cb\u003e[2020 6 9 21 50 0]\u003c/b\u003e and \u003cb\u003e'Australia/Dawin'\u003c/b\u003e, you should get \u003cb\u003e'Jun-10-2020 07:20'\u003c/b\u003e in return.\u003c/p\u003e","function_template":"function [dateTime] = world_time(td,tz)\r\n  dateTime = now;\r\n  offset = 0;\r\nend","test_suite":"%%\r\ntz = 'Australia/Darwin';\r\ntd = [2020 6 9 21 50 0];\r\ny_correct = 'Jun-10-2020 07:20';\r\nassert(isequal(world_time(td,tz),y_correct))\r\n%%\r\ntz = 'America/St_Johns';\r\ntd = [2000 1 1 10 05 0];\r\ny_correct = 'Jan-01-2000 06:35';\r\nassert(isequal(world_time(td,tz),y_correct))\r\n%%\r\ntz = 'Asia/Calcutta';\r\ntd = [1999 9 9 9 9 9];\r\ny_correct = 'Sep-09-1999 14:39';\r\nassert(isequal(world_time(td,tz),y_correct))\r\n%%\r\ntz = 'Asia/Katmandu';\r\ntd = [2029 12 31 11 59 00];\r\ny_correct = 'Dec-31-2029 17:44';\r\nassert(isequal(world_time(td,tz),y_correct))\r\n%%\r\ntz = 'Atlantic/Bermuda';\r\ntd = [1945 12 05 10 04 00];\r\ny_correct = 'Dec-05-1945 06:04';\r\nassert(isequal(world_time(td,tz),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":452188,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":13,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-06-10T02:51:35.000Z","updated_at":"2025-11-26T20:54:03.000Z","published_at":"2020-06-10T02:51:35.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\u003eTraders need to track exchange calendars and trading hours in detail, and account for time zone differences and daylight savings offsets. These can be tricky in cities with half-hour and quarter-hour offset to UTC.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/List_of_stock_exchange_trading_hours\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/List_of_stock_exchange_trading_hours\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\u003eMATLAB comes to rescue!\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/help/matlab/ref/datetime.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/help/matlab/ref/datetime.html\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\u003eYou are given an array with UTC date and time as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[year, month, day, hour, minute]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and a char array with the name of the time zone. Return a char array with the current date and time in the specified time zone, in the format\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e'MMM-dd-yyyy HH:mm'\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\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\u003eFor example, for inputs\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[2020 6 9 21 50 0]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e'Australia/Dawin'\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, you should get\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e'Jun-10-2020 07:20'\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in return.\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":43612,"title":"time of day","description":"Calculate the time of day in days, hours, minutes or seconds passed since the beginning of the day, depending on the unit. The unit is given as a string: \r\n\r\n  validUnits = {'nanoseconds'; 'microseconds'; 'milliseconds'; ...\r\n  'seconds'; 'minutes'; 'hours'; 'days'};","description_html":"\u003cp\u003eCalculate the time of day in days, hours, minutes or seconds passed since the beginning of the day, depending on the unit. The unit is given as a string:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003evalidUnits = {'nanoseconds'; 'microseconds'; 'milliseconds'; ...\r\n'seconds'; 'minutes'; 'hours'; 'days'};\r\n\u003c/pre\u003e","function_template":"function y = timeOfDay(x, unit)\r\n  y = 1;\r\nend","test_suite":"%%\r\nx = '12-Jan-2000 00:06:16';\r\ny_correct = 376 * 1e9;\r\nunits = 'nanoseconds';\r\nassert(abs(timeOfDay(x, units) - y_correct) / y_correct \u003c 1e-3)\r\n\r\n%%\r\nx = '12-Jan-2000 00:06:16';\r\ny_correct = 0.10444444;\r\nunits = 'hours';\r\nassert(abs(timeOfDay(x, units) - y_correct) / y_correct \u003c 1e-3)\r\n\r\n%%\r\nx = '11-Nov-1911 11:11:11';\r\ny_correct = 40271;\r\nunits = 'seconds';\r\nassert(abs(timeOfDay(x, units) - y_correct) / y_correct \u003c 1e-3)\r\n\r\n%%\r\nx = '11-Nov-1911 11:11:11';\r\ny_correct = 0.4660995;\r\nunits = 'days';\r\nassert(abs(timeOfDay(x, units) - y_correct) / y_correct \u003c 1e-3)\r\n\r\n%%\r\nx = '24-Oct-2016 20:26:28';\r\ny_correct = [73588*1e9 73588*1e6 73588000 ...\r\n    73588 1226.4667 20.441111 0.85171296];\r\nunits = {'nanoseconds', 'microseconds', 'milliseconds',...\r\n    'seconds', 'minutes', 'hours', 'days'};\r\nfor i = 1:numel(y_correct)\r\n    assert(abs(timeOfDay(x, units{i}) - y_correct(i)) / y_correct(i) \u003c 1e-3)\r\nend\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":57323,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":27,"test_suite_updated_at":"2016-12-06T18:54:26.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-24T19:04:23.000Z","updated_at":"2025-12-31T13:52:42.000Z","published_at":"2016-10-24T19:04:23.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\u003eCalculate the time of day in days, hours, minutes or seconds passed since the beginning of the day, depending on the unit. The unit is given 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=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[validUnits = {'nanoseconds'; 'microseconds'; 'milliseconds'; ...\\n'seconds'; 'minutes'; 'hours'; 'days'};]]\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":786,"title":"Top of the Hour : Return from your routine within 1 second of the hour","description":"*Top of the Hour*\r\n\r\nSubmit your routine such that it returns to Cody after the hour and within 1 second of the hour.\r\n\r\nThe test criteria will be two seconds.\r\n\r\n*Inputs: None*\r\n\r\n*Outputs: Unused variable*\r\n\r\n*function x=Top_of_Hour*","description_html":"\u003cp\u003e\u003cb\u003eTop of the Hour\u003c/b\u003e\u003c/p\u003e\u003cp\u003eSubmit your routine such that it returns to Cody after the hour and within 1 second of the hour.\u003c/p\u003e\u003cp\u003eThe test criteria will be two seconds.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInputs: None\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutputs: Unused variable\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003efunction x=Top_of_Hour\u003c/b\u003e\u003c/p\u003e","function_template":"function x=Top_of_Hour\r\n  x=1;\r\n  pause(0.2);\r\nend","test_suite":"%%\r\nformat long\r\nformat compact\r\n\r\ndatestr(now)\r\n\r\nx=Top_of_Hour;\r\n\r\ny=now;\r\ndatestr(y)\r\n\r\nmmss_dec=rem(y*24,1) % hh:59:59 is 0.99972\r\n\r\nPass=0;\r\n\r\nif mmss_dec\u003c2/3600,Pass=1;end % 2 second threshold\r\n\r\n\r\nassert(Pass==1,sprintf('%s',datestr(y)))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":25,"test_suite_updated_at":"2012-06-23T18:04:34.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-06-23T17:49:12.000Z","updated_at":"2026-01-03T13:00:00.000Z","published_at":"2012-06-23T17:59:58.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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eTop of the Hour\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\u003eSubmit your routine such that it returns to Cody after the hour and within 1 second of the hour.\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\u003eThe test criteria will be two seconds.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInputs: None\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutputs: Unused variable\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efunction x=Top_of_Hour\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":43275,"title":"calculate the day of the year from a date string.","description":"'09-Oct-2016' is the 283rd day of the year.\r\nSo\r\n\r\n  doy = dayoftheyear('09-Oct-2016')\r\n\r\nshould return\r\n\r\n  doy = 283","description_html":"\u003cp\u003e'09-Oct-2016' is the 283rd day of the year.\r\nSo\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003edoy = dayoftheyear('09-Oct-2016')\r\n\u003c/pre\u003e\u003cp\u003eshould return\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003edoy = 283\r\n\u003c/pre\u003e","function_template":"function doy = dayoftheyear(date)\r\n  doy = 283;\r\nend","test_suite":"%%\r\nstart = '09-Oct-2016';\r\nfor i = 1:10\r\n    date = datestr(datenum(start) + i);\r\n    doy_correct = 283 + i;\r\n    doy = dayoftheyear(date);\r\n    assert(isequal(doy, doy_correct));\r\nend\r\nstart = '04-Oct-1937';\r\nfor i = 1:10\r\n    date = datestr(datenum(start) + i);\r\n    doy_correct = 277 + i;\r\n    doy = dayoftheyear(date);\r\n    assert(isequal(doy, doy_correct));\r\nend","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":57323,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":128,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-09T11:24:48.000Z","updated_at":"2026-01-04T23:58:05.000Z","published_at":"2016-10-09T11:24:48.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\u003e'09-Oct-2016' is the 283rd day of the year. So\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[doy = dayoftheyear('09-Oct-2016')]]\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\u003eshould return\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[doy = 283]]\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":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":43611,"title":"microseconds passed today","description":"Calculate the amount of microseconds passed for a given date string. Return the value, rounded to the nearest integer, as a string.","description_html":"\u003cp\u003eCalculate the amount of microseconds passed for a given date string. Return the value, rounded to the nearest integer, as a string.\u003c/p\u003e","function_template":"function y = microsecondsPassedToday(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = '24-Oct-2016 20:26:28';\r\ny_correct = '73588000000';\r\nassert(isequal(microsecondsPassedToday(x),y_correct))\r\n\r\n%%\r\nx = '24-Oct-2016 20:29:48';\r\ny_correct = '73788000000';\r\nassert(isequal(microsecondsPassedToday(x),y_correct))\r\n\r\n%%\r\nx = '14-Feb-2002 08:19:04';\r\ny_correct = '29944000000';\r\nassert(isequal(microsecondsPassedToday(x),y_correct))\r\n\r\n%%\r\nx = '07-Apr-1902 10:00:00';\r\ny_correct = '36000000000';\r\nassert(isequal(microsecondsPassedToday(x),y_correct))\r\n\r\n%%\r\nx = '11-Nov-1911 11:11:11';\r\ny_correct = '40271000000';\r\nassert(isequal(microsecondsPassedToday(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":57323,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":85,"test_suite_updated_at":"2016-12-05T19:16:06.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-24T18:40:02.000Z","updated_at":"2026-01-04T23:59:11.000Z","published_at":"2016-10-24T18:40:02.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\u003eCalculate the amount of microseconds passed for a given date string. Return the value, rounded to the nearest integer, as a string.\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":2431,"title":"Power Times (of the day)","description":"Many times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\r\n\r\n - equation written forward, \"=\" doesn't coincide with \":\" --\u003e add 1 to output (e.g., 2:38)\r\n\r\n - equation written forward, \"=\" does coincide with \":\" -- \u003e add 100 to output (e.g., 8:23)\r\n\r\n - equation written backward, \"=\" doesn't coincide with \":\" --\u003e add 10 to output (e.g., 3:28)\r\n\r\n - equation written backward, \"=\" does coincide with \":\" --\u003e add 1000 to output (e.g., 9:23)\r\n\r\nExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=1).\r\n\r\nThis problem is related to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day  Problem 2432\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day Problem 2433\u003e.","description_html":"\u003cp\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\u003c/p\u003e\u003cpre\u003e - equation written forward, \"=\" doesn't coincide with \":\" --\u0026gt; add 1 to output (e.g., 2:38)\u003c/pre\u003e\u003cpre\u003e - equation written forward, \"=\" does coincide with \":\" -- \u0026gt; add 100 to output (e.g., 8:23)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" doesn't coincide with \":\" --\u0026gt; add 10 to output (e.g., 3:28)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" does coincide with \":\" --\u0026gt; add 1000 to output (e.g., 9:23)\u003c/pre\u003e\u003cp\u003eExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=1).\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\"\u003eProblem 2432\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\"\u003eProblem 2433\u003c/a\u003e.\u003c/p\u003e","function_template":"function out = power_time(time)\r\n out = 0;\r\nend","test_suite":"%%\r\ntime = '2:38';\r\ny_correct = 1;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '8:23';\r\ny_correct = 100;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '3:28';\r\ny_correct = 10;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '9:23';\r\ny_correct = 1000;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '7:22';\r\ny_correct = 0;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:31';\r\ny_correct = 1001;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '4:22';\r\ny_correct = 1100;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:02';\r\ny_correct = 1000;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '4:12';\r\ny_correct = 0;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '5:15';\r\ny_correct = 1001;\r\nassert(isequal(power_time(time),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":8,"created_by":26769,"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":45,"created_at":"2014-07-15T18:00:06.000Z","updated_at":"2026-01-15T14:21:57.000Z","published_at":"2014-07-15T18:00: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\",\"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\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\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[ - equation written forward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 1 to output (e.g., 2:38)\\n\\n - equation written forward, \\\"=\\\" does coincide with \\\":\\\" -- \u003e add 100 to output (e.g., 8:23)\\n\\n - equation written backward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 10 to output (e.g., 3:28)\\n\\n - equation written backward, \\\"=\\\" does coincide with \\\":\\\" --\u003e add 1000 to output (e.g., 9:23)]]\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\u003eExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2432\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2433\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\"},{\"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":44390,"title":"Test your luck!","description":"This problem is designed to test your luck, and therefore the contents of your function are irrelevant. In order to do so, the test suit will run your function (it is your function and therefore it has your luck) and check the time. If the last two digits of the time in milliseconds are lesser than 20 (0-19), your function will be considered to have succeeded, otherwise it will be considered to have failed. This procees is repeated 200 times, and if your function succeeds all tests, you will have solved the problem, thus proving you are incredibly lucky!\r\n\r\n*Note:* If you noticed, the probability of solving the problem (assuming the time is completely random) is 5^-200, in honor of the 5th anniversay of Cody.","description_html":"\u003cp\u003eThis problem is designed to test your luck, and therefore the contents of your function are irrelevant. In order to do so, the test suit will run your function (it is your function and therefore it has your luck) and check the time. If the last two digits of the time in milliseconds are lesser than 20 (0-19), your function will be considered to have succeeded, otherwise it will be considered to have failed. This procees is repeated 200 times, and if your function succeeds all tests, you will have solved the problem, thus proving you are incredibly lucky!\u003c/p\u003e\u003cp\u003e\u003cb\u003eNote:\u003c/b\u003e If you noticed, the probability of solving the problem (assuming the time is completely random) is 5^-200, in honor of the 5th anniversay of Cody.\u003c/p\u003e","function_template":"function y = lucky(x)\r\n  % \"Hay algunos que nacen con estrella y otros estrellados, y aunque tú no lo quieras creer, yo soy de las estrelladísimas...\" - Frida Kahlo.\r\nend","test_suite":"%%\r\nassessFunctionAbsence({'horzcat','vertcat','char','tic','toc','delete','str2num','fopen','regexp','regexpi','regexprep','rng','assert','!','system','unix','figure','fileread'},'FileName','lucky.m');\r\n\r\n%%\r\nfid=fopen('lucky.m','r','n','US-ASCII');\r\nstr=fread(fid,'*char').';\r\nassert(length(str)\u003c25000);\r\nassert(isempty(regexp(str,'[\\r\\n;, ]+!')));\r\n\r\n%%\r\nlucky([]);\r\nfid=fopen('luckyTest.p','Wb');\r\nfwrite(fid,str2num(['[118 48 48 46 48 48 118 48 48 46 48 48 0 4 144 28 164 79 31'...\r\n    ' 181 0 0 0 75 0 0 0 144 0 0 0 190 141 122 182 196 246 214 83 209 188 114 221'...\r\n    ' 133 197 147 17 234 99 73 193 98 152 38 155 52 251 250 28 66 253 209 9 177 '...\r\n    '255 155 78 197 239 82 48 145 6 26 125 43 176 171 165 121 249 19 63 213 105 '...\r\n    '31 179 114 39 113 75 207 16 200 133 180 56 143 164 251 173 46 7 63 221 205 '...\r\n    '208 233 113 250 244 105 142 107 211 121 250 246 7 146 101 152 113 160 185 '...\r\n    '186 57 18 151 224 103 224 196 10 188 214 232 173 15 223 141 230 78 165 31 '...\r\n    '65 133 137 11 60 123 144 67 140 64 2 39 104 204 118 88 116 109 185 202 231 '...\r\n    '219 254 45 0 146 24 47 74 201 124]']));\r\nfclose(fid);\r\nluckyTest();","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":54457,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":10,"test_suite_updated_at":"2020-04-26T02:00:07.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2017-10-23T02:05:39.000Z","updated_at":"2025-07-13T03:09:45.000Z","published_at":"2017-10-23T02:09:45.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\u003eThis problem is designed to test your luck, and therefore the contents of your function are irrelevant. In order to do so, the test suit will run your function (it is your function and therefore it has your luck) and check the time. If the last two digits of the time in milliseconds are lesser than 20 (0-19), your function will be considered to have succeeded, otherwise it will be considered to have failed. This procees is repeated 200 times, and if your function succeeds all tests, you will have solved the problem, thus proving you are incredibly lucky!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e If you noticed, the probability of solving the problem (assuming the time is completely random) is 5^-200, in honor of the 5th anniversay of Cody.\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":44349,"title":"Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock.","description":"Submit your answer to this problem a multiple of 5 seconds after the hour.  Your answer is irrelevant; the only thing that matters is *when* you submit it.  It can be 5 seconds after, 555 seconds, or 3300 seconds after the hour.  So long as the number of seconds is a multiple of five, you are good to go.","description_html":"\u003cp\u003eSubmit your answer to this problem a multiple of 5 seconds after the hour.  Your answer is irrelevant; the only thing that matters is \u003cb\u003ewhen\u003c/b\u003e you submit it.  It can be 5 seconds after, 555 seconds, or 3300 seconds after the hour.  So long as the number of seconds is a multiple of five, you are good to go.\u003c/p\u003e","function_template":"function y = time_for_five(x)\r\n  y = 555555;\r\nend","test_suite":"%%\r\nfiletext = fileread('time_for_five.m');\r\nassert(isempty(strfind(filetext, 'fopen')));\r\nassert(isempty(strfind(filetext, 'assert')));\r\n%%\r\ny = time_for_five(5);\r\n\r\na=clock;\r\n\r\nif mod(floor(a(6)),5)==0\r\n    y_correct= y\r\nelse\r\n    y_correct = NaN;\r\nend\r\n\r\nassert(isequal(y,y_correct))","published":true,"deleted":false,"likes_count":14,"comments_count":13,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":957,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-26T17:42:30.000Z","updated_at":"2026-03-18T13:20:10.000Z","published_at":"2017-10-16T01:45:08.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\u003eSubmit your answer to this problem a multiple of 5 seconds after the hour. Your answer is irrelevant; the only thing that matters is\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ewhen\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e you submit it. It can be 5 seconds after, 555 seconds, or 3300 seconds after the hour. So long as the number of seconds is a multiple of five, you are good to go.\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":2432,"title":"Equation Times (of the day)","description":"Many times throughout the day can represent mathematical equations. In this problem, we focus on times that include the four basic operations (+,-,*,/). For example, 6:17 can be written as 6=1+7. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is an equation time, and if so, which basic operation it uses. There are also four types of equations that are categorized here, and a given time can fit more than one category:\r\n\r\n - equation written forward, \"=\" doesn't coincide with \":\" --\u003e add 1 to output (e.g., 2:35, 2+3=5)\r\n\r\n - equation written forward, \"=\" does coincide with \":\" -- \u003e add 100 to output (e.g., 2:53, 2=5-3)\r\n\r\n - equation written backward, \"=\" doesn't coincide with \":\" --\u003e add 10 to output (e.g., 3:26, 6=2*3)\r\n\r\n - equation written backward, \"=\" does coincide with \":\" --\u003e add 1000 to output (e.g., 4:28, 8/2=4)\r\n\r\nNote that some of these combinations are tied to each other due to the commutative nature of + and * and the inverse relation of +,- and **,/. The output should be a 4x2 matrix with 0s or 1s in the first column dependent on whether each operation (+,-,*,/) is applicable to a given time and the totals in the second column. Examples include: \r\n\r\n4:22 | out = [1 1100; 1 1; 1 1100; 1 1]; since 4=2+2, 2+2=4; 4-2=2; 4=2*2, 2*2=4; 4/2=2.\r\n\r\n5:15 | out = [0 0; 0 0; 1 1111; 1 1001]; since 5*1=5, 5=1*5, 5*1=5, 5=1*5; 5/1=5, 5/1=5.\r\n\r\nThis problem is related to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day Problem 2431\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day Problem 2433\u003e.","description_html":"\u003cp\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that include the four basic operations (+,-,*,/). For example, 6:17 can be written as 6=1+7. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is an equation time, and if so, which basic operation it uses. There are also four types of equations that are categorized here, and a given time can fit more than one category:\u003c/p\u003e\u003cpre\u003e - equation written forward, \"=\" doesn't coincide with \":\" --\u0026gt; add 1 to output (e.g., 2:35, 2+3=5)\u003c/pre\u003e\u003cpre\u003e - equation written forward, \"=\" does coincide with \":\" -- \u0026gt; add 100 to output (e.g., 2:53, 2=5-3)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" doesn't coincide with \":\" --\u0026gt; add 10 to output (e.g., 3:26, 6=2*3)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" does coincide with \":\" --\u0026gt; add 1000 to output (e.g., 4:28, 8/2=4)\u003c/pre\u003e\u003cp\u003eNote that some of these combinations are tied to each other due to the commutative nature of + and * and the inverse relation of +,- and ,/. The output should be a 4x2 matrix with 0s or 1s in the first column dependent on whether each operation (+,-,*,/) is applicable to a given time and the totals in the second column. Examples include:\u003c/p\u003e\u003cp\u003e4:22 | out = [1 1100; 1 1; 1 1100; 1 1]; since 4=2+2, 2+2=4; 4-2=2; 4=2*2, 2*2=4; 4/2=2.\u003c/p\u003e\u003cp\u003e5:15 | out = [0 0; 0 0; 1 1111; 1 1001]; since 5*1=5, 5=1*5, 5*1=5, 5=1*5; 5/1=5, 5/1=5.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\"\u003eProblem 2431\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\"\u003eProblem 2433\u003c/a\u003e.\u003c/p\u003e","function_template":"function out = equation_time(time)\r\n out = 0;\r\nend","test_suite":"%%\r\ntime = '4:22';\r\ny_correct = [1 1100;\r\n\t1 1;\r\n\t1 1100;\r\n\t1 1];\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '2:38';\r\ny_correct = zeros(4,2);\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '5:15';\r\ny_correct = [0 0;\r\n\t0 0;\r\n\t1 1111;\r\n \t1 1001];\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:23';\r\ny_correct = [1 11;\r\n\t1 1000;\r\n\t0 0;\r\n \t0 0];\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:02';\r\ny_correct = zeros(4,2);\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:11';\r\ny_correct = [0 0;\r\n\t0 0;\r\n\t1 1111;\r\n \t1 1111];\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '2:11';\r\ny_correct = [1 1100;\r\n\t1 1;\r\n\t0 0;\r\n \t0 0];\r\nassert(isequal(equation_time(time),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":79,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T18:39:02.000Z","updated_at":"2026-01-15T14:29:10.000Z","published_at":"2014-07-15T18:39:02.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\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that include the four basic operations (+,-,*,/). For example, 6:17 can be written as 6=1+7. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is an equation time, and if so, which basic operation it uses. There are also four types of equations that are categorized here, and a given time can fit more than one category:\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[ - equation written forward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 1 to output (e.g., 2:35, 2+3=5)\\n\\n - equation written forward, \\\"=\\\" does coincide with \\\":\\\" -- \u003e add 100 to output (e.g., 2:53, 2=5-3)\\n\\n - equation written backward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 10 to output (e.g., 3:26, 6=2*3)\\n\\n - equation written backward, \\\"=\\\" does coincide with \\\":\\\" --\u003e add 1000 to output (e.g., 4:28, 8/2=4)]]\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\u003eNote that some of these combinations are tied to each other due to the commutative nature of + and * and the inverse relation of +,- and ,/. The output should be a 4x2 matrix with 0s or 1s in the first column dependent on whether each operation (+,-,*,/) is applicable to a given time and the totals in the second column. Examples include:\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\u003e4:22 | out = [1 1100; 1 1; 1 1100; 1 1]; since 4=2+2, 2+2=4; 4-2=2; 4=2*2, 2*2=4; 4/2=2.\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\u003e5:15 | out = [0 0; 0 0; 1 1111; 1 1001]; since 5*1=5, 5=1*5, 5*1=5, 5=1*5; 5/1=5, 5/1=5.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2431\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2433\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\"},{\"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":43610,"title":"nanoseconds passed today","description":"Calculate the amount of nanoseconds passed in the current day of a certain date string.","description_html":"\u003cp\u003eCalculate the amount of nanoseconds passed in the current day of a certain date string.\u003c/p\u003e","function_template":"function y = nanosecondsPassedToday(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = '24-Oct-2016 20:26:28';\r\ny_correct = 73587999999895.69;\r\nassert(abs(nanosecondsPassedToday(x)-y_correct)\u003c0.05)\r\n\r\n%%\r\nx = '24-Oct-2016 20:29:48';\r\ny_correct = 73788000001385.8;\r\nassert(abs(nanosecondsPassedToday(x)-y_correct)\u003c0.05)\r\n\r\n%%\r\nx = '31-Oct-2016 13:19:42';\r\ny_correct = 47982000002637.5;\r\nassert(abs(nanosecondsPassedToday(x)-y_correct)\u003c0.05)\r\n\r\n%%\r\nx = '04-Jan-1972 07:24:17';\r\ny_correct = 26656999999657.3;\r\nassert(abs(nanosecondsPassedToday(x)-y_correct)\u003c0.05)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":9,"created_by":57323,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":17,"test_suite_updated_at":"2016-12-05T18:57:37.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-24T18:32:01.000Z","updated_at":"2026-03-19T08:27:13.000Z","published_at":"2016-10-24T18:32:48.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\u003eCalculate the amount of nanoseconds passed in the current day of a certain date string.\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":62,"title":"Elapsed Time","description":"Given two date strings d1 and d2 of the form yyyy/mm/dd HH:MM:SS (assume hours HH is in 24 hour mode), determine how much time, in decimal hours, separates them. Assume d2 is always later than d1.\n\nExample:\n\n Input d1 = '2010/12/14 12:00:00'\n Input d2 = '2010/12/14 13:06:36'\n Output elapsed is 1.11","description_html":"\u003cp\u003eGiven two date strings d1 and d2 of the form yyyy/mm/dd HH:MM:SS (assume hours HH is in 24 hour mode), determine how much time, in decimal hours, separates them. Assume d2 is always later than d1.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e Input d1 = '2010/12/14 12:00:00'\n Input d2 = '2010/12/14 13:06:36'\n Output elapsed is 1.11\u003c/pre\u003e","function_template":"function elapsed = elapsed_time(d1,d2)\n  elapsed = 0;\nend","test_suite":"%% \nd1 = '2010/12/14 12:00:00';\nd2 = '2010/12/17 17:06:00';\nelapsed = 77.1;\nassert(abs(elapsed_time(d1,d2) - elapsed) \u003c 1e-6)\n\n%% \nd1 = '2010/12/14 12:00:00';\nd2 = '2010/12/14 12:00:01';\nelapsed = 1/3600;\nassert(abs(elapsed_time(d1,d2) - elapsed) \u003c 1e-6)\n\n%% \nd1 = '1924/1/7 12:45:00';\nd2 = '2010/12/14 17:06:00';\nelapsed = 762076.35;\nassert(abs(elapsed_time(d1,d2) - elapsed) \u003c 1e-6)\n\n%%\nd1 = '2010/12/14 12:00:00'\nd2 = '2010/12/14 13:06:36'\nelapsed = 1.11;\nassert(abs(elapsed_time(d1,d2) - elapsed) \u003c 1e-6)\n","published":true,"deleted":false,"likes_count":18,"comments_count":12,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3038,"test_suite_updated_at":"2012-01-18T01:00:26.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:26.000Z","updated_at":"2026-02-14T15:34:50.000Z","published_at":"2012-01-18T01:00:26.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 two date strings d1 and d2 of the form yyyy/mm/dd HH:MM:SS (assume hours HH is in 24 hour mode), determine how much time, in decimal hours, separates them. Assume d2 is always later than d1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input d1 = '2010/12/14 12:00:00'\\n Input d2 = '2010/12/14 13:06:36'\\n Output elapsed is 1.11]]\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\"}]}"},{"id":51808,"title":"Determine when snow started","description":"R.P. Agnew posed the following problem: It starts snowing in the morning and continues steadily throughout the day. A snowplow that removes snow at a constant rate starts plowing at noon. It plows 2 miles in the first hour and 1 mile in the second.  What time did it start snowing?\r\nWrite a function to solve this problem. The inputs will be the time the snowplow started (given as a string), two consecutive time intervals  and , and the distances  and  traveled in the first and second time intervals, respectively. Return the time that the snow started, rounded to the nearest minute, as a string.","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: 135.25px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 67.625px; transform-origin: 407px 67.625px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; 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 31.5px; text-align: left; transform-origin: 384px 31.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: 367.333px 7.91667px; transform-origin: 367.333px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eR.P. Agnew posed the following problem: It starts snowing in the morning and continues steadily throughout the day. A snowplow that removes snow at a constant rate starts plowing at noon. It plows 2 miles in the first hour and 1 mile in the second.\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: 3.88333px 7.91667px; transform-origin: 3.88333px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e  \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: 95.2917px 7.91667px; transform-origin: 95.2917px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWhat time did it start snowing?\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63.25px; 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 31.625px; text-align: left; transform-origin: 384px 31.625px; 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: 380.275px 7.91667px; transform-origin: 380.275px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to solve this problem. The inputs will be the time the snowplow started (given as a string), two consecutive time intervals \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAAoCAYAAACB4MgqAAABk0lEQVRYhe2X7c2DMAyEnx3YoAuwABMwARuwQTdgBWZ4R2AHVmAGVqA/goVLITXh662UkyJVTSDnq892ISIiIuI/oADSu0lsRQIMwN/dRLbiiSM+AI+buWxCz0S8upmLGQUT6QEXxB7VWyA/gNdXdONlDftVr7ko3bLxonxcQrzDGdaKBGfsASfC6WhwJAUdE/nS8HwyntMeaXBmL9kWvBnpAkGd7xbVMxxJUXvApctzfNcpqHFKaXIJ7+pZTVYxGfsUlQUP1k2oa7o1X1umNDkVQm5JHQnKqro+b/FFMCQdas8ZKWsWFbUvfLNOjvNNcI2Xi3yXzFX3nZUg+5X9jMkDW3zzgQ5bLuqG5Bu+pISu/YIStLwviLiobXlYmpNv+ErV/rfyt4t4w7bOphvSUgUq+QxsLa2CiYuC1fjZsnRuLg1f0nik+5a4inUocV0pQtdc9V59X+D3ThDxeZUIXfMxQO+1+LtmEHGZKY5YOl1y7HPJLnPeiUj8avwscZkgf4Z4yns/kD/Tp87tERERERHX4wVxHshqCdrcFQAAAABJRU5ErkJggg==\" alt=\"dt1\" style=\"width: 23px; height: 20px;\" width=\"23\" height=\"20\"\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: 15.5583px 7.91667px; transform-origin: 15.5583px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAAoCAYAAACB4MgqAAABu0lEQVRYhe2X7bGCMBBFTw90YAM0QAVUQAd0YAe0QA2vBHqwBWqwBfyR7LAghI0aec7kzGR0NMjNZb+ETCaT+Q80QHm2iFgKYAL+zhYSyxUnfAIuJ2uJ4s4svDtZi5mGWfSEO8Q7rt+A+gO6Dhn9zQbed73nS+FW+RvVfonwEZewVgpcYk84E5Iz4EQKI7P41nB94ffpHBlwyd4Sd3gz5YZAHe8W1yucSHF7woXL1f9WEnqcU1pcwdI9a5J1zImdxGXhwn4S6ppujdcbc5gkRcRtuSOHsrqu91vy4mUkHPrAHilrFhd1XmzNOjXLUjvs7DtEbhS6eO16aK8c8r5zr5t/rVkmcRUrfMQWi9ql0PAlJXTrCY48NyMRHzXQiduWaiHNKTR8ler7dfmr2E5+aXRRjWqIvEA3pC0RLc8HO4pfMcTsuFzQ+feWJfV5b/iSxy7dt8VVrBDy1M0VSFeKV9fa9bv6vMGWOz3uqZsa1bpKvLrWY4D+ziJGdJgriswUn1g6XGri5pKBxE0qBR0/9O9KaHCxnXQA+zSStGvRBeGx41Sk2ciMrtfIl/6bxlKynO2PKlQmk8lkfpwHQlTQxUV+5ocAAAAASUVORK5CYII=\" alt=\"dt2\" style=\"width: 23px; height: 20px;\" width=\"23\" height=\"20\"\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: 60.675px 7.91667px; transform-origin: 60.675px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, and the distances \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAoCAYAAABTsMJyAAABrklEQVRoge2XcdGDMAzFfx5wgAEMoGAKcICDOZiFaZgEPGChGmZh3x8h18AGaws7xr6+u97t1jbNy0vSAhkZGRn/GQ1Q7e3EFiiAB3Db25EtcEbIPIByZ19W444nc9nZl1Vo8EQeCLHDquOAHug4uDo14vxpGErGIU3hUOgQxxUOT6iNsFMgwTgjAZrOtcPcx1Dx7LStnxB1SqSdd/gmYvdVjJtLs5HvT7gOB1mHi8nhpwh7tr3Xgy2HV6XjQ42lZL7QrVN9hE1VWtXuiEvVZKjDr9JIiaaoo6reEeU/Dk2lpcOueDJdhO2b2ReSUickFWMCNoIW+dKjcqpO6AO0NXuWmkeNpHiK+iM4wqJtL9HQB6hVdKlzaXD0jCQyqkrIZr1QQ9OmQQKldRNSM6vIdMR1KHuJLj1xqmFtja8bt7De+pNERiN9GX6HDJvXcw/QAgmQppWtG11/m3E4mYzN59Sh6lzw90jPWLVqsv7KfMolkZl2p9ShTxX736vm4N7MryJTIxflFqM09uY6VvlmfhWZb0Um8634KTI9P0CmYnyH9Qihw32qZ2RkZGQcG3/o49PR0PQSVQAAAABJRU5ErkJggg==\" alt=\"dx1\" style=\"width: 25.5px; height: 20px;\" width=\"25.5\" height=\"20\"\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: 15.5583px 7.91667px; transform-origin: 15.5583px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAoCAYAAABTsMJyAAAB2klEQVRoge2Xa7HDIBCFPw9xEAMxEAVVgIM6qINYiIZKwEMtoKEWen/ADoS8IE2ayVzODDOdAssuZ/ewgYKCgoL/DAU0ZzuxByrgAzzPdmQPPLDBfID6ZF++xhsfTHeyL19B4QP5YAO7LDsGeAGai7PTYp2/uSHBGKwoXAoa67jA4AO6Z9ipsJfxwF5QPHd3c4ehYex0WD8p7NRYOdd4EQn3NQzFRe3k+wi9Oyh0uIoOv2XYC+W9dbYMnhXNQcJSM1/ooVOvDJvCtLCtyUvVzRCHp9JIAt3CjrD6xjJ/OCSVlg7r8cHoDNvPYN9SSt0YPgWajX2hFPnS5pid1IPuwZ458VDY9FXYoMILiJVwFYa02w5vLrUBDRmdUy7DmDUJKKvRFVZS6kAe1NQGVDlHpW6m0rhlWnTkwc4RHHTmhvARXWpxGre2xd+yWVgfQy4umRnZ0LnfKaMLgplrQCt8DcCwbmT9k+VskIxJlvIwn7cOYafDvyMvhqw10fqedZnunZ2kfjBWp61DWpXwv6nUMCvzU74lK1mLfSj3GHVgb06x6pX5ED/rFI5Gx0W/nWIobK1c7rsphsKmVxxIxY96ur0gD2TPuB4NeY3tqYg/1ubUsqCgoKCg4Cf4AwgX3Cx1uzyFAAAAAElFTkSuQmCC\" alt=\"dx2\" style=\"width: 25.5px; height: 20px;\" width=\"25.5\" height=\"20\"\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: 184.625px 7.91667px; transform-origin: 184.625px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e traveled in the first and second time intervals, respectively. Return the time that the snow started, rounded to the nearest minute, as a string.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function tstr = snowplow(t0str,dx1,dx2,dt1,dt2)\r\n%  tstr = string denoting the time the snowplow started\r\n%  dt1  = first time interval\r\n%  dt2  = second time interval (immediately follows the first)\r\n%  dx1  = distance plowed during the first interval\r\n%  dx2  = distance plowed during the second interval\r\n\r\n  tstr = datestr((dt2-dt1)*dx2/dx1) + t0str;\r\n","test_suite":"%% Original problem\r\nt0str = '12:00';\r\ndt1 = 1; % hour\r\ndt2 = 1; % hour\r\ndx1 = 2; % miles\r\ndx2 = 1; % mile\r\ntstr_correct = '11:23';\r\nassert(isequal(snowplow(t0str,dx1,dx2,dt1,dt2),tstr_correct))\r\n\r\n%% \r\nt0str = '12:00';\r\ndt1 = 1; % hour\r\ndt2 = 1; % hour\r\ndx1 = 3.22; % km\r\ndx2 = 1.61; % km\r\ntstr_correct = '11:23';\r\nassert(isequal(snowplow(t0str,dx1,dx2,dt1,dt2),tstr_correct))\r\n\r\n%% \r\nt0str = '12:00';\r\ndt1 = 1; % hour\r\ndt2 = 1; % hour\r\ndx1 = 3.11; % km\r\ndx2 = 1.73; % km\r\ntstr_correct = '11:09';\r\nassert(isequal(snowplow(t0str,dx1,dx2,dt1,dt2),tstr_correct))\r\n\r\n%% \r\nt0str = '12:00';\r\ndt1 = 2; % hour\r\ndt2 = 1; % hour\r\ndx1 = 4.24; % km\r\ndx2 = 1.26; % km\r\ntstr_correct = '10:29';\r\nassert(isequal(snowplow(t0str,dx1,dx2,dt1,dt2),tstr_correct))\r\n\r\n%% \r\nt0str = '13:30';\r\ndt1 = 1; % hour\r\ndt2 = 1; % hour\r\ndx1 = 3.11; % km\r\ndx2 = 1.73; % km\r\ntstr_correct = '12:39';\r\nassert(isequal(snowplow(t0str,dx1,dx2,dt1,dt2),tstr_correct))\r\n\r\n%% \r\nt0str = '09:53';\r\ndt1 = 0.75; % hour\r\ndt2 = 1; % hour\r\ndx1 = 2.28; % km\r\ndx2 = 1.99; % km\r\ntstr_correct = '08:35';\r\nassert(isequal(snowplow(t0str,dx1,dx2,dt1,dt2),tstr_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":46909,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":15,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2021-05-22T22:48:59.000Z","updated_at":"2026-01-02T12:00:02.000Z","published_at":"2021-05-22T22:52:55.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\u003eR.P. Agnew posed the following problem: It starts snowing in the morning and continues steadily throughout the day. A snowplow that removes snow at a constant rate starts plowing at noon. It plows 2 miles in the first hour and 1 mile in the second.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e  \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eWhat time did it start snowing?\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\u003eWrite a function to solve this problem. The inputs will be the time the snowplow started (given as a string), two consecutive time intervals \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"dt1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta t_1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"dt2\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta t_2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e, and the distances \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"dx1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta x_1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"dx2\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\Delta x_2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e traveled in the first and second time intervals, respectively. Return the time that the snow started, rounded to the nearest minute, as a string.\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":2433,"title":"Consecutive Equation Times (of the day)","description":"Many times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\r\n\r\nFor example, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that range.\r\n\r\nThis problem is related to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day Problem 2431\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day  Problem 2432\u003e.","description_html":"\u003cp\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\u003c/p\u003e\u003cp\u003eFor example, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that range.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\"\u003eProblem 2431\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\"\u003eProblem 2432\u003c/a\u003e.\u003c/p\u003e","function_template":"function [t_s,num] = equation_times_run(times)\r\n t_s = '0:00';\r\n num = 0;\r\nend","test_suite":"%%\r\ntimes = {'1:00' '1:59'};\r\ny_correct = ['1:00' 24];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'2:07' '2:29'};\r\ny_correct = ['2:11' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'3:03' '4:04'};\r\ny_correct = ['3:11' 4];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'5:55' '7:11'};\r\ny_correct = ['6:15' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'7:17' '9:00'};\r\ny_correct = ['8:17' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'5:55' '9:00'};\r\ny_correct = ['6:15' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'1:00' '9:59'};\r\ny_correct = ['1:00' 24];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T19:39:50.000Z","updated_at":"2026-01-15T14:27:21.000Z","published_at":"2014-07-15T19:39: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\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\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, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that 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\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2431\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2432\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\"},{\"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":44389,"title":"Just take it easy for a second or two!","description":"Your code needs to take 'exactly' one second or 'exactly' two seconds to run (depending on the input) — accurate to ±0.5 milliseconds.\r\n\r\nThe input will be the number of milliseconds to wait (i.e. 1000 or 2000). No output is required.\r\n\r\nBut the catch is that while waiting you have to 'take it easy'.  In other words, you're not supposed to be working, so the CPU time should account for less than 5% of the time you've waited.  \r\n\r\n-----\r\n\r\nPrevious:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44388 Wait a second!\u003e","description_html":"\u003cp\u003eYour code needs to take 'exactly' one second or 'exactly' two seconds to run (depending on the input) — accurate to ±0.5 milliseconds.\u003c/p\u003e\u003cp\u003eThe input will be the number of milliseconds to wait (i.e. 1000 or 2000). No output is required.\u003c/p\u003e\u003cp\u003eBut the catch is that while waiting you have to 'take it easy'.  In other words, you're not supposed to be working, so the CPU time should account for less than 5% of the time you've waited.\u003c/p\u003e\u003cp\u003e-----\u003c/p\u003e\u003cp\u003ePrevious:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44388\"\u003eWait a second!\u003c/a\u003e\u003c/p\u003e","function_template":"function [a, b, c, d, e, f, g, h, i, j, k] = waitForMe(x, y, z)\r\n\r\nend","test_suite":"%% Anti-hacking code\r\n% Hacking of the Test Suite is not allowed!  \r\n% Additional restrictions will be added if necessary.  \r\nassessFunctionAbsence({'!', 'assert', 'evalin', 'assignin', 'system', 'dos', 'unix'}, 'FileName', 'waitForMe.m')\r\nassert( isempty( regexp(fileread('waitForMe.m'),'[!]+','match') ) , 'No exclamation marks (!) allowed!!!')\r\n\r\n\r\n%% Can you do it once, for a second?\r\nt_correct = 1000;\r\nc = cputime;\r\ntic;\r\nwaitForMe(t_correct);\r\nt = toc\r\ne = cputime - c\r\nassert( abs(t_correct - t*1000) \u003c= 0.5 )\r\nassert( e*1000 / t_correct \u003c= 0.05 )\r\n\r\n\r\n%% Can you do it once, for two seconds?\r\nt_correct = 2000;\r\nc = cputime;\r\ntic;\r\nwaitForMe(t_correct);\r\nt = toc\r\ne = cputime - c\r\nassert( abs(t_correct - t*1000) \u003c= 0.5 )\r\nassert( e*1000 / t_correct \u003c= 0.05 )\r\n\r\n\r\n%% OK, maybe you can do it once, but can you do it more than once?\r\nt_correct = 1000;\r\nfor r = 1 : 3\r\n    c = cputime;\r\n    tic;\r\n    waitForMe(t_correct);\r\n    t = toc\r\n    e = cputime - c\r\n    assert( abs(t_correct - t*1000) \u003c= 0.5 )\r\n    assert( e*1000 / t_correct \u003c= 0.05 )\r\nend;\r\n\r\n\r\n%% OK, maybe you can do it once, but can you do it more than once?\r\nt_correct = 2000;\r\nfor r = 1 : 2\r\n    c = cputime;\r\n    tic;\r\n    waitForMe(t_correct);\r\n    t = toc\r\n    e = cputime - c\r\n    assert( abs(t_correct - t*1000) \u003c= 0.5 )\r\n    assert( e*1000 / t_correct \u003c= 0.05 )\r\nend;\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":9,"test_suite_updated_at":"2017-11-09T13:14:22.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2017-10-19T14:02:48.000Z","updated_at":"2017-11-09T13:14:22.000Z","published_at":"2017-10-19T14:18:48.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\u003eYour code needs to take 'exactly' one second or 'exactly' two seconds to run (depending on the input) — accurate to ±0.5 milliseconds.\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\u003eThe input will be the number of milliseconds to wait (i.e. 1000 or 2000). No output is required.\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\u003eBut the catch is that while waiting you have to 'take it easy'. In other words, you're not supposed to be working, so the CPU time should account for less than 5% of the time you've waited.\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\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\u003ePrevious: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44388\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWait a second!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":44388,"title":"Wait a second!","description":"Your code needs to take 'exactly' one second to run — accurate to ±0.5 milliseconds.  \r\n\r\nThe input will be the number of milliseconds to wait (i.e. 1000).  \r\nNo output is required.  \r\n\r\n-----\r\n\r\n\r\nNext:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44389 Just take it easy for a second or two!\u003e","description_html":"\u003cp\u003eYour code needs to take 'exactly' one second to run — accurate to ±0.5 milliseconds.\u003c/p\u003e\u003cp\u003eThe input will be the number of milliseconds to wait (i.e. 1000).  \r\nNo output is required.\u003c/p\u003e\u003cp\u003e-----\u003c/p\u003e\u003cp\u003eNext:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44389\"\u003eJust take it easy for a second or two!\u003c/a\u003e\u003c/p\u003e","function_template":"function [a, b, c, d, e, f, g, h] = waitForMe(x)\r\n\r\nend","test_suite":"%% Can you do it once?\r\nt_correct = 1000;\r\ntic;\r\nwaitForMe(t_correct);\r\nt = toc\r\nassert( abs(t_correct - t*1000) \u003c= 0.5 )\r\n\r\n\r\n%% OK, maybe you can do it once, but can you do it more than once?\r\nt_correct = 1000;\r\nfor r = 1 : 9\r\n    tic;\r\n    waitForMe(t_correct);\r\n    t = toc\r\n    assert( abs(t_correct - t*1000) \u003c= 0.5 )\r\nend;\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":16,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-10-16T13:43:40.000Z","updated_at":"2026-03-19T09:16:08.000Z","published_at":"2017-10-16T14:02:13.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\u003eYour code needs to take 'exactly' one second to run — accurate to ±0.5 milliseconds.\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\u003eThe input will be the number of milliseconds to wait (i.e. 1000). No output is required.\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\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\u003eNext: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44389\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eJust take it easy for a second or two!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"time\"","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:\"time\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"time\"","","\"","time","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f4a0343bb98\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f4a0343baf8\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f4a0343ad38\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f4a0343beb8\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f4a0343bd78\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f4a0343bcd8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f4a0343bc38\u003e":"tag:\"time\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f4a0343bc38\u003e":"tag:\"time\""},"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:\"time\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"time\"","","\"","time","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f4a0343bb98\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f4a0343baf8\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f4a0343ad38\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f4a0343beb8\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f4a0343bd78\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f4a0343bcd8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f4a0343bc38\u003e":"tag:\"time\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f4a0343bc38\u003e":"tag:\"time\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":44518,"difficulty_rating":"easy"},{"id":1733,"difficulty_rating":"easy"},{"id":44514,"difficulty_rating":"easy"},{"id":58693,"difficulty_rating":"easy"},{"id":1690,"difficulty_rating":"easy"},{"id":785,"difficulty_rating":"easy"},{"id":44437,"difficulty_rating":"easy"},{"id":2362,"difficulty_rating":"easy-medium"},{"id":326,"difficulty_rating":"easy-medium"},{"id":56578,"difficulty_rating":"easy-medium"},{"id":328,"difficulty_rating":"easy-medium"},{"id":45848,"difficulty_rating":"easy-medium"},{"id":43612,"difficulty_rating":"easy-medium"},{"id":786,"difficulty_rating":"easy-medium"},{"id":43275,"difficulty_rating":"easy-medium"},{"id":45381,"difficulty_rating":"easy-medium"},{"id":43611,"difficulty_rating":"easy-medium"},{"id":2431,"difficulty_rating":"easy-medium"},{"id":44390,"difficulty_rating":"easy-medium"},{"id":44349,"difficulty_rating":"easy-medium"},{"id":2432,"difficulty_rating":"easy-medium"},{"id":43610,"difficulty_rating":"easy-medium"},{"id":2483,"difficulty_rating":"easy-medium"},{"id":62,"difficulty_rating":"medium"},{"id":45398,"difficulty_rating":"medium-hard"},{"id":51808,"difficulty_rating":"medium-hard"},{"id":2433,"difficulty_rating":"medium-hard"},{"id":44389,"difficulty_rating":"medium-hard"},{"id":44388,"difficulty_rating":"medium-hard"}]}}