{"group":{"group":{"id":2296,"name":"Date \u0026 Time II","lockable":false,"created_at":"2020-03-14T17:13:48.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Basics of using date-time function","is_default":false,"created_by":363598,"badge_id":62,"featured":false,"trending":false,"solution_count_in_trending_period":10,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":627,"published":true,"community_created":true,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"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\u003eBasics of using date-time function\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\"}]}","description_html":"\u003cdiv style = \"text-align: start; line-height: normal; 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=\"display: block; min-width: 0px; padding-top: 0px; perspective-origin: 289.5px 10.24px; transform-origin: 289.5px 10.24px; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; perspective-origin: 266.5px 10.24px; transform-origin: 266.5px 10.24px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eBasics of using date-time function\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","published_at":"2020-03-24T08:13:16.000Z"},"current_player":null},"problems":[{"id":42352,"title":"Days until next NewYear ball drop","description":"Given a date string in the form 'yyyy-mm-dd' or 'yyyy-mm-dd hh:mm:ss', calculate the number of *days* until the dropping of the NewYear ball at Times Square (i.e., Dec 31st at midnight) of that year. Examples:\r\n\r\n    y = Days2NYE('2014-05-26') = 220 or\r\n    y = Days2NYE('2014-05-26 10:15:45') = 219","description_html":"\u003cp\u003eGiven a date string in the form 'yyyy-mm-dd' or 'yyyy-mm-dd hh:mm:ss', calculate the number of \u003cb\u003edays\u003c/b\u003e until the dropping of the NewYear ball at Times Square (i.e., Dec 31st at midnight) of that year. Examples:\u003c/p\u003e\u003cpre\u003e    y = Days2NYE('2014-05-26') = 220 or\r\n    y = Days2NYE('2014-05-26 10:15:45') = 219\u003c/pre\u003e","function_template":"function y = Days2NYE(x)\r\n  y = ??;\r\nend","test_suite":"%%\r\nx= '2015-05-26';\r\ny_correct = 220;\r\nassert(isequal(Days2NYE(x),y_correct))\r\n\r\n%%\r\nx = '2015-12-30';\r\ny_correct = 2;\r\nassert(isequal(Days2NYE(x),y_correct))\r\n\r\n%%\r\nx = '2014-05-26 10:15:45';\r\ny_correct = 219;\r\nassert(isequal(Days2NYE(x),y_correct))\r\n\r\n%%\r\nx = '2014-12-31 10:15:45';\r\ny_correct = 0;\r\nassert(isequal(Days2NYE(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":44306,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":78,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-06-02T18:07:53.000Z","updated_at":"2026-03-22T08:23:49.000Z","published_at":"2015-06-02T18:09: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\u003eGiven a date string in the form 'yyyy-mm-dd' or 'yyyy-mm-dd hh:mm:ss', calculate the number of\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\u003edays\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e until the dropping of the NewYear ball at Times Square (i.e., Dec 31st at midnight) of that year. Examples:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    y = Days2NYE('2014-05-26') = 220 or\\n    y = Days2NYE('2014-05-26 10:15:45') = 219]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2483,"title":"How long until the weekend?","description":"Write a function a that takes a date vector as an input and returns the number of hours until the weekend begins.  The beginning of the weekend is defined as 5:00 PM on Friday.  For example\r\n\r\n  input=[ 2014 08 04 08 00 00]\r\n  weekend(input) = 105\r\n\r\n  input=[ 2014 08 08 16 30 00]\r\n  weekend(input) = 0.5\r\n\r\nstr2num and other cheat functions are not allowed.","description_html":"\u003cp\u003eWrite a function a that takes a date vector as an input and returns the number of hours until the weekend begins.  The beginning of the weekend is defined as 5:00 PM on Friday.  For example\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003einput=[ 2014 08 04 08 00 00]\r\nweekend(input) = 105\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003einput=[ 2014 08 08 16 30 00]\r\nweekend(input) = 0.5\r\n\u003c/pre\u003e\u003cp\u003estr2num and other cheat functions are not allowed.\u003c/p\u003e","function_template":"function y = weekend(x)\r\n  y = x;\r\nend","test_suite":"%%\r\n%%\r\n% It's going to be a long week\r\na = [2014 8 4 08 00 0];\r\nweekend(a)\r\nb = 105;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n\r\n%%\r\na = [2014 08 05 10 23 34];\r\nweekend(a)\r\nb=78.607222;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n\r\n%%\r\n% Half way there\r\na = [2014 08 06 13 39 15];\r\nb = 51.3458333;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n\r\n%%\r\na = [2014 08 07 23 12 41];\r\nb = 17.788611;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n%%\r\n% Counting down the minutes\r\na = [2014 08 08 16 31 59];\r\nb = 0.466944;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n%%\r\n\r\na = [2013 08 29 15 59 10];\r\nb = 25.013888;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n%%\r\na = [2013 12 30 09 05 9];\r\nb = 103.914166;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n%%\r\na = [2012 02 27 10 32 33];\r\nb = 102.457500;\r\nassert(abs(weekend(a)-b)\u003c1e-5)\r\n\r\n\r\n%%\r\n% Prohibited functions.  List may be added to if more cheats arise\r\nt=evalc('type weekend.m');\r\nbadwords={'str2num'};\r\nassert(~any(cellfun(@(y) any(strfind(t,y)),badwords)));\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":18156,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":75,"test_suite_updated_at":"2014-08-07T12:18:26.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-08-04T19:26:18.000Z","updated_at":"2026-01-06T07:27:25.000Z","published_at":"2014-08-04T19:36:09.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function a that takes a date vector as an input and returns the number of hours until the weekend begins. The beginning of the weekend is defined as 5:00 PM on Friday. For example\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[input=[ 2014 08 04 08 00 00]\\nweekend(input) = 105\\n\\ninput=[ 2014 08 08 16 30 00]\\nweekend(input) = 0.5]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003estr2num and other cheat functions are not allowed.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45365,"title":"Count the days","description":"Count the occurrence of a particular day (e.g. Monday) for a given duration.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 21px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 10.5px; transform-origin: 407px 10.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 239px 8px; transform-origin: 239px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCount the occurrence of a particular day (e.g. Monday) for a given duration.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = count_days_2(year,day)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(count_days_2([2010:2020],'Fri'),574))\r\n%%\r\nassert(isequal(count_days_2([1910:2020],'Sat'),5792))\r\n%%\r\nassert(isequal( count_days_2([1942:1947],'Sun'),313))\r\n%%\r\nassert(isequal(count_days_2([1899:1912],'Wed'),730))\r\n%%\r\nassert(isequal(count_days_2([1798:1902],'Sun'),5478))\r\n%%\r\nassert(isequal(count_days_2(2012,'Mon'),53))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":65,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-15T19:12:07.000Z","updated_at":"2025-12-14T15:43:27.000Z","published_at":"2020-03-15T19:12:33.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCount the occurrence of a particular day (e.g. Monday) for a given duration.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44668,"title":"Day counter function","description":"Write a function called day_counter that returns the number of Mondays that fell on the first day of the month in a given year between 1776 and 2016 inclusive where the requested year is the only input to your function and it is a positive integer scalar. Note that a leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. In a leap year, February has 29 days.\r\nYou are not allowed to use the datenum built-in function.\r\n(Inspired by Project Euler.)","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: 144px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 72px; transform-origin: 407px 72px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84px; 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 42px; text-align: left; transform-origin: 384px 42px; 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: 70px 8px; transform-origin: 70px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function called\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: 2px 8px; transform-origin: 2px 8px; 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: 39.5px 8px; transform-origin: 39.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eday_counter\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: 265px 8px; transform-origin: 265px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e that returns the number of Mondays that fell on the first day of the month in a given year between 1776 and 2016 inclusive where the requested year is the only input to your function and it is a positive integer scalar. Note that a leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. In a leap year, February has 29 days.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 199px 8px; transform-origin: 199px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eYou are not allowed to use the datenum built-in function.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 93px 8px; transform-origin: 93px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e(Inspired by Project Euler.)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"% function to count number of mondays\r\nfunction foms = day_counter( year )\r\n\r\nend","test_suite":"%%\r\nyear  = 1902;\r\nfoms_correct = 2;\r\nassert(isequal(day_counter( year ),foms_correct))\r\n\r\n%%\r\nyear  = 2002;\r\nfoms_correct = 2;\r\nassert(isequal(day_counter( year ),foms_correct))\r\n\r\n%%\r\nyear  = 1996;\r\nfoms_correct = 3;\r\nassert(isequal(day_counter( year ),foms_correct))\r\n\r\n%%\r\nyear  = 1885;\r\nfoms_correct = 1;\r\nassert(isequal(day_counter( year ),foms_correct))\r\n\r\n%%\r\nyear  = 2000;\r\nfoms_correct = 1;\r\nassert(isequal(day_counter( year ),foms_correct))\r\n\r\n%%\r\nyear  = 2013;\r\nfoms_correct = 2;\r\nassert(isequal(day_counter( year ),foms_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":223089,"edited_at":"2023-01-16T11:22:13.000Z","deleted_by":null,"deleted_at":null,"solvers_count":77,"test_suite_updated_at":"2023-01-16T11:22:13.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-30T02:42:41.000Z","updated_at":"2026-01-01T20:23:31.000Z","published_at":"2018-05-30T02:42:41.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\u003eWrite a function called\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eday_counter\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e that returns the number of Mondays that fell on the first day of the month in a given year between 1776 and 2016 inclusive where the requested year is the only input to your function and it is a positive integer scalar. Note that a leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. In a leap year, February has 29 days.\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eYou are not allowed to use the datenum built-in function.\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e(Inspired by Project Euler.)\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":1877,"title":"Friday the 13th","description":"According to superstition, lots of unpleasant stuff happens on Friday the 13th, so you might like to find the next occurence of such a date. Given a date string ('dd/mm/yyyy'), return the next occurence of a Friday the 13th. If the date string is already a Friday the 13th, return the original string. Output should be in the form of a date string ('dd/mm/yyyy').\r\n\r\nExample:\r\ndate = '13/09/2013', nextfri13(date) = '13/09'2013';\r\ndate = '15/12/2013', nextfri13(date) = '13/06/2014';\r\n\r\nAnd so on. Good luck!","description_html":"\u003cp\u003eAccording to superstition, lots of unpleasant stuff happens on Friday the 13th, so you might like to find the next occurence of such a date. Given a date string ('dd/mm/yyyy'), return the next occurence of a Friday the 13th. If the date string is already a Friday the 13th, return the original string. Output should be in the form of a date string ('dd/mm/yyyy').\u003c/p\u003e\u003cp\u003eExample:\r\ndate = '13/09/2013', nextfri13(date) = '13/09'2013';\r\ndate = '15/12/2013', nextfri13(date) = '13/06/2014';\u003c/p\u003e\u003cp\u003eAnd so on. Good luck!\u003c/p\u003e","function_template":"function y = nextfri13(date)\r\n  y = x;\r\nend","test_suite":"%%\r\ndate = '13/09/2013';\r\ny_correct = '13/09/2013';\r\nassert(isequal(nextfri13(date),y_correct))\r\n%%\r\ndate = '15/09/2013';\r\ny_correct = '13/12/2013';\r\nassert(isequal(nextfri13(date),y_correct))\r\n%%\r\ndate = '17/12/2013';\r\ny_correct = '13/06/2014';\r\nassert(isequal(nextfri13(date),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":16311,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":71,"test_suite_updated_at":"2013-09-17T12:01:39.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-16T07:58:38.000Z","updated_at":"2026-04-01T09:51:48.000Z","published_at":"2013-09-16T07:59:41.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAccording to superstition, lots of unpleasant stuff happens on Friday the 13th, so you might like to find the next occurence of such a date. Given a date string ('dd/mm/yyyy'), return the next occurence of a Friday the 13th. If the date string is already a Friday the 13th, return the original string. Output should be in the form of a date string ('dd/mm/yyyy').\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample: date = '13/09/2013', nextfri13(date) = '13/09'2013'; date = '15/12/2013', nextfri13(date) = '13/06/2014';\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAnd so on. Good luck!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2025,"title":"Find the day for a date","description":"Today's day and date will be given to you. By utilising that you need to find the day of the old date. (Date will be in DD/MM/YYYY format, Consider leap years also).\r\nExample:\r\nTodayDate='20/11/2013'\r\nToday='Monday'\r\nUnknownDay_Date ='19/11/2013'\r\nSo here you need to provide output as UnknownDay='Sunday'\r\nSolve the problem in the hypothetical world where 16 April 2019 happens on Saturday instead of Tuesday.\r\nNote: It is not like using \"datestr\" and finding result. You need to calculate the number of inbetween days and then find the answer.","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: 273px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 136.5px; transform-origin: 407px 136.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 358.5px 8px; transform-origin: 358.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eToday's day and date will be given to you. By utilising that you need to find the day of the old date. (Date will be in DD/MM/YYYY format, Consider leap years also).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 76.5px 8px; transform-origin: 76.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eTodayDate='20/11/2013'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 51px 8px; transform-origin: 51px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eToday='Monday'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 104.5px 8px; transform-origin: 104.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eUnknownDay_Date ='19/11/2013'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 195.5px 8px; transform-origin: 195.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSo here you need to provide output as UnknownDay='Sunday'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 333.5px 8px; transform-origin: 333.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSolve the problem in the hypothetical world where 16 April 2019 happens on Saturday instead of Tuesday.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 384px 8px; transform-origin: 384px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNote: It is not like using \"datestr\" and finding result. You need to calculate the number of inbetween days and then find the answer.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function UnknownDay = FindDay(TodayDate,Today,UnknownDay_Date)\r\n  UnknownDay= UnknownDay_Date;\r\nend","test_suite":"%%\r\nTodayDate='28/11/2013';\r\nToday='Thursday';\r\nUnknownDay_Date='07/01/1991';\r\ny_correct = 'Monday';\r\nassert(isequal(FindDay(TodayDate,Today,UnknownDay_Date),y_correct))\r\n\r\n%%\r\nTodayDate='20/07/1977';\r\nToday='Wednesday';\r\nUnknownDay_Date='26/01/1950';\r\ny_correct = 'Thursday';\r\nassert(isequal(FindDay(TodayDate,Today,UnknownDay_Date),y_correct))\r\n\r\n%%\r\nTodayDate='16/04/2019';\r\nToday='Saturday';\r\nUnknownDay_Date='22/10/1901';\r\ny_correct = 'Saturday';\r\nassert(isequal(FindDay(TodayDate,Today,UnknownDay_Date),y_correct))\r\n\r\n%%\r\nTodayDate='14/03/2020';\r\nToday='Tuesday';\r\nUnknownDay_Date='12/03/2020';\r\ny_correct = 'Sunday';\r\nassert(isequal(FindDay(TodayDate,Today,UnknownDay_Date),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":13835,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":56,"test_suite_updated_at":"2022-01-28T19:22:15.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-11-28T13:39:50.000Z","updated_at":"2025-11-21T18:25:54.000Z","published_at":"2013-11-28T13:43:46.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\u003eToday's day and date will be given to you. By utilising that you need to find the day of the old date. (Date will be in DD/MM/YYYY format, Consider leap years also).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTodayDate='20/11/2013'\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\u003eToday='Monday'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eUnknownDay_Date ='19/11/2013'\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\u003eSo here you need to provide output as UnknownDay='Sunday'\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\u003eSolve the problem in the hypothetical world where 16 April 2019 happens on Saturday instead of Tuesday.\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\u003eNote: It is not like using \\\"datestr\\\" and finding result. You need to calculate the number of inbetween days and then find the answer.\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":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":2336,"title":"Calendar Matrix","description":"Return a calendar matrix for the given values of month and year. Assume that Sunday is the first day of the week. The resulting calendar month will have seven columns and only as many rows (weeks) as needed to display all days of the month. Thus it might have either 4, 5, or 6 rows. Days preceding the first of the month or following the last of the month are given by zeros.\r\n\r\nExamples\r\n\r\n \u003e\u003e mo = 1\r\n \u003e\u003e yr = 2014\r\n \u003e\u003e momat = makeCalendar(mo,yr)\r\n\r\n     0     0     0     1     2     3     4\r\n     5     6     7     8     9    10    11\r\n    12    13    14    15    16    17    18\r\n    19    20    21    22    23    24    25\r\n    26    27    28    29    30    31     0\r\n\r\n \u003e\u003e mo = 2\r\n \u003e\u003e yr = 2015\r\n \u003e\u003e momat = makeCalendar(mo,yr)\r\n\r\n     1     2     3     4     5     6     7\r\n     8     9    10    11    12    13    14\r\n    15    16    17    18    19    20    21\r\n    22    23    24    25    26    27    28\r\n\r\n\r\n \u003e\u003e mo = 10\r\n \u003e\u003e yr = 2010\r\n \u003e\u003e momat = makeCalendar(mo,yr)\r\n\r\n     0     0     0     0     0     1     2\r\n     3     4     5     6     7     8     9\r\n    10    11    12    13    14    15    16\r\n    17    18    19    20    21    22    23\r\n    24    25    26    27    28    29    30\r\n    31     0     0     0     0     0     0","description_html":"\u003cp\u003eReturn a calendar matrix for the given values of month and year. Assume that Sunday is the first day of the week. The resulting calendar month will have seven columns and only as many rows (weeks) as needed to display all days of the month. Thus it might have either 4, 5, or 6 rows. Days preceding the first of the month or following the last of the month are given by zeros.\u003c/p\u003e\u003cp\u003eExamples\u003c/p\u003e\u003cpre\u003e \u0026gt;\u0026gt; mo = 1\r\n \u0026gt;\u0026gt; yr = 2014\r\n \u0026gt;\u0026gt; momat = makeCalendar(mo,yr)\u003c/pre\u003e\u003cpre\u003e     0     0     0     1     2     3     4\r\n     5     6     7     8     9    10    11\r\n    12    13    14    15    16    17    18\r\n    19    20    21    22    23    24    25\r\n    26    27    28    29    30    31     0\u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; mo = 2\r\n \u0026gt;\u0026gt; yr = 2015\r\n \u0026gt;\u0026gt; momat = makeCalendar(mo,yr)\u003c/pre\u003e\u003cpre\u003e     1     2     3     4     5     6     7\r\n     8     9    10    11    12    13    14\r\n    15    16    17    18    19    20    21\r\n    22    23    24    25    26    27    28\u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; mo = 10\r\n \u0026gt;\u0026gt; yr = 2010\r\n \u0026gt;\u0026gt; momat = makeCalendar(mo,yr)\u003c/pre\u003e\u003cpre\u003e     0     0     0     0     0     1     2\r\n     3     4     5     6     7     8     9\r\n    10    11    12    13    14    15    16\r\n    17    18    19    20    21    22    23\r\n    24    25    26    27    28    29    30\r\n    31     0     0     0     0     0     0\u003c/pre\u003e","function_template":"function momat = makeCalendar(mo,yr)\r\n  momat = 0;\r\nend","test_suite":"%%\r\n\r\nmo = 1;\r\nyr = 2014;\r\nmomat = makeCalendar(mo,yr);\r\nmomat_correct = [ ...\r\n     0     0     0     1     2     3     4\r\n     5     6     7     8     9    10    11\r\n    12    13    14    15    16    17    18\r\n    19    20    21    22    23    24    25\r\n    26    27    28    29    30    31     0];\r\nassert(isequal(momat,momat_correct)) \r\n\r\n%%\r\n\r\nmo = 2;\r\nyr = 2015;\r\nmomat = makeCalendar(mo,yr);\r\nmomat_correct = [ ...\r\n     1     2     3     4     5     6     7\r\n     8     9    10    11    12    13    14\r\n    15    16    17    18    19    20    21\r\n    22    23    24    25    26    27    28];\r\nassert(isequal(momat,momat_correct)) \r\n\r\n%%\r\n\r\nmo = 10;\r\nyr = 2010;\r\nmomat = makeCalendar(mo,yr);\r\nmomat_correct = [ ...\r\n     0     0     0     0     0     1     2\r\n     3     4     5     6     7     8     9\r\n    10    11    12    13    14    15    16\r\n    17    18    19    20    21    22    23\r\n    24    25    26    27    28    29    30\r\n    31     0     0     0     0     0     0];\r\nassert(isequal(momat,momat_correct))\r\n\r\n%%\r\n\r\nmo = 11;\r\nyr = 1972;\r\nmomat = makeCalendar(mo,yr);\r\nmomat_correct = [0 0 0 1 2 3 4;5 6 7 8 9 10 11;12 13 14 15 16 17 18;19 20 21 22 23 24 25;26 27 28 29 30 0 0];\r\n\r\nassert(isequal(momat,momat_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":7,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":161,"test_suite_updated_at":"2014-05-22T21:48:47.000Z","rescore_all_solutions":false,"group_id":31,"created_at":"2014-05-22T20:36:33.000Z","updated_at":"2026-03-03T16:29:43.000Z","published_at":"2014-05-22T20:47:34.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn a calendar matrix for the given values of month and year. Assume that Sunday is the first day of the week. The resulting calendar month will have seven columns and only as many rows (weeks) as needed to display all days of the month. Thus it might have either 4, 5, or 6 rows. Days preceding the first of the month or following the last of the month are given by zeros.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ \u003e\u003e mo = 1\\n \u003e\u003e yr = 2014\\n \u003e\u003e momat = makeCalendar(mo,yr)\\n\\n     0     0     0     1     2     3     4\\n     5     6     7     8     9    10    11\\n    12    13    14    15    16    17    18\\n    19    20    21    22    23    24    25\\n    26    27    28    29    30    31     0\\n\\n \u003e\u003e mo = 2\\n \u003e\u003e yr = 2015\\n \u003e\u003e momat = makeCalendar(mo,yr)\\n\\n     1     2     3     4     5     6     7\\n     8     9    10    11    12    13    14\\n    15    16    17    18    19    20    21\\n    22    23    24    25    26    27    28\\n\\n \u003e\u003e mo = 10\\n \u003e\u003e yr = 2010\\n \u003e\u003e momat = makeCalendar(mo,yr)\\n\\n     0     0     0     0     0     1     2\\n     3     4     5     6     7     8     9\\n    10    11    12    13    14    15    16\\n    17    18    19    20    21    22    23\\n    24    25    26    27    28    29    30\\n    31     0     0     0     0     0     0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44663,"title":"Datetime basics","description":"Generate the datetime scalar representing the current date","description_html":"\u003cp\u003eGenerate the datetime scalar representing the current date\u003c/p\u003e","function_template":"function y = generate_datetime()\r\n  \r\nend","test_suite":"%%\r\ny_correct = datetime('today');\r\nassert(isequal(generate_datetime(),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":135,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-29T14:59:26.000Z","updated_at":"2026-03-02T09:12:44.000Z","published_at":"2018-05-29T14:59: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\",\"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\u003eGenerate the datetime scalar representing the current date\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":44479,"title":"Friday or not","description":"I love Friday. Please tell me whether the day is Friday.\r\n\r\nDateformat is 'yyyy-mm-dd'  or 'dd-mmm-yyyy' or 'mm/dd/yyyy'.\r\n\r\nExamples;\r\n\r\ninput  D =  '2018-01-03';  % Wednesday\r\n\r\noutput y = 0\r\n\r\ninput  D =  '5-Jan-2018';  % Friday\r\n\r\noutput y = 1 \r\n\r\ninput  D =  '09/09/2019';  % Monday\r\n\r\noutput y = 0 \r\n","description_html":"\u003cp\u003eI love Friday. Please tell me whether the day is Friday.\u003c/p\u003e\u003cp\u003eDateformat is 'yyyy-mm-dd'  or 'dd-mmm-yyyy' or 'mm/dd/yyyy'.\u003c/p\u003e\u003cp\u003eExamples;\u003c/p\u003e\u003cp\u003einput  D =  '2018-01-03';  % Wednesday\u003c/p\u003e\u003cp\u003eoutput y = 0\u003c/p\u003e\u003cp\u003einput  D =  '5-Jan-2018';  % Friday\u003c/p\u003e\u003cp\u003eoutput y = 1\u003c/p\u003e\u003cp\u003einput  D =  '09/09/2019';  % Monday\u003c/p\u003e\u003cp\u003eoutput y = 0\u003c/p\u003e","function_template":"function y = Fri(D)\r\n  y = 1;\r\nend","test_suite":"%% 1\r\nD = '5-Jan-2018';\r\ny_correct = 1;\r\nassert(isequal(Fri(D),y_correct))\r\n%% 2\r\nD = '09/09/2019';\r\ny_correct = 0;\r\nassert(isequal(Fri(D),y_correct))\r\n%% 3\r\nD = '2000-01-01';\r\ny_correct = 0;\r\nassert(isequal(Fri(D),y_correct))\r\n%% 4\r\nD = '2020-12-25';\r\ny_correct = 1;\r\nassert(isequal(Fri(D),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":137687,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":96,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-01-04T06:58:08.000Z","updated_at":"2026-03-16T12:05:20.000Z","published_at":"2018-01-04T07:28:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eI love Friday. Please tell me whether the day is Friday.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDateformat is 'yyyy-mm-dd' or 'dd-mmm-yyyy' or 'mm/dd/yyyy'.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003einput D = '2018-01-03'; % Wednesday\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eoutput y = 0\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003einput D = '5-Jan-2018'; % Friday\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eoutput y = 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003einput D = '09/09/2019'; % Monday\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eoutput y = 0\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45328,"title":"leap year","description":"find the number of leap years within the given time interval","description_html":"\u003cp\u003efind the number of leap years within the given time interval\u003c/p\u003e","function_template":"function b = leap_count(n)\r\n  y = x;\r\nend","test_suite":"%%\r\nn = 1900:2000;\r\nassert(isequal( leap_count(n),25))\r\n%%\r\nn = 100:2000;\r\nassert(isequal( leap_count(n),461))\r\n%%\r\nn = 1600:2000;\r\nassert(isequal( leap_count(n),98))\r\n%%\r\nn = 3000;\r\nassert(isequal( leap_count(n),0))\r\n%%\r\nn = 377:467;\r\nassert(isequal( leap_count(n),22))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":84,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-02-15T07:16:33.000Z","updated_at":"2025-12-21T21:32:21.000Z","published_at":"2020-02-15T07:16:59.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003efind the number of leap years within the given time interval\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2397,"title":"Leap Year","description":"According to Gregorian Calender(which is in use now, in many countries),decide whether a given year is a leap year or not.\r\nGive 'true' if the given year is a leap year and 'false',if not.\r\n\r\nNote:\r\nIn the Gregorian calendar 3 criteria must be taken into account to identify leap years:\r\n\r\nThe year is evenly divisible by 4;\r\nIf the year can be evenly divided by 100, it is NOT a leap year, unless;\r\nThe year is also evenly divisible by 400. Then it is a leap year.","description_html":"\u003cp\u003eAccording to Gregorian Calender(which is in use now, in many countries),decide whether a given year is a leap year or not.\r\nGive 'true' if the given year is a leap year and 'false',if not.\u003c/p\u003e\u003cp\u003eNote:\r\nIn the Gregorian calendar 3 criteria must be taken into account to identify leap years:\u003c/p\u003e\u003cp\u003eThe year is evenly divisible by 4;\r\nIf the year can be evenly divided by 100, it is NOT a leap year, unless;\r\nThe year is also evenly divisible by 400. Then it is a leap year.\u003c/p\u003e","function_template":"function y = leap(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1700;\r\ny_correct = false;\r\nassert(isequal(leap(x),y_correct))\r\n\r\n%%\r\nx = 2000;\r\ny_correct = true;\r\nassert(isequal(leap(x),y_correct))\r\n\r\n%%\r\nx = 2014;\r\ny_correct = false;\r\nassert(isequal(leap(x),y_correct))\r\n\r\n\r\n%%\r\nx = 2020;\r\ny_correct = true;\r\nassert(isequal(leap(x),y_correct))\r\n \r\n%%\r\nx = 2100;\r\ny_correct = false;\r\nassert(isequal(leap(x),y_correct))\r\n\r\n%%\r\nx = 2400;\r\ny_correct = true;\r\nassert(isequal(leap(x),y_correct))\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":15302,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":195,"test_suite_updated_at":"2014-07-01T06:37:35.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2014-06-30T19:41:10.000Z","updated_at":"2026-04-02T12:45:25.000Z","published_at":"2014-06-30T19:41: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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAccording to Gregorian Calender(which is in use now, in many countries),decide whether a given year is a leap year or not. Give 'true' if the given year is a leap year and 'false',if not.\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\u003eNote: In the Gregorian calendar 3 criteria must be taken into account to identify leap years:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe year is evenly divisible by 4; If the year can be evenly divided by 100, it is NOT a leap year, unless; The year is also evenly divisible by 400. Then it is a leap 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":45378,"title":"Lost days","description":"Given two dates in a particular format, calculate the difference between them.\r\n","description_html":"\u003cp\u003eGiven two dates in a particular format, calculate the difference between them.\u003c/p\u003e","function_template":"function y = date_dis(a,b,c)","test_suite":"%%\r\na=[2019 2 4];\r\nb=[1992 3 6];\r\nc='yyyy-MM-dd';\r\ny=calendarDuration(26,10,29);\r\nassert(isequal(date_dis(a,b,c),y))\r\n\r\n%%\r\na=[2029 12 14];\r\nb=[1892 13 16];\r\nc='yyyy-MM-dd';\r\ny=calendarDuration(136,10,28);\r\nassert(isequal(date_dis(a,b,c),y))\r\n\r\n%%\r\na='14/11/2018';\r\nb='14/12/2009';\r\nc='dd/MM/yyyy';\r\ny=calendarDuration(8,11,0);\r\nassert(isequal(date_dis(a,b,c),y))\r\n\r\n%%\r\na='29-12-2014';\r\nb='02-01-1916';\r\nc='dd-MM-yyyy';\r\ny=calendarDuration(98,11,27);\r\nassert(isequal(date_dis(a,b,c),y))","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":61,"test_suite_updated_at":"2020-03-23T11:35:18.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-23T11:23:03.000Z","updated_at":"2025-11-21T18:07:42.000Z","published_at":"2020-03-23T11:35:18.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two dates in a particular format, calculate the difference between them.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45380,"title":"The End of the World","description":"given a date -- represent it in the Maya long count system.\r\n\r\n\u003chttps://en.wikipedia.org/wiki/Maya_calendar\u003e\r\n\r\n\u003chttps://maya.nmai.si.edu/calendar/maya-calendar-converter\u003e\r\n\r\nFor example,\r\n \r\n date = [2020 03 24]\r\n Maya = '13.0.7.6.10'","description_html":"\u003cp\u003egiven a date -- represent it in the Maya long count system.\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://en.wikipedia.org/wiki/Maya_calendar\"\u003ehttps://en.wikipedia.org/wiki/Maya_calendar\u003c/a\u003e\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://maya.nmai.si.edu/calendar/maya-calendar-converter\"\u003ehttps://maya.nmai.si.edu/calendar/maya-calendar-converter\u003c/a\u003e\u003c/p\u003e\u003cp\u003eFor example,\u003c/p\u003e\u003cpre\u003e date = [2020 03 24]\r\n Maya = '13.0.7.6.10'\u003c/pre\u003e","function_template":"function y = maya_cal(x)","test_suite":"%%\r\nx=[1989 03 01];\r\nassert(isequal(maya_cal(x),'12.18.15.15.4'))\r\n\r\n%%\r\nx=[1995 03 23];\r\nassert(isequal(maya_cal(x),'12.19.1.17.17'))\r\n\r\n%%\r\nx=[2005 03 23];\r\nassert(isequal(maya_cal(x),'12.19.12.2.10'))\r\n\r\n%%\r\nx=[2015 03 23];\r\nassert(isequal(maya_cal(x),'13.0.2.5.2'))\r\n\r\n%%\r\nx=[1993 02 19];\r\nassert(isequal(maya_cal(x),'12.18.19.15.15'))\r\n\r\n%%\r\nx=[2012 12 31];\r\nassert(isequal(maya_cal(x),'13.0.0.0.10'))\r\n\r\n\r\n%%\r\nx=[2112 09 17];\r\nassert(isequal(maya_cal(x),'13.5.1.3.9'))","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":55,"test_suite_updated_at":"2020-03-24T00:45:50.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-24T00:30:10.000Z","updated_at":"2025-11-21T18:25:00.000Z","published_at":"2020-03-24T00:45:50.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003egiven a date -- represent it in the Maya long count system.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Maya_calendar\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/Maya_calendar\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://maya.nmai.si.edu/calendar/maya-calendar-converter\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://maya.nmai.si.edu/calendar/maya-calendar-converter\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ date = [2020 03 24]\\n Maya = '13.0.7.6.10']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"no_progress_badge":{"id":53,"name":"Unknown","symbol":"unknown","description":"Partially completed groups","description_html":null,"image_location":"/images/responsive/supporting/matlabcentral/cody/badges/problem_groups_unknown_2.png","bonus":null,"players_count":0,"active":false,"created_by":null,"updated_by":null,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"created_at":"2018-01-10T23:20:29.000Z","updated_at":"2018-01-10T23:20:29.000Z","community_badge_id":null,"award_multiples":false}}