{"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":369,"title":"Basic electricity in a dry situation","description":"\u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \r\n\r\nThis is a very hypothetical situation between two individuals in a very dry atmosphere. \r\n\r\nHe came running in rubber boots when she was combing her hair. \r\n\r\nAround N number of electrons moved from one person to the other upon contact. \r\n\r\nWhat was the voltage between them before the contact? \r\n\r\nAssume it is a simple RC type electrical circuit with equivalent capacitance of about 16 pico farads. \r\n\r\nPlease assume that every electron carries about 160 zepto coulombs.\r\n\r\nFor more info on capacitors: \u003chttps://en.wikipedia.org/wiki/Capacitor\u003e","description_html":"\u003cp\u003e\u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889\u003c/p\u003e\u003cp\u003eThis is a very hypothetical situation between two individuals in a very dry atmosphere.\u003c/p\u003e\u003cp\u003eHe came running in rubber boots when she was combing her hair.\u003c/p\u003e\u003cp\u003eAround N number of electrons moved from one person to the other upon contact.\u003c/p\u003e\u003cp\u003eWhat was the voltage between them before the contact?\u003c/p\u003e\u003cp\u003eAssume it is a simple RC type electrical circuit with equivalent capacitance of about 16 pico farads.\u003c/p\u003e\u003cp\u003ePlease assume that every electron carries about 160 zepto coulombs.\u003c/p\u003e\u003cp\u003eFor more info on capacitors: \u003ca href = \"https://en.wikipedia.org/wiki/Capacitor\"\u003ehttps://en.wikipedia.org/wiki/Capacitor\u003c/a\u003e\u003c/p\u003e","function_template":"function V = volts(N)\r\n  V = 10000;\r\nend","test_suite":"%%\r\nN = 10^10;\r\nV = 150;\r\nassert(volts(N)\u003eV/pi)\r\n%%\r\nN = 10^11;\r\nV = 700;\r\nassert(volts(N)\u003cV*pi)\r\n%%\r\nN = 10^12;\r\nV = 10000;\r\nassert(volts(N)\u003eV/sqrt(pi))\r\n","published":true,"deleted":false,"likes_count":8,"comments_count":4,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":595,"test_suite_updated_at":"2012-02-20T20:05:18.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2012-02-20T20:05:18.000Z","updated_at":"2026-03-18T13:23:56.000Z","published_at":"2017-10-16T01:45:05.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\u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889\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 is a very hypothetical situation between two individuals in a very dry atmosphere.\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\u003eHe came running in rubber boots when she was combing her hair.\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\u003eAround N number of electrons moved from one person to the other upon contact.\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\u003eWhat was the voltage between them before the contact?\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\u003eAssume it is a simple RC type electrical circuit with equivalent capacitance of about 16 pico farads.\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\u003ePlease assume that every electron carries about 160 zepto coulombs.\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 more info on capacitors:\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/Capacitor\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/Capacitor\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":361,"title":"Energy of a photon","description":"\u0026#9883 \u0026#9762 \u0026#9883 \u0026#9762 \u0026#9883 \u0026#9762 \u0026#9883\r\nGiven the frequency F of a photon in giga hertz.\r\nFind energy E of this photon in giga electron volts.\r\nAssume h, Planck's constant is about 4 femto electron-volt-second.\r\nTo maximize benefits, it may help not looking at the Test Suite before trying any solution!\r\nFor more info: \u003chttps://en.wikipedia.org/wiki/Planck_constant\u003e","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 171px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 85.5px; transform-origin: 407px 85.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 187px 8px; transform-origin: 187px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e\u0026amp;#9883 \u0026amp;#9762 \u0026amp;#9883 \u0026amp;#9762 \u0026amp;#9883 \u0026amp;#9762 \u0026amp;#9883\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: 151px 8px; transform-origin: 151px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven the frequency F of a photon in giga hertz.\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: 158.5px 8px; transform-origin: 158.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFind energy E of this photon in giga electron volts.\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: 211px 8px; transform-origin: 211px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAssume h, Planck's constant is about 4 femto electron-volt-second.\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: 276.5px 8px; transform-origin: 276.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eTo maximize benefits, it may help not looking at the Test Suite before trying any solution!\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: 44.5px 8px; transform-origin: 44.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor more info:\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\u003ca target='_blank' href = \"https://en.wikipedia.org/wiki/Planck_constant\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e\u0026lt;https://en.wikipedia.org/wiki/Planck_constant\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 4px 8px; transform-origin: 4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u0026gt;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function E = photon_energy(F)\r\n  E=100/F;\r\nend","test_suite":"%%\r\nF = 1;\r\nE_correct = 3/10^15;\r\nassert(photon_energy(F)\u003eE_correct)\r\n%%\r\nF = 100;\r\nE_correct = 500/10^15;\r\nassert(photon_energy(F)\u003cE_correct)\r\n%%\r\nF = 500;\r\nE_correct = 2100/10^15;\r\nassert(photon_energy(F)\u003cE_correct)\r\n%%\r\nF = 420;\r\nE_correct = 1680/10^15;\r\nassert(isequal(photon_energy(F),E_correct))\r\n%%\r\nF = 0.25;\r\nE_correct = 1e-15;\r\nassert(isequal(photon_energy(F),E_correct))","published":true,"deleted":false,"likes_count":15,"comments_count":11,"created_by":166,"edited_by":223089,"edited_at":"2022-12-24T15:16:49.000Z","deleted_by":null,"deleted_at":null,"solvers_count":1465,"test_suite_updated_at":"2022-12-24T15:16:49.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2012-02-19T23:13:56.000Z","updated_at":"2026-04-01T13:59:42.000Z","published_at":"2017-10-16T01:45:05.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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u0026amp;#9883 \u0026amp;#9762 \u0026amp;#9883 \u0026amp;#9762 \u0026amp;#9883 \u0026amp;#9762 \u0026amp;#9883\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\u003eGiven the frequency F of a photon in giga hertz.\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\u003eFind energy E of this photon in giga electron volts.\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\u003eAssume h, Planck's constant is about 4 femto electron-volt-second.\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\u003eTo maximize benefits, it may help not looking at the Test Suite before trying any solution!\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 more info:\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/Planck_constant\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/Planck_constant\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\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":2736,"title":"Pernicious Anniversary Problem","description":"Since Cody is 5 years old, it's pernicious. A \u003chttp://rosettacode.org/wiki/Pernicious_numbers Pernicious number\u003e is an integer whose population count is a prime. Check if the given number is pernicious.","description_html":"\u003cp\u003eSince Cody is 5 years old, it's pernicious. A \u003ca href = \"http://rosettacode.org/wiki/Pernicious_numbers\"\u003ePernicious number\u003c/a\u003e is an integer whose population count is a prime. Check if the given number is pernicious.\u003c/p\u003e","function_template":"function y = isPernicious(x)\r\n  y = false;\r\nend","test_suite":"%%\r\nx = 5;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 1;\r\ny_correct = false;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 2^randi(16);\r\ny_correct = false;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 17;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 18;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 61;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 6;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 2115;\r\ny_correct = false;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 2114;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 2017;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":13,"comments_count":1,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":837,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2014-12-08T08:48:45.000Z","updated_at":"2026-03-18T13:27:13.000Z","published_at":"2017-10-16T01:45:06.000Z","restored_at":"2017-10-25T14:37:50.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\u003eSince Cody is 5 years old, it's pernicious. A\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://rosettacode.org/wiki/Pernicious_numbers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePernicious number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is an integer whose population count is a prime. Check if the given number is pernicious.\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":44315,"title":"Predicting life and death of a memory-less light bulb","description":"*\u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161* \r\n\r\nYou have a light bulb that can fail any moment according to the exponential probability distribution. \r\n\r\nAt any moment, the probability that it will survive just N hours = exp(-N*P), where P is a constant. \r\n\r\nNotice that this probability is very small if N is very large. \r\n\r\nNow suppose, the bulb has already survived N hours. \r\n\r\nPlease calculate the probability of its surviving M more hours.\r\n","description_html":"\u003cp\u003e\u003cb\u003e\u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161\u003c/b\u003e\u003c/p\u003e\u003cp\u003eYou have a light bulb that can fail any moment according to the exponential probability distribution.\u003c/p\u003e\u003cp\u003eAt any moment, the probability that it will survive just N hours = exp(-N*P), where P is a constant.\u003c/p\u003e\u003cp\u003eNotice that this probability is very small if N is very large.\u003c/p\u003e\u003cp\u003eNow suppose, the bulb has already survived N hours.\u003c/p\u003e\u003cp\u003ePlease calculate the probability of its surviving M more hours.\u003c/p\u003e","function_template":"function hope = fate(N,P,M)\r\n  hope=exp(-(N+M)*P);\r\nend","test_suite":"%%\r\nN = 1;\r\nP=1;\r\nM=0;\r\nhope_correct = 1;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN = 1;\r\nP=0;\r\nM=1;\r\nhope_correct = 1;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN=1;\r\nP=1;\r\nM=1;\r\nhope_correct = 0.3679;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN=2;\r\nP=1;\r\nM=1;\r\nhope_correct = 0.3679;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN=2;\r\nP=1;\r\nM=2;\r\nhope_correct = 0.1353;\r\nassert(fate(N,P,M)\u003chope_correct*1.1)\r\n%%\r\nN=2;\r\nP=2;\r\nM=2;\r\nhope_correct = 0.0183;\r\nassert(fate(N,P,M)\u003chope_correct*1.1)\r\n%%","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":336,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-12T02:53:45.000Z","updated_at":"2026-03-25T02:55:11.000Z","published_at":"2017-10-16T01:45: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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161\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 have a light bulb that can fail any moment according to the exponential probability distribution.\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\u003eAt any moment, the probability that it will survive just N hours = exp(-N*P), where P is a constant.\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\u003eNotice that this probability is very small if N is very large.\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\u003eNow suppose, the bulb has already survived N hours.\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\u003ePlease calculate the probability of its surviving M more hours.\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":44370,"title":"Octoberfest festival","description":"A group of students decided to visit Octoberfest festival. First they ordered one beer, then after half-hour they taken one more, after one more half-hour they ordered two more beers like sum of previous two times. Then after having spend a good time and anoter half an hour they ordered three beers. The situation went on. Task: calculate how many beers they ordered after n half-hours for given n - number of half-hours.\r\n\r\nExample:\r\n\r\nn=1 result will be 2;\r\n\r\nn=2 result will be 4.","description_html":"\u003cp\u003eA group of students decided to visit Octoberfest festival. First they ordered one beer, then after half-hour they taken one more, after one more half-hour they ordered two more beers like sum of previous two times. Then after having spend a good time and anoter half an hour they ordered three beers. The situation went on. Task: calculate how many beers they ordered after n half-hours for given n - number of half-hours.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003en=1 result will be 2;\u003c/p\u003e\u003cp\u003en=2 result will be 4.\u003c/p\u003e","function_template":"function totalNumberOfOrderedBeers = OctoberfestFestival(n)  \r\n  totalNumberOfOrderedBeers=n\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 2;\r\nassert(isequal(OctoberfestFestival(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = 20;\r\nassert(isequal(OctoberfestFestival(x),y_correct))\r\n%%\r\nx = 10;\r\ny_correct = 232;\r\nassert(isequal(OctoberfestFestival(x),y_correct))","published":true,"deleted":false,"likes_count":4,"comments_count":11,"created_by":90467,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":498,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-10T19:33:58.000Z","updated_at":"2026-03-18T12:47:33.000Z","published_at":"2017-10-16T01:45: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\u003eA group of students decided to visit Octoberfest festival. First they ordered one beer, then after half-hour they taken one more, after one more half-hour they ordered two more beers like sum of previous two times. Then after having spend a good time and anoter half an hour they ordered three beers. The situation went on. Task: calculate how many beers they ordered after n half-hours for given n - number of half-hours.\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\u003en=1 result will be 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=2 result will be 4.\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":44314,"title":"A Simple Tide Gauge with MATLAB","description":"*\u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767* \r\n\r\nYou are standing in a few inches of sea water on a beach.\r\n\r\nYou are wondering whether the high tide is coming soon or it has just passed. \r\n\r\nTherefore, you will write a code in MATLAB to analyze following data. \r\n\r\nYou followed the sequence of water lines left by several swash of waves. \r\n\r\nThe data array A contains the distances the water traveled past your feet during each upward swash of waves. \r\n\r\nYour code will return 1 if the high tide is coming soon. \r\n\r\nYour code will return 0 if the high tide has just passed.    \r\n","description_html":"\u003cp\u003e\u003cb\u003e\u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767\u003c/b\u003e\u003c/p\u003e\u003cp\u003eYou are standing in a few inches of sea water on a beach.\u003c/p\u003e\u003cp\u003eYou are wondering whether the high tide is coming soon or it has just passed.\u003c/p\u003e\u003cp\u003eTherefore, you will write a code in MATLAB to analyze following data.\u003c/p\u003e\u003cp\u003eYou followed the sequence of water lines left by several swash of waves.\u003c/p\u003e\u003cp\u003eThe data array A contains the distances the water traveled past your feet during each upward swash of waves.\u003c/p\u003e\u003cp\u003eYour code will return 1 if the high tide is coming soon.\u003c/p\u003e\u003cp\u003eYour code will return 0 if the high tide has just passed.\u003c/p\u003e","function_template":"function tide = gauge(A)\r\n  tide=max(A)-min(A);\r\n  tide=tide*0;\r\nend","test_suite":"%%\r\nA = [5 8 10 12 8 13 14 10 10 15];\r\ntide_correct = 1;\r\nassert(isequal(gauge(A),tide_correct))\r\n%%\r\nA = [15 16 11 9 10 15 7 12 6 11 5 6];\r\ntide_correct = 0;\r\nassert(isequal(gauge(A),tide_correct))\r\n%%\r\nA = [9 15 3 9 5 18 4 17 18 19 8 13 12 21 17 24];\r\ntide_correct = 1;\r\nassert(isequal(gauge(A),tide_correct))\r\n%%\r\nA = [22 12 22 12 9 14 17 16 15 8 13 6 10 7 13 3];\r\ntide_correct = 0;\r\nassert(isequal(gauge(A),tide_correct))\r\n%%\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":3,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":394,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-12T00:26:53.000Z","updated_at":"2026-03-25T04:12:58.000Z","published_at":"2017-10-16T01:45: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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u0026amp;#8767 \u0026amp;#8767 \u0026amp;#8767 \u0026amp;#8767 \u0026amp;#8767 \u0026amp;#8767 \u0026amp;#8767 \u0026amp;#8767\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 standing in a few inches of sea water on a beach.\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 wondering whether the high tide is coming soon or it has just passed.\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\u003eTherefore, you will write a code in MATLAB to analyze following data.\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 followed the sequence of water lines left by several swash of waves.\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 data array A contains the distances the water traveled past your feet during each upward swash of waves.\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\u003eYour code will return 1 if the high tide is coming soon.\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\u003eYour code will return 0 if the high tide has just passed.\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":564,"title":"How to subtract?","description":"*\u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn* \r\n\r\n* Imagine you need to subtract one number from another using MATLAB.\r\n* You will not be using eval for this task.\r\n* Given two ASCII strings representing two integers X and Y.\r\n* Each of them has only 12 or less ASCII characters.\r\n* Each of them represents signed integers, such as '+2345'\r\n* Please output the result of (X-Y) in a similar style.","description_html":"\u003cp\u003e\u003cb\u003e\u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn\u003c/b\u003e\u003c/p\u003e\u003cul\u003e\u003cli\u003eImagine you need to subtract one number from another using MATLAB.\u003c/li\u003e\u003cli\u003eYou will not be using eval for this task.\u003c/li\u003e\u003cli\u003eGiven two ASCII strings representing two integers X and Y.\u003c/li\u003e\u003cli\u003eEach of them has only 12 or less ASCII characters.\u003c/li\u003e\u003cli\u003eEach of them represents signed integers, such as '+2345'\u003c/li\u003e\u003cli\u003ePlease output the result of (X-Y) in a similar style.\u003c/li\u003e\u003c/ul\u003e","function_template":"function Z = mysub(X,Y)\r\n   Z = 0;\r\nend\r\n","test_suite":"%%\r\nX='+68768686834554';\r\nY='+76574535435398';\r\nZ_correct='-7805848600844';\r\nassert(isequal(mysub(X,Y),Z_correct))\r\n\r\n%%\r\nX='+1';\r\nY='+2';\r\nZ_correct ='-1';\r\nassert(isequal(mysub(X,Y),Z_correct))\r\n\r\n%%\r\nX='+100';\r\nY='+20';\r\nZ_correct ='+80';\r\nassert(isequal(mysub(X,Y),Z_correct))\r\n","published":true,"deleted":false,"likes_count":7,"comments_count":11,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1535,"test_suite_updated_at":"2017-10-16T20:04:25.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2012-04-08T02:27:39.000Z","updated_at":"2026-02-04T22:10:20.000Z","published_at":"2017-10-16T01:45:05.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\u003e\u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eImagine you need to subtract one number from another using MATLAB.\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will not be using eval for this task.\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two ASCII strings representing two integers X and Y.\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEach of them has only 12 or less ASCII characters.\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEach of them represents signed integers, such as '+2345'\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePlease output the result of (X-Y) in a similar style.\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":44369,"title":"Circle/Pentagon Overlap","description":"Your function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return the number of pentagon vertices that lie within or on the circle. The tolerance for lying on the circle is 0.02.","description_html":"\u003cp\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return the number of pentagon vertices that lie within or on the circle. The tolerance for lying on the circle is 0.02.\u003c/p\u003e","function_template":"function y = circle_pentagon_overlap(p,cp,r)\r\n y = 0;\r\nend","test_suite":"%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 4;\r\ny_correct = 0;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 15;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [2,0];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [2,0.75];\r\nr = 5;\r\ny_correct = 3;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [7.5,0];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,-5];\r\nr = 9;\r\ny_correct = 4;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19,8];\r\nr = 5;\r\ny_correct = 3;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19.5,10];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19.5,10];\r\nr = 6.6;\r\ny_correct = 4;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19.5,10];\r\nr = 7;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8;\r\ny_correct = 0;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":327,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-10T18:44:43.000Z","updated_at":"2026-03-18T12:46:34.000Z","published_at":"2017-10-16T01:45: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\",\"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\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return the number of pentagon vertices that lie within or on the circle. The tolerance for lying on the circle is 0.02.\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":44358,"title":"I Plead the Fifth","description":"Write a function to provide a yes or no answer to the input string. However, it must plead the 5th amendment (return an empty string) if the number five or any variation thereof (e.g., fifth, fifty, fifteen, 5) is within the input string.","description_html":"\u003cp\u003eWrite a function to provide a yes or no answer to the input string. However, it must plead the 5th amendment (return an empty string) if the number five or any variation thereof (e.g., fifth, fifty, fifteen, 5) is within the input string.\u003c/p\u003e","function_template":"function answer = I_plead_the_fifth(question)\r\n str = 'yes/no';\r\nend","test_suite":"%%\r\nquestion = 'Are you the fifth child?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Were you at home on the night of 24 Oct 1974?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Did you go to work on 15 Oct 1955?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Did you go to the bowling alley last week?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Do you like bread?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Are there five fingers on your right hand?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Do you like pumpkins?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Do you have fifteen siblings?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Do two quarters equal fifty cents?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Do you own five dogs?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Is my name Harry?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))","published":true,"deleted":false,"likes_count":6,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":427,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-03T17:12:42.000Z","updated_at":"2026-03-22T03:30:09.000Z","published_at":"2017-10-16T01:45: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\",\"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 to provide a yes or no answer to the input string. However, it must plead the 5th amendment (return an empty string) if the number five or any variation thereof (e.g., fifth, fifty, fifteen, 5) is within the input 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":44363,"title":"Is this is a Tic Tac Toe X Win?","description":"For the game of Tic Tac Toe we will be storing the state of the game in a matrix M.\r\nFor this game:\r\n\r\nWe would store the state as this:\r\n-1  1  1 \r\n 1 -1 -1\r\n 1 -1 -1\r\nIf there were any blanks squares, they would be 0;\r\nFor this challenge, given a game state, does X (1) have a three in a row on any row, column or major diagonal?","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: 243.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 121.65px; transform-origin: 407px 121.65px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 50.5px 8px; transform-origin: 50.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor the game of\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\u003ca target='_blank' href = \"https://en.wikipedia.org/wiki/Tic-tac-toe\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eTic Tac Toe\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 167.5px 8px; transform-origin: 167.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e we will be storing the state of the game in a matrix M.\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: 45.5px 8px; transform-origin: 45.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor this game:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\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: 102.5px 8px; transform-origin: 102.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWe would store the state as this:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 61.3px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 30.65px; transform-origin: 404px 30.65px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 36px 8.5px; tab-size: 4; transform-origin: 36px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e-1  1  1 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 32px 8.5px; tab-size: 4; transform-origin: 32px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e 1 -1 -1\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 32px 8.5px; tab-size: 4; transform-origin: 32px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e 1 -1 -1\u003c/span\u003e\u003c/span\u003e\u003c/div\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: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; 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: 158px 8px; transform-origin: 158px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf there were any blanks squares, they would be 0;\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: 349px 8px; transform-origin: 349px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor this challenge, given a game state, does X (1) have a three in a row on any row, column or major diagonal?\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function flagWin = your_fcn_name(M)\r\n  flagWin = false\r\nend","test_suite":"%%\r\nx = [1 1 1\r\n     0 0 0\r\n     0 0 0];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [1 0 0\r\n     0 1 0\r\n     0 0 1];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [1 0 0\r\n     0 -1 0\r\n     1 0 1];\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [1 0 0\r\n     1 0 0\r\n     1 0 0];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [1 0 0\r\n     1 -1 0\r\n     1 0 0];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [0 0 1\r\n     0 1 0\r\n     1 0 0];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [1  0 0\r\n     0 -1 0\r\n     0  0 1];\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [1 0 0\r\n     0 1 0\r\n     0 0 1];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [-1 0 0\r\n     0 -1 0\r\n     0 0 -1];\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":240,"edited_by":223089,"edited_at":"2022-07-28T15:36:47.000Z","deleted_by":null,"deleted_at":null,"solvers_count":532,"test_suite_updated_at":"2022-07-28T15:36:47.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-09T23:11:43.000Z","updated_at":"2026-03-18T12:43:46.000Z","published_at":"2017-10-16T01:45:09.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\u003eFor the game of\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/Tic-tac-toe\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eTic Tac Toe\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e we will be storing the state of the game in a matrix M.\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 this game:\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\u003eWe would store the state as this:\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[-1  1  1 \\n 1 -1 -1\\n 1 -1 -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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf there were any blanks squares, they would be 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\u003eFor this challenge, given a game state, does X (1) have a three in a row on any row, column or major diagonal?\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":44384,"title":"Find the nearest prime number","description":"Happy 5th birthday, Cody! Since 5 is a prime number, let's have some fun looking for other prime numbers.\r\n\r\nGiven a positive integer x, find the nearest prime number. Keep in mind that the nearest prime may be less than x.\r\n\r\n*Examples*\r\n\r\n  nearestprime(5) = 5\r\n  nearestprime(36) = 37\r\n  nearestprime(200) = 199\r\n\r\nNOTE: You may ignore cases in which two prime numbers are equally close to x. (e.g., x=12 --\u003e 11 and 13 are both primes). ","description_html":"\u003cp\u003eHappy 5th birthday, Cody! Since 5 is a prime number, let's have some fun looking for other prime numbers.\u003c/p\u003e\u003cp\u003eGiven a positive integer x, find the nearest prime number. Keep in mind that the nearest prime may be less than x.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExamples\u003c/b\u003e\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003enearestprime(5) = 5\r\nnearestprime(36) = 37\r\nnearestprime(200) = 199\r\n\u003c/pre\u003e\u003cp\u003eNOTE: You may ignore cases in which two prime numbers are equally close to x. (e.g., x=12 --\u0026gt; 11 and 13 are both primes).\u003c/p\u003e","function_template":"function y = nearestprime(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 0;\r\ny_correct = 2;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 5;\r\ny_correct = 5;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 100;\r\ny_correct = 101;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 500;\r\ny_correct = 499;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 911;\r\ny_correct = 911;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 2500;\r\ny_correct = 2503;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 8000;\r\ny_correct = 7993;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 100000;\r\ny_correct = 100003;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 1300000;\r\ny_correct = 1299989;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 179424710;\r\ny_correct = 179424719;\r\nassert(isequal(nearestprime(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":9,"comments_count":1,"created_by":4793,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":663,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-13T19:42:15.000Z","updated_at":"2026-03-20T10:59:25.000Z","published_at":"2017-10-16T01:45: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\u003eHappy 5th birthday, Cody! Since 5 is a prime number, let's have some fun looking for other prime numbers.\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\u003eGiven a positive integer x, find the nearest prime number. Keep in mind that the nearest prime may be less than x.\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\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[nearestprime(5) = 5\\nnearestprime(36) = 37\\nnearestprime(200) = 199]]\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: You may ignore cases in which two prime numbers are equally close to x. (e.g., x=12 --\u0026gt; 11 and 13 are both primes).\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":44385,"title":"Extra safe primes","description":"Did you know that the number 5 is the first safe prime? A safe prime is a prime number that can be expressed as 2p+1, where p is also a prime.\r\n\r\nTo celebrate Cody's Five-Year Anniversary, write a function to determine if a positive integer n is a safe prime in which the prime p (such that n=2p+1) is *also a safe prime*.\r\n\r\n*Examples*\r\n\r\n  isextrasafe(5) = false % because 5=2*2+1 and 2 is not a safe prime\r\n  isextrasafe(23) = true % because 23=2*11+1 and 11 is also a safe prime (11=2*5+1)\r\n","description_html":"\u003cp\u003eDid you know that the number 5 is the first safe prime? A safe prime is a prime number that can be expressed as 2p+1, where p is also a prime.\u003c/p\u003e\u003cp\u003eTo celebrate Cody's Five-Year Anniversary, write a function to determine if a positive integer n is a safe prime in which the prime p (such that n=2p+1) is \u003cb\u003ealso a safe prime\u003c/b\u003e.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExamples\u003c/b\u003e\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eisextrasafe(5) = false % because 5=2*2+1 and 2 is not a safe prime\r\nisextrasafe(23) = true % because 23=2*11+1 and 11 is also a safe prime (11=2*5+1)\r\n\u003c/pre\u003e","function_template":"function tf = isextrasafe(x)\r\n    tf = false;\r\nend","test_suite":"%%\r\nx = 0;\r\nassert(isequal(isextrasafe(x),false))\r\n\r\n%%\r\nx = 5;\r\nassert(isequal(isextrasafe(x),false))\r\n\r\n%%\r\nx = 7;\r\nassert(isequal(isextrasafe(x),false))\r\n\r\n%%\r\nx = 11;\r\nassert(isequal(isextrasafe(x),true))\r\n\r\n%%\r\nx = 15;\r\nassert(isequal(isextrasafe(x),false))\r\n\r\n%%\r\nx = 23;\r\nassert(isequal(isextrasafe(x),true))\r\n\r\n%%\r\nx = 71;\r\nassert(isequal(isextrasafe(x),false))\r\n\r\n%%\r\nx = 719;\r\nassert(isequal(isextrasafe(x),true))\r\n\r\n%%\r\nx = 2039;\r\nassert(isequal(isextrasafe(x),true))\r\n\r\n%%\r\nx = 2040;\r\nassert(isequal(isextrasafe(x),false))\r\n\r\n%%\r\nx = 5807;\r\nassert(isequal(isextrasafe(x),true))","published":true,"deleted":false,"likes_count":13,"comments_count":4,"created_by":4793,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":756,"test_suite_updated_at":"2017-10-19T17:09:19.000Z","rescore_all_solutions":true,"group_id":34,"created_at":"2017-10-13T20:02:13.000Z","updated_at":"2026-03-25T08:22:41.000Z","published_at":"2017-10-16T01:45: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\u003eDid you know that the number 5 is the first safe prime? A safe prime is a prime number that can be expressed as 2p+1, where p is also a prime.\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\u003eTo celebrate Cody's Five-Year Anniversary, write a function to determine if a positive integer n is a safe prime in which the prime p (such that n=2p+1) 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\u003ealso a safe prime\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\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[isextrasafe(5) = false % because 5=2*2+1 and 2 is not a safe prime\\nisextrasafe(23) = true % because 23=2*11+1 and 11 is also a safe prime (11=2*5+1)]]\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":44319,"title":"Write c^3 as sum of two squares a^2+b^2","description":"write c^3 as sum of two squares a^2+b^2. a and b must be integer and greater than zero.\r\n\r\nFor example \r\n\r\n 5^3 = 2^2 + 11^2\r\n 5^3 = 5^2 + 10^2\r\n 10^3 = 10^2 + 30^2\r\n 10^3 = 18^2 + 26^2\r\n\r\nsort output matrix so that each row and first column is in ascending order.","description_html":"\u003cp\u003ewrite c^3 as sum of two squares a^2+b^2. a and b must be integer and greater than zero.\u003c/p\u003e\u003cp\u003eFor example\u003c/p\u003e\u003cpre\u003e 5^3 = 2^2 + 11^2\r\n 5^3 = 5^2 + 10^2\r\n 10^3 = 10^2 + 30^2\r\n 10^3 = 18^2 + 26^2\u003c/pre\u003e\u003cp\u003esort output matrix so that each row and first column is in ascending order.\u003c/p\u003e","function_template":"function y = sumoftwosquares(c)\r\n\r\nend","test_suite":"%%\r\nc = 1;\r\ny_correct = [];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 5;\r\ny_correct = [2 11; 5 10];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 6;\r\ny_correct = [];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 10;\r\ny_correct = [10 30; 18 26];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 20;\r\ny_correct = [16 88; 40 80];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 24;\r\ny_correct = [];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 40;\r\ny_correct = [80 240; 144 208];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 65;\r\ny_correct = [7 524; 65 520; 140 505; 191 488; 208 481; 260 455; 320 415; 364 377];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 100;\r\ny_correct = [280 960; 352 936; 600 800];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 123;\r\ny_correct = [];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 340;\r\ny_correct = [408 6256;1360 6120; 1680 6040; 2280 5840; 2584 5712; 3304 5328; 3824 4968; 4080 4760];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 500;\r\ny_correct = [1160 11120; 2000 11000; 5000 10000; 5744 9592; 7600 8200];\r\nassert(isequal(sumoftwosquares(c),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":329,"test_suite_updated_at":"2017-10-16T17:19:22.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-12T19:54:46.000Z","updated_at":"2026-04-01T13:09:32.000Z","published_at":"2017-10-16T01:45: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\u003ewrite c^3 as sum of two squares a^2+b^2. a and b must be integer and greater than zero.\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[ 5^3 = 2^2 + 11^2\\n 5^3 = 5^2 + 10^2\\n 10^3 = 10^2 + 30^2\\n 10^3 = 18^2 + 26^2]]\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\u003esort output matrix so that each row and first column is in ascending order.\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":44360,"title":"Pentagonal Numbers","description":"Your function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascending order. Additionally, it should return an array that indicates those numbers that are divisible by 5. For example,\r\n\r\n [p,d] = pentagonal_numbers(10,40)\r\n\r\nshould return\r\n\r\n p = [12,22,35]\r\n d = [ 0, 0, 1]","description_html":"\u003cp\u003eYour function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascending order. Additionally, it should return an array that indicates those numbers that are divisible by 5. For example,\u003c/p\u003e\u003cpre\u003e [p,d] = pentagonal_numbers(10,40)\u003c/pre\u003e\u003cp\u003eshould return\u003c/p\u003e\u003cpre\u003e p = [12,22,35]\r\n d = [ 0, 0, 1]\u003c/pre\u003e","function_template":"function [p,d] = pentagonal_numbers(10,40)\r\n p = [5];\r\n d = [1];\r\nend","test_suite":"%%\r\nx1 = 1; x2 = 25;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1,5,12,22]))\r\nassert(isequal(d,[0,1,0,0]))\r\n\r\n%%\r\nx1 = 1; x2 = 4;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,1))\r\nassert(isequal(d,0))\r\n\r\n%%\r\nx1 = 10; x2 = 40;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[12,22,35]))\r\nassert(isequal(d,[0,0,1]))\r\n\r\n%%\r\nx1 = 10; x2 = 99;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[12,22,35,51,70,92]))\r\nassert(isequal(d,[0,0,1,0,1,0]))\r\n\r\n%%\r\nx1 = 100; x2 = 999;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[117,145,176,210,247,287,330,376,425,477,532,590,651,715,782,852,925]))\r\nassert(isequal(d,[0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1]))\r\n\r\n%%\r\nx1 = 40; x2 = 50;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isempty(p))\r\nassert(isempty(d))\r\n\r\n%%\r\nx1 = 1000; x2 = 1500;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1001,1080,1162,1247,1335,1426]))\r\nassert(isequal(d,[0,1,0,0,1,0]))\r\n\r\n%%\r\nx1 = 1500; x2 = 3000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1520,1617,1717,1820,1926,2035,2147,2262,2380,2501,2625,2752,2882]))\r\nassert(isequal(d,[1,0,0,1,0,1,0,0,1,0,1,0,0]))\r\n\r\n%%\r\nx1 = 1; x2 = 3000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1,5,12,22,35,51,70,92,117,145,176,210,247,287,330,376,425,477,532,590,651,715,782,852,925,1001,1080,1162,1247,1335,1426,1520,1617,1717,1820,1926,2035,2147,2262,2380,2501,2625,2752,2882]))\r\nassert(isequal(d,[0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0]))\r\n\r\n%%\r\nx1 = 10000; x2 = 12000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[10045,10292,10542,10795,11051,11310,11572,11837]))\r\nassert(isequal(d,[1,0,0,1,0,1,0,0]))\r\n\r\n%%\r\nx1 = 100000; x2 = 110000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[100492,101270,102051,102835,103622,104412,105205,106001,106800,107602,108407,109215]))\r\nassert(isequal(d,[0,1,0,1,0,0,1,0,1,0,0,1]))\r\n\r\n%%\r\nx1 = 1000000; x2 = 1010101;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1000825,1003277,1005732,1008190]))\r\nassert(isequal(d,[1,0,0,1]))","published":true,"deleted":false,"likes_count":12,"comments_count":3,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":677,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-05T17:43:36.000Z","updated_at":"2026-03-18T12:42:40.000Z","published_at":"2017-10-16T01:45: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\u003eYour function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascending order. Additionally, it should return an array that indicates those numbers that are divisible by 5. 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[ [p,d] = pentagonal_numbers(10,40)]]\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[ p = [12,22,35]\\n d = [ 0, 0, 1]]]\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":44368,"title":"Inscribed Pentagon?","description":"Your function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon will be centered about the circle. The function should return one of the following values:\r\n\r\n  0: the pentagon is completely enclosed within the circle but is not inscribed\r\n  1: the pentagon is inscribed in the circle (within ±0.02)\r\n  2: the vertices of the pentagon extend beyond the circle\r\n\r\nPoints will be rounded to the nearest hundredth. See the test cases for examples.","description_html":"\u003cp\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon will be centered about the circle. The function should return one of the following values:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0: the pentagon is completely enclosed within the circle but is not inscribed\r\n1: the pentagon is inscribed in the circle (within ±0.02)\r\n2: the vertices of the pentagon extend beyond the circle\r\n\u003c/pre\u003e\u003cp\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples.\u003c/p\u003e","function_template":"function y = inscribed_pentagon(p,cp,r)\r\n y = 0;\r\nend","test_suite":"%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [25.01,12.47; 25.98,4.58; 18.78,1.23; 13.37,7.03; 17.22,13.97];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.27,11.12; 23.92,5.87; 19.12,3.63; 15.52,7.50; 18.08,12.13];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [32.54,38.78; 38.84,26.41; 29.02,16.59; 16.65,22.89; 18.83,36.61];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.49,35.54; 34.69,27.29; 28.14,20.74; 19.89,24.95; 21.34,34.09];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),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":306,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-10T16:31:01.000Z","updated_at":"2026-03-18T12:45:42.000Z","published_at":"2017-10-16T01:45: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\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon will be centered about the circle. The function should return one of the following values:\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[0: the pentagon is completely enclosed within the circle but is not inscribed\\n1: the pentagon is inscribed in the circle (within ±0.02)\\n2: the vertices of the pentagon extend beyond the circle]]\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\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples.\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":44342,"title":"Spot the First Occurrence of 5","description":"This problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate \u003chttps://www.mathworks.com/matlabcentral/cody/contests/1?s_tid=Cody5YA_cody_home Cody's 5th birthday\u003e. \r\n\r\nIn this problem, let's determine the position (index) of the first occurrence of 5 along the first non-singleton dimension of an input array. \r\n\r\nE.g., \r\n\r\n* If the input is a vector, return the index of the first occurrence of 5. \r\n\r\n  x = [1 2 5 3 5];\r\n  y = 3;\r\n\r\n* If the input is a matrix, return the index of the first occurrence of 5 in each column. If 5 is not found, simply return 0; \r\n\r\n  % Input x is a matrix\r\n  x = [1 2 5\r\n       5 9 1\r\n       5 6 5];\r\n\r\n  % Output y\r\n  y = [2 0 1];\r\n\r\nNext problem in this series: \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44352-the-top-5-primes The Top 5 Primes\u003e","description_html":"\u003cp\u003eThis problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/contests/1?s_tid=Cody5YA_cody_home\"\u003eCody's 5th birthday\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eIn this problem, let's determine the position (index) of the first occurrence of 5 along the first non-singleton dimension of an input array.\u003c/p\u003e\u003cp\u003eE.g.,\u003c/p\u003e\u003cul\u003e\u003cli\u003eIf the input is a vector, return the index of the first occurrence of 5.\u003c/li\u003e\u003c/ul\u003e\u003cpre class=\"language-matlab\"\u003ex = [1 2 5 3 5];\r\ny = 3;\r\n\u003c/pre\u003e\u003cul\u003e\u003cli\u003eIf the input is a matrix, return the index of the first occurrence of 5 in each column. If 5 is not found, simply return 0;\u003c/li\u003e\u003c/ul\u003e\u003cpre class=\"language-matlab\"\u003e% Input x is a matrix\r\nx = [1 2 5\r\n     5 9 1\r\n     5 6 5];\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003e% Output y\r\ny = [2 0 1];\r\n\u003c/pre\u003e\u003cp\u003eNext problem in this series: \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44352-the-top-5-primes\"\u003eThe Top 5 Primes\u003c/a\u003e\u003c/p\u003e","function_template":"function y = locOf5(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','locOf5.m')\r\n\r\n%%\r\nx = 2:2:20;\r\ny_correct = 0;\r\nassert(isequal(locOf5(x),y_correct))\r\n\r\n%%\r\nx = rot90(1:10);\r\ny_correct = 6;\r\nassert(isequal(locOf5(x),y_correct))\r\n\r\n%%\r\nx = [1 2 5\r\n     5 9 1\r\n     5 6 5];\r\ny_correct = [2 0 1];\r\nassert(isequal(locOf5(x),y_correct))\r\n\r\n%%\r\nx = magic(5);\r\ny_correct = [0 2 0 0 0];\r\nassert(isequal(locOf5(x),y_correct))\r\n\r\n%%\r\nx = [1 2 3 4 5;\r\n     5 4 3 2 1\r\n     2 3 5 2 1\r\n     1 5 2 6 8\r\n     3 5 2 2 5];\r\ny_correct = [2 4 3 0 1];\r\nassert(isequal(locOf5(x),y_correct))\r\n\r\n% %%\r\n% x = randi([-10,10],20,1e6); \r\n% x(x==5) = 0;\r\n% p = sort(randi([0 size(x,1)],5,size(x,2)));\r\n% y_correct = p(1,:);\r\n% p(2:end,~y_correct) = 0;\r\n% [~,col,v] = find(p);\r\n% x((col-1)*size(x,1)+v) = 5;\r\n% assert(isequal(locOf5(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":12569,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":434,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-20T14:43:55.000Z","updated_at":"2026-03-18T13:43:25.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\u003eThis problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate\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/contests/1?s_tid=Cody5YA_cody_home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody's 5th birthday\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\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn this problem, let's determine the position (index) of the first occurrence of 5 along the first non-singleton dimension of an input array.\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\u003eE.g.,\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the input is a vector, return the index of the first occurrence of 5.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[x = [1 2 5 3 5];\\ny = 3;]]\u003e\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the input is a matrix, return the index of the first occurrence of 5 in each column. If 5 is not found, simply return 0;\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 x is a matrix\\nx = [1 2 5\\n     5 9 1\\n     5 6 5];\\n\\n% Output y\\ny = [2 0 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\u003eNext problem in this series:\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/44352-the-top-5-primes\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eThe Top 5 Primes\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":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":44338,"title":"Recaman Sequence - I","description":"Recaman Sequence (A005132 - \u003chttp://oeis.org/A005132 - OEIS Link\u003e) is defined as follow;\r\n\r\n  seq(0) = 0; \r\n  for n \u003e 0, seq(n) = seq(n-1) - n if positive and not already in the sequence, \r\n  otherwise seq(n) = seq(n-1) + n. \r\n\r\n  seq = 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9 ...\r\nindex = 1, 2, 3 ,...\r\n\r\nTo avoid zero index, start indexing from 1.\r\nreturn the first n elements in Recaman Sequence\r\n\r\n*Related Challenges :*\r\n\r\n# Recaman Sequence - I\r\n# \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44339 Recaman Sequence - II\u003e\r\n# \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44340 Recaman Sequence - III\u003e\r\n","description_html":"\u003cp\u003eRecaman Sequence (A005132 - \u003ca href = \"http://oeis.org/A005132\"\u003e- OEIS Link\u003c/a\u003e) is defined as follow;\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eseq(0) = 0; \r\nfor n \u0026gt; 0, seq(n) = seq(n-1) - n if positive and not already in the sequence, \r\notherwise seq(n) = seq(n-1) + n. \r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eseq = 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9 ...\r\nindex = 1, 2, 3 ,...\r\n\u003c/pre\u003e\u003cp\u003eTo avoid zero index, start indexing from 1.\r\nreturn the first n elements in Recaman Sequence\u003c/p\u003e\u003cp\u003e\u003cb\u003eRelated Challenges :\u003c/b\u003e\u003c/p\u003e\u003col\u003e\u003cli\u003eRecaman Sequence - I\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44339\"\u003eRecaman Sequence - II\u003c/a\u003e\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44340\"\u003eRecaman Sequence - III\u003c/a\u003e\u003c/li\u003e\u003c/ol\u003e","function_template":"function y = Recaman(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 0;\r\nassert(isequal(Recaman(x),y_correct))\r\n\r\n%%\r\nx = 5;\r\ny_correct = [0 1 3 6 2];\r\nassert(isequal(Recaman(x),y_correct))\r\n\r\n%%\r\nx = 8;\r\ny_correct = [0 1 3 6 2 7 13 20];\r\nassert(isequal(Recaman(x),y_correct))\r\n\r\n%%\r\nx = 10;\r\ny_correct = [0 1 3 6 2 7 13 20 12 21];\r\nassert(isequal(Recaman(x),y_correct))\r\n\r\n%%\r\nx = 5e4;\r\ny = Recaman(x);\r\nassert(isequal(length(Recaman(x)),x))\r\nassert(isequal(y(954),739))\r\nassert(isequal(y(7589),17654))\r\nassert(isequal(y(12345),18554))\r\n\r\n%%\r\nx = 1e5;\r\ny = Recaman(x);\r\nassert(isequal(length(Recaman(x)),x))\r\nassert(isequal(y(1e4),8658))\r\nassert(isequal(y(2e4),34358))\r\nassert(isequal(y(3e4),92474))\r\nassert(isequal(y(4e4),102344))","published":true,"deleted":false,"likes_count":3,"comments_count":8,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":321,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-19T06:55:43.000Z","updated_at":"2026-03-22T11:16:16.000Z","published_at":"2017-10-16T01:45: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\u003eRecaman Sequence (A005132 -\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://oeis.org/A005132\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e- OEIS Link\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e) is defined as follow;\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[seq(0) = 0; \\nfor n \u003e 0, seq(n) = seq(n-1) - n if positive and not already in the sequence, \\notherwise seq(n) = seq(n-1) + n. \\n\\nseq = 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9 ...\\nindex = 1, 2, 3 ,...]]\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\u003eTo avoid zero index, start indexing from 1. return the first n elements in Recaman Sequence\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\u003eRecaman Sequence - I\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/44339\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eRecaman Sequence - II\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:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44340\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eRecaman Sequence - III\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":44334,"title":"Sums of Multiple Pairs of Triangular Numbers","description":"This is a follow-up to \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44289 Problem 44289\u003e - Find two triangular numbers whose sum is input.\r\n\r\nThere are some numbers that are the sum of multiple pairs of triangular numbers.  For example, 81 = 36+45 = 15+66 = 3+78.  Given a number X, find all of the possible pairs of triangular numbers that add up to X.  Your answer should be in a 2-by-X matrix.  Each column of the matrix should sum to X, and each pair of triangular numbers should only appear once.  The top row sorted from low to high.  The output for 81 would be:\r\n\r\n [ 3   15  36 \r\n  78   66  45]\r\n\r\nGood luck!","description_html":"\u003cp\u003eThis is a follow-up to \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44289\"\u003eProblem 44289\u003c/a\u003e - Find two triangular numbers whose sum is input.\u003c/p\u003e\u003cp\u003eThere are some numbers that are the sum of multiple pairs of triangular numbers.  For example, 81 = 36+45 = 15+66 = 3+78.  Given a number X, find all of the possible pairs of triangular numbers that add up to X.  Your answer should be in a 2-by-X matrix.  Each column of the matrix should sum to X, and each pair of triangular numbers should only appear once.  The top row sorted from low to high.  The output for 81 would be:\u003c/p\u003e\u003cpre\u003e [ 3   15  36 \r\n  78   66  45]\u003c/pre\u003e\u003cp\u003eGood luck!\u003c/p\u003e","function_template":"function y = multi_triangular(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 21;\r\ny_correct = [6;15];\r\nassert(isequal(multi_triangular(x),y_correct))\r\n%%\r\nx=81;\r\ny_correct=[ 3   15  36 ;  78   66  45];\r\nassert(isequal(multi_triangular(x),y_correct))\r\n%%\r\nx=20;\r\ny_correct=[ 10 10];\r\nassert(isequal(multi_triangular(x),y_correct'))\r\n%%\r\nx=17956;\r\ny_correct=[ 1 190 378 1485 2556  4095 4753 6328 8911;\r\n 17955 17766 17578 16471 15400 13861 13203 11628 9045];\r\nassert(isequal(multi_triangular(x),y_correct))\r\n%%\r\nx=70;\r\ny_correct=[15 55];\r\nassert(isequal(multi_triangular(x),y_correct'));\r\n%%\r\nx=37052031;\r\ny_correct=[7503 16110 93528 119316 136503 393828 496506 778128 1033203 1194285 1675365 1876953 2503203 2627778 3214380 3436131 3983253 4226778 4943940 5112003 5279625 6063903 6417153 7055646 7771653 8456328 8855736 9801378 10015050 11221953 11580078 12834711 13846953 14084778 15149760 15387378 15531951 17096628 17567628 18395145;\r\n37044528 37035921 36958503 36932715 36915528 36658203 36555525 36273903 36018828 35857746 35376666 35175078 34548828 34424253 33837651 33615900 33068778 32825253 32108091 31940028 31772406 30988128 30634878 29996385 29280378 28595703 28196295 27250653 27036981 25830078 25471953 24217320 23205078 22967253 21902271 21664653 21520080 19955403 19484403 18656886];\r\nassert(isequal(multi_triangular(x),y_correct));\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":247,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-15T19:37:34.000Z","updated_at":"2026-03-22T12:09:49.000Z","published_at":"2017-10-16T01:45: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\u003eThis is a follow-up 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=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44289\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44289\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e - Find two triangular numbers whose sum is input.\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\u003eThere are some numbers that are the sum of multiple pairs of triangular numbers. For example, 81 = 36+45 = 15+66 = 3+78. Given a number X, find all of the possible pairs of triangular numbers that add up to X. Your answer should be in a 2-by-X matrix. Each column of the matrix should sum to X, and each pair of triangular numbers should only appear once. The top row sorted from low to high. The output for 81 would be:\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[ [ 3   15  36 \\n  78   66  45]]]\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\u003eGood 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":44321,"title":"Van Eck's Sequence's nth member","description":"Return the Van Eck's Sequence's nth member.\r\n\r\nFor detailed info : \u003chttp://oeis.org/A181391 OEIS link\u003e and \u003chttps://www.theguardian.com/science/alexs-adventures-in-numberland/2014/oct/07/neil-sloane-the-man-who-loved-only-integer-sequences here\u003e\r\n\r\n seq = 0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5...\r\n\r\nFirst member is 0;\r\n\r\nSecond member is 0;\r\n\r\nthird member is 1 etc\r\n","description_html":"\u003cp\u003eReturn the Van Eck's Sequence's nth member.\u003c/p\u003e\u003cp\u003eFor detailed info : \u003ca href = \"http://oeis.org/A181391\"\u003eOEIS link\u003c/a\u003e and \u003ca href = \"https://www.theguardian.com/science/alexs-adventures-in-numberland/2014/oct/07/neil-sloane-the-man-who-loved-only-integer-sequences\"\u003ehere\u003c/a\u003e\u003c/p\u003e\u003cpre\u003e seq = 0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5...\u003c/pre\u003e\u003cp\u003eFirst member is 0;\u003c/p\u003e\u003cp\u003eSecond member is 0;\u003c/p\u003e\u003cp\u003ethird member is 1 etc\u003c/p\u003e","function_template":"function result = VanEcksSequence(n)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 0;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 2;\r\ny_correct = 0;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 4;\r\ny_correct = 0;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 6;\r\ny_correct = 0;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 11;\r\ny_correct = 0;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 50;\r\ny_correct = 3;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 500;\r\ny_correct = 4;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n\r\n%%\r\nx = 5000;\r\ny_correct = 402;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 50000;\r\ny_correct = 114;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":12,"comments_count":1,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":331,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-13T08:14:57.000Z","updated_at":"2026-03-24T14:52:41.000Z","published_at":"2017-10-16T01:45:07.000Z","restored_at":"2017-09-28T06:15:18.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\u003eReturn the Van Eck's Sequence's nth member.\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 detailed info :\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://oeis.org/A181391\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOEIS link\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=\\\"https://www.theguardian.com/science/alexs-adventures-in-numberland/2014/oct/07/neil-sloane-the-man-who-loved-only-integer-sequences\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\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=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ seq = 0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 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\u003eFirst member is 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSecond member is 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethird member is 1 etc\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":44339,"title":"Recaman Sequence - II","description":"Take an arbitrary starting point as input and create Recaman Sequence. Then find the 1, return its index.\r\n\r\nFor example: if n = 0 (default Recaman sequence)\r\n  \r\n  seq = [0 1 3 6 2];\r\n\r\n1 is in the second place. \r\n\r\nif n = 10;\r\n\r\n  seq = [10 9 7 4 8 3 9 2 10 1 11 22 34 21];\r\n\r\n1 is in the 10th place\r\n\r\n*Related Challenges :*\r\n\r\n# \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44338 Recaman Sequence - I\u003e\r\n# Recaman Sequence - II\r\n# \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44340 Recaman Sequence - III\u003e","description_html":"\u003cp\u003eTake an arbitrary starting point as input and create Recaman Sequence. Then find the 1, return its index.\u003c/p\u003e\u003cp\u003eFor example: if n = 0 (default Recaman sequence)\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eseq = [0 1 3 6 2];\r\n\u003c/pre\u003e\u003cp\u003e1 is in the second place.\u003c/p\u003e\u003cp\u003eif n = 10;\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eseq = [10 9 7 4 8 3 9 2 10 1 11 22 34 21];\r\n\u003c/pre\u003e\u003cp\u003e1 is in the 10th place\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/44338\"\u003eRecaman Sequence - I\u003c/a\u003e\u003c/li\u003e\u003cli\u003eRecaman Sequence - II\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44340\"\u003eRecaman Sequence - III\u003c/a\u003e\u003c/li\u003e\u003c/ol\u003e","function_template":"function y = RecamanII(startPoint)\r\n\r\nend","test_suite":"%%\r\nx = 0;\r\ny_correct = 2;\r\nassert(isequal(RecamanII(x),y_correct))\r\n\r\n%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(RecamanII(x),y_correct))\r\n\r\n%%\r\nx = 3;\r\ny_correct = 4;\r\nassert(isequal(RecamanII(x),y_correct))\r\n\r\n%%\r\nx = 90;\r\ny_correct = 35;\r\nassert(isequal(RecamanII(x),y_correct))\r\n\r\n%%\r\nx = 123456;\r\ny_correct = 895;\r\nassert(isequal(RecamanII(x),y_correct))\r\n\r\n%%\r\nx = 123456789;\r\ny_correct = 46633;\r\nassert(isequal(RecamanII(x),y_correct))\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":280,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-19T07:08:59.000Z","updated_at":"2026-03-22T11:06:47.000Z","published_at":"2017-10-16T01:45: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\u003eTake an arbitrary starting point as input and create Recaman Sequence. Then find the 1, return its index.\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: if n = 0 (default Recaman sequence)\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[seq = [0 1 3 6 2];]]\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\u003e1 is in the second place.\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 n = 10;\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[seq = [10 9 7 4 8 3 9 2 10 1 11 22 34 21];]]\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\u003e1 is in the 10th place\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/44338\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eRecaman Sequence - I\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\u003eRecaman Sequence - II\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/44340\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eRecaman Sequence - III\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":44305,"title":"5 Prime Numbers","description":"Your function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\r\n\r\nFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\r\n\r\n p = [61,67,71,73,79, ... 149,151,157,163, ... 241,251,257,263, ... 349,353,359,367, ... 983,991,997]\r\n\r\nThis set contains at least five numbers that contain a five; the first five are:\r\n\r\n p5 = [151,157,251,257,353]\r\n\r\nwhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).","description_html":"\u003cdiv style = \"text-align: start; line-height: 20px; 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: normal; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; transform-origin: 420.4375px 118px; vertical-align: baseline; perspective-origin: 420.4375px 118px; \"\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; transform-origin: 309px 31.5px; white-space: pre-wrap; perspective-origin: 309px 31.5px; 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; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYour function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\u003c/span\u003e\u003c/span\u003e\u003c/div\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; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; 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; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 417.4375px 10px; perspective-origin: 417.4375px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; 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-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e p = [61,67,71,73,79, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e149,151,157,163, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e241,251,257,263, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e349,353,359,367, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e983,991,997]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eThis set contains at least five numbers that contain a five; the first five are:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 417.4375px 10px; perspective-origin: 417.4375px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; 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-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e p5 = [151,157,251,257,353]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 21px; white-space: pre-wrap; perspective-origin: 309px 21px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003ewhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = five_primes(n_min,n_max)\r\n  y = [];\r\nend","test_suite":"%%\r\nn_min = 60;\r\nn_max = 1000;\r\ny_correct = [151,157,251,257,353];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 60;\r\nn_max = 300;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 1;\r\nn_max = 200;\r\ny_correct = [5,53,59,151,157];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 1;\r\nn_max = 100;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 600;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 555;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 500000000;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 5020;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 5200;\r\ny_correct = [5003,5009,5011,5021,5023];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 55555555;\r\ny_correct = [5003,5009,5011,5021,5023];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 55555;\r\nn_max = 56789;\r\ny_correct = [55579,55589,55603,55609,55619];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 987654321;\r\nn_max = 988777666;\r\ny_correct = [987654323,987654337,987654347,987654359,987654361];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))","published":true,"deleted":false,"likes_count":7,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":453,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-08T18:33:05.000Z","updated_at":"2026-04-06T09:57:52.000Z","published_at":"2017-10-16T01:45:06.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\u003eYour function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, for n_min = 60 and n_max = 1000, the set of prime numbers 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[ p = [61,67,71,73,79, … 149,151,157,163, … 241,251,257,263, … 349,353,359,367, … 983,991,997]]]\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\u003eThis set contains at least five numbers that contain a five; the first five are:\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[ p5 = [151,157,251,257,353]]]\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\u003ewhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).\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":44307,"title":"The glass half full","description":"Identical glasses are placed in a triangular tower structure, such that the top level (L = 1) comprises one glass, the next level down (L = 2) comprises three glasses, the next level down (L = 3) comprises six glasses, and so on.\r\n\r\nFollow the \u003chttps://imgur.com/a/j9ZZa link\u003e to see a diagram shows the first three levels. The glasses in each levels are represented by the blue circles, while the yellow circles represent the positions of the glasses in the next higher level.\r\n\r\nWater is poured into the top glass at a constant volumetric flow rate. When the glass is filled, the water starts spilling over and into the glasses below. Note that *water only spills outward* , meaning that at some point, some glasses will remain empty.\r\n\r\nGiven the volume of a glass in liters, v, the volumetric flow rate in liters per second, u, and an integer, L, representing a level in the glass structure, return the total number of glasses in that level, g, the number of glasses in that level that will be filled with water, f, and the time, in seconds, it would take to fill all \"fillable\" glasses in that level, t, starting with no water in any of the levels.\r\n\r\nExample:\r\n\r\nInput: v = 0.25, u = 0.1, L = 2\r\n\r\nOutput: g = 3, f = 3, t = 10","description_html":"\u003cp\u003eIdentical glasses are placed in a triangular tower structure, such that the top level (L = 1) comprises one glass, the next level down (L = 2) comprises three glasses, the next level down (L = 3) comprises six glasses, and so on.\u003c/p\u003e\u003cp\u003eFollow the \u003ca href = \"https://imgur.com/a/j9ZZa\"\u003elink\u003c/a\u003e to see a diagram shows the first three levels. The glasses in each levels are represented by the blue circles, while the yellow circles represent the positions of the glasses in the next higher level.\u003c/p\u003e\u003cp\u003eWater is poured into the top glass at a constant volumetric flow rate. When the glass is filled, the water starts spilling over and into the glasses below. Note that \u003cb\u003ewater only spills outward\u003c/b\u003e , meaning that at some point, some glasses will remain empty.\u003c/p\u003e\u003cp\u003eGiven the volume of a glass in liters, v, the volumetric flow rate in liters per second, u, and an integer, L, representing a level in the glass structure, return the total number of glasses in that level, g, the number of glasses in that level that will be filled with water, f, and the time, in seconds, it would take to fill all \"fillable\" glasses in that level, t, starting with no water in any of the levels.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003eInput: v = 0.25, u = 0.1, L = 2\u003c/p\u003e\u003cp\u003eOutput: g = 3, f = 3, t = 10\u003c/p\u003e","function_template":"function [g, f, t] = filltime(v, u, L)\r\n    [g, f, t] = [v, u, L];\r\nend","test_suite":"%%\r\n[g f t] = filltime(0.25, 0.1, 2);\r\nassert(isequal([g f t],[3 3 10]))\r\n\r\n%%\r\n[g f t] = filltime(0.45, 0.3, 6);\r\nassert(isequal([g f t],[21 15 69]))\r\n\r\n%%\r\n[g f t] = filltime(3, 0.8, 7);\r\nassert(isequal([g f t],[28 18 240]))\r\n\r\n\r\n%%\r\n[g f t] = filltime(2, 8, 47);\r\nassert(isequal([g f t],[1128 138 811]))","published":true,"deleted":false,"likes_count":8,"comments_count":1,"created_by":15521,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":259,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-09T07:06:17.000Z","updated_at":"2026-03-18T13:30:02.000Z","published_at":"2017-10-16T01:45: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\u003eIdentical glasses are placed in a triangular tower structure, such that the top level (L = 1) comprises one glass, the next level down (L = 2) comprises three glasses, the next level down (L = 3) comprises six glasses, and so on.\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\u003eFollow the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://imgur.com/a/j9ZZa\\\"\u003e\u003cw:r\u003e\u003cw:t\u003elink\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e to see a diagram shows the first three levels. The glasses in each levels are represented by the blue circles, while the yellow circles represent the positions of the glasses in the next higher level.\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\u003eWater is poured into the top glass at a constant volumetric flow rate. When the glass is filled, the water starts spilling over and into the glasses below. Note that\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\u003ewater only spills outward\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e , meaning that at some point, some glasses will remain empty.\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\u003eGiven the volume of a glass in liters, v, the volumetric flow rate in liters per second, u, and an integer, L, representing a level in the glass structure, return the total number of glasses in that level, g, the number of glasses in that level that will be filled with water, f, and the time, in seconds, it would take to fill all \\\"fillable\\\" glasses in that level, t, starting with no water in any of the levels.\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=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInput: v = 0.25, u = 0.1, L = 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\u003eOutput: g = 3, f = 3, t = 10\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":44375,"title":"Missing five","description":"Convert decimal numbers to a base-9 notation missing the digit *5*\r\n\r\n\u003c\u003chttp://www.alfnie.com/software/missing5.jpg\u003e\u003e\r\n\r\nToo many five-themed problems? Wondering whether everything would be simpler if we just got rid of the digit 5? Let's try!\r\n\r\nIn a world without 5's, positive integers may be represented using a base-9 notation that uses only the digits 0, 1, 2, 3, 4, 6, 7, 8, and 9. We'll call this the \"missing-5\" notation. The following list shows the first 100 positive numbers (i.e. 1 through 100) using \"missing-5\" notation:\r\n\r\n    '1'      '2'      '3'      '4'      '6'      '7'      '8'      '9'      '10'     '11' \r\n    '12'     '13'     '14'     '16'     '17'     '18'     '19'     '20'     '21'     '22' \r\n    '23'     '24'     '26'     '27'     '28'     '29'     '30'     '31'     '32'     '33' \r\n    '34'     '36'     '37'     '38'     '39'     '40'     '41'     '42'     '43'     '44' \r\n    '46'     '47'     '48'     '49'     '60'     '61'     '62'     '63'     '64'     '66' \r\n    '67'     '68'     '69'     '70'     '71'     '72'     '73'     '74'     '76'     '77' \r\n    '78'     '79'     '80'     '81'     '82'     '83'     '84'     '86'     '87'     '88' \r\n    '89'     '90'     '91'     '92'     '93'     '94'     '96'     '97'     '98'     '99' \r\n    '100'    '101'    '102'    '103'    '104'    '106'    '107'    '108'    '109'    '110'\r\n    '111'    '112'    '113'    '114'    '116'    '117'    '118'    '119'    '120'    '121'\r\n\r\nYou may notice that this is simply the sorted list of positive numbers which do not contain the digit 5 in their decimal representation. \r\n\r\nYour function should convert a positive decimal number N into its \"missing-5\" notation. For example\r\n\r\n dec2missing5(20)\r\n\r\nshould return _'22'_ (the 20th positive number in missing-5 notation), and\r\n\r\n dec2missing5(100)\r\n\r\nshould return _'121'_ (the 100th positive number in missing-5 notation)\r\n\r\nGood luck!\r\n\r\n_Small print_: Your function may output a number, a char array, or a string; whatever you find simpler (e.g. in the example above, valid outputs are 121, '121', or \"121\"). Input numbers in testsuite are always relatively low valued positive integers (\u003c10,000)","description_html":"\u003cp\u003eConvert decimal numbers to a base-9 notation missing the digit \u003cb\u003e5\u003c/b\u003e\u003c/p\u003e\u003cimg src = \"http://www.alfnie.com/software/missing5.jpg\"\u003e\u003cp\u003eToo many five-themed problems? Wondering whether everything would be simpler if we just got rid of the digit 5? Let's try!\u003c/p\u003e\u003cp\u003eIn a world without 5's, positive integers may be represented using a base-9 notation that uses only the digits 0, 1, 2, 3, 4, 6, 7, 8, and 9. We'll call this the \"missing-5\" notation. The following list shows the first 100 positive numbers (i.e. 1 through 100) using \"missing-5\" notation:\u003c/p\u003e\u003cpre\u003e    '1'      '2'      '3'      '4'      '6'      '7'      '8'      '9'      '10'     '11' \r\n    '12'     '13'     '14'     '16'     '17'     '18'     '19'     '20'     '21'     '22' \r\n    '23'     '24'     '26'     '27'     '28'     '29'     '30'     '31'     '32'     '33' \r\n    '34'     '36'     '37'     '38'     '39'     '40'     '41'     '42'     '43'     '44' \r\n    '46'     '47'     '48'     '49'     '60'     '61'     '62'     '63'     '64'     '66' \r\n    '67'     '68'     '69'     '70'     '71'     '72'     '73'     '74'     '76'     '77' \r\n    '78'     '79'     '80'     '81'     '82'     '83'     '84'     '86'     '87'     '88' \r\n    '89'     '90'     '91'     '92'     '93'     '94'     '96'     '97'     '98'     '99' \r\n    '100'    '101'    '102'    '103'    '104'    '106'    '107'    '108'    '109'    '110'\r\n    '111'    '112'    '113'    '114'    '116'    '117'    '118'    '119'    '120'    '121'\u003c/pre\u003e\u003cp\u003eYou may notice that this is simply the sorted list of positive numbers which do not contain the digit 5 in their decimal representation.\u003c/p\u003e\u003cp\u003eYour function should convert a positive decimal number N into its \"missing-5\" notation. For example\u003c/p\u003e\u003cpre\u003e dec2missing5(20)\u003c/pre\u003e\u003cp\u003eshould return \u003ci\u003e'22'\u003c/i\u003e (the 20th positive number in missing-5 notation), and\u003c/p\u003e\u003cpre\u003e dec2missing5(100)\u003c/pre\u003e\u003cp\u003eshould return \u003ci\u003e'121'\u003c/i\u003e (the 100th positive number in missing-5 notation)\u003c/p\u003e\u003cp\u003eGood luck!\u003c/p\u003e\u003cp\u003e\u003ci\u003eSmall print\u003c/i\u003e: Your function may output a number, a char array, or a string; whatever you find simpler (e.g. in the example above, valid outputs are 121, '121', or \"121\"). Input numbers in testsuite are always relatively low valued positive integers (\u0026lt;10,000)\u003c/p\u003e","function_template":"function y = dec2missing5(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(regexprep(char(string(dec2missing5(3))),'^0*',''),'3'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(14))),'^0*',''),'16'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(19))),'^0*',''),'21'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(80))),'^0*',''),'99'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(91))),'^0*',''),'111'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(313))),'^0*',''),'388'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(732))),'^0*',''),'1003'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(748))),'^0*',''),'1021'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(1249))),'^0*',''),'1738'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(1873))),'^0*',''),'2611'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(2790))),'^0*',''),'3840'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(3035))),'^0*',''),'4142'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(3391))),'^0*',''),'4688'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(3547))),'^0*',''),'4881'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(3724))),'^0*',''),'6098'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4057))),'^0*',''),'6608'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4221))),'^0*',''),'6810'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4389))),'^0*',''),'7017'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4444))),'^0*',''),'7088'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4489))),'^0*',''),'7138'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4530))),'^0*',''),'7193'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4533))),'^0*',''),'7197'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4569))),'^0*',''),'7237'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4585))),'^0*',''),'7264'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4651))),'^0*',''),'7338'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4680))),'^0*',''),'7380'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(5455))),'^0*',''),'8431'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(5711))),'^0*',''),'8846'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(5949))),'^0*',''),'9140'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(5999))),'^0*',''),'9206'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6075))),'^0*',''),'9300'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6526))),'^0*',''),'9961'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6601))),'^0*',''),'10044'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6634))),'^0*',''),'10091'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6728))),'^0*',''),'10206'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6787))),'^0*',''),'10281'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6902))),'^0*',''),'10419'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(7037))),'^0*',''),'10689'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(7212))),'^0*',''),'10903'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(7493))),'^0*',''),'11246'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(7962))),'^0*',''),'11927'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(7996))),'^0*',''),'11974'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8062))),'^0*',''),'12048'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8109))),'^0*',''),'12110'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8248))),'^0*',''),'12284'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8427))),'^0*',''),'12603'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8538))),'^0*',''),'12737'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8620))),'^0*',''),'12838'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8959))),'^0*',''),'13264'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(9190))),'^0*',''),'13641'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(9289))),'^0*',''),'13771'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(9436))),'^0*',''),'13944'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(9480))),'^0*',''),'14003'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(9533))),'^0*',''),'14072'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(9541))),'^0*',''),'14081'))\r\n%%\r\nfor n=1:100, assert(all(char(string(dec2missing5(randi(10000))))~='5')); end\r\n%%\r\nx='1000'; for n=1:7, x=char(string(dec2missing5(str2double(x)))); end; assert(isequal(regexprep(x,'^0*',''),'11027'));\r\n%%\r\nx='234'; for n=1:10, x=char(string(dec2missing5(str2double(x)))); end; assert(isequal(regexprep(x,'^0*',''),'4240'));\r\n%%\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[13944,14003,14072,14081]),regexp(fileread('dec2missing5.m'),'((\\s*[\\+\\-\\*\\/]\\s*)?[\\d\\.])+','match'))),'please do not use look-up table solutions');\r\n\r\n","published":true,"deleted":false,"likes_count":9,"comments_count":7,"created_by":43,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":381,"test_suite_updated_at":"2017-10-31T17:07:46.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-11T00:58:23.000Z","updated_at":"2026-03-18T12:51:12.000Z","published_at":"2017-10-16T01:45: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\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/media/image1.JPEG\"}],\"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\u003eConvert decimal numbers to a base-9 notation missing the digit\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\u003e5\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:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\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\u003eToo many five-themed problems? Wondering whether everything would be simpler if we just got rid of the digit 5? Let's try!\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\u003eIn a world without 5's, positive integers may be represented using a base-9 notation that uses only the digits 0, 1, 2, 3, 4, 6, 7, 8, and 9. We'll call this the \\\"missing-5\\\" notation. The following list shows the first 100 positive numbers (i.e. 1 through 100) using \\\"missing-5\\\" notation:\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[    '1'      '2'      '3'      '4'      '6'      '7'      '8'      '9'      '10'     '11' \\n    '12'     '13'     '14'     '16'     '17'     '18'     '19'     '20'     '21'     '22' \\n    '23'     '24'     '26'     '27'     '28'     '29'     '30'     '31'     '32'     '33' \\n    '34'     '36'     '37'     '38'     '39'     '40'     '41'     '42'     '43'     '44' \\n    '46'     '47'     '48'     '49'     '60'     '61'     '62'     '63'     '64'     '66' \\n    '67'     '68'     '69'     '70'     '71'     '72'     '73'     '74'     '76'     '77' \\n    '78'     '79'     '80'     '81'     '82'     '83'     '84'     '86'     '87'     '88' \\n    '89'     '90'     '91'     '92'     '93'     '94'     '96'     '97'     '98'     '99' \\n    '100'    '101'    '102'    '103'    '104'    '106'    '107'    '108'    '109'    '110'\\n    '111'    '112'    '113'    '114'    '116'    '117'    '118'    '119'    '120'    '121']]\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 may notice that this is simply the sorted list of positive numbers which do not contain the digit 5 in their decimal representation.\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\u003eYour function should convert a positive decimal number N into its \\\"missing-5\\\" notation. 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[ dec2missing5(20)]]\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\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\u003e'22'\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (the 20th positive number in missing-5 notation), and\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[ dec2missing5(100)]]\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\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\u003e'121'\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (the 100th positive number in missing-5 notation)\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\u003eGood luck!\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\u003eSmall print\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e: Your function may output a number, a char array, or a string; whatever you find simpler (e.g. in the example above, valid outputs are 121, '121', or \\\"121\\\"). Input numbers in testsuite are always relatively low valued positive integers (\u0026lt;10,000)\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\"},{\"partUri\":\"/media/image1.JPEG\",\"contentType\":\"image/JPEG\",\"content\":\"data:image/JPEG;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCADqASMDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD3+iiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAoopCwA5IAoAKK5fXPH2g6GXjmuxLcp/wAsIRubPoew/EivP9U+MGpTsV02yht0/vSkux/AYA/WsKmIpw3Z6eEyfGYrWnDTu9D2fcB1IH41G08SDLSIB7kV8333jHxFqP8Ax8avc4z0jbyx/wCO4rGlmlnk3zSPI/Tc7EmuZ4+P2Ue5S4Rq2vVqJfj/AJH1C2r6epwb2AH0Mg/xpyanZSn5LqFvo4NfLFFT9ff8pv8A6ow/5/fh/wAE+sBIh6Mp/GnDB6V8sWup6hZEfZb65gHYRysv8jXR6f8AEnxNYYBvVuUH8M6A/qMH9auOPg/iVjkrcJ4mKvSmpfgfQlFeX6R8YbOXbHqllJAe8kR3r+XUfrXf6XrenazbibT7uOdD3U8j6jqPxrqhWhP4WeDisuxOFf76DX5GlRRRWpxBRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAJRSH1Nee+OPiLFoofTtLZJr88O/VYfr6t7fn6GJ1IwV5HThcJVxVRU6SuzpPEfi3S/DNuHvJsytny4U+Z3/DsPc8V434i+Imta6zxRymytCeIoW5I/2m6n8MCuYuLi51G8aaeSSe5lblmO5mPpXoPhT4V3N+q3etl7aA4K26n52/3j/D9Ov0rzZVquIfLDRH2lLLsBlFNVcW+af9bI8/srC61G4W3sreSeZuixrk13Wj/CTV75RJqM8dip/gx5jY/A4/WvXtL0TTtGtxBp9pHAg67Ryfqep/GtGt6eBitZ6nmYzinEVPdw65V+JwVh8J/D9oo+0ie7YdTJIRn8FxXQ23g/w9a4MOkWgI6MYVJ/PGa3KOldUaUI7I8Crj8TWf7ybfzKS6Rp8YwlnAB7IBUc2haXcD97p9tJ/vRKf6Vo0VXKuxh7ap/MzmLz4feGbxCH0qGPPeIbD/47iuX1P4O2Eu59Ov5rds5CSDzFH8j+pr0+is5UKct0ddDNMZQd4VGfOus/D/xBoqtLJafaIB/y0t/n/MdR+VYFlf3WnXK3FlcSQTDo0bYNfVBAYYIBrlPEfgDRvEAaRovs12ek8XBz7joa5KmBtrTZ9HhOKOdezxsLp9V/kcf4Y+LLhhbeIFBHAW5jX/0JR/T8q9VtrqG9t0nt5VkicZVkOQRXzr4l8Har4ZlP2mLzbUnCXEY+U/X+6frS+FvGGoeFrnMDebaMcyW7HAb3Hofepp4qVN8lU1xuQ4fF0/rGXtenT/gH0hRWRoPiGw8RWC3VjLuHG5DwyH0IrX5r0k01dHxdSnKnJwmrNC0UUUyAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAEo6UVyXjrxYnhnRz5RBvpwVgQ9vVj7D/CplJQXMzbD0J16ipU1dsw/iN47GlxvpGly/wCnOP3sin/Uj/4o/p+VeP2dndanfR2trE89xK2FUckn1/8Ar01VudQvcKHnuZ5M4HLOxP8AMmvevA3guHwzp/mzhZNQmUebJj7o/ur7fzx9K8tKWKqXex93UnQyHCKMdakv6+4h8GfD+z8PQpd3SrcakRkyEcR57L/j1rt8YHFFFenCEYKyPhcTiauJqOpVd2xaKKKswCiiigAooooAKKKKACiikJAGTQBBd2tveWzwXMSSwuMMrrkEe9fOnjLT9J0zxDNa6ROZIU++vURv3UHvj9Old58QviEYPN0XRpv3vK3Fyh+56qp/vep7fXp5PFFJPMkMMbSSOQqooyWJ6ACvLxlWMnyRV2fdcNYCvQi8TVlyxfTv5s0/D3iG98Oaml5aOdvSSMn5XX3FfQ3h/XbPxDpUV9aOCrcMvdG7g+9eF6/4F1Tw9o9tqFyA6yDEyoM+SSeAT39PrxzTPBfiqbwxrCuWLWUxCzx57f3h7ipw9WVGXJU2N82wFDNKLxOFacl26+R9GUVDb3EV1bxzwuHjdQyspyCD3qavWPz9pp2YtFFFAgooooAKKKKACiiigAooooAKKKKACiiigAooooAguriO0tpLiZwkcalmY9AAOtfNvinX5vEeuz30hPlZ2wL/AHUHT8e59zXqHxa182WkRaTA+Jbw5kweRGOv5nA/OvLvCuhv4h8Q21gAfLJ3zEdkHX/D6kV5uMqOc1Sifa8OYWGGoTx9b5eh6J8K/CQjhGv3kf7xwRaqw+6vQt9T0Ht9a9VFRW8EdrbxwRKEjRQqqBwAKlrupU1Tgoo+Wx+MnjK8q0+v5C0UUVocYUUUUAFFfI/xQ8Yay/xJ1xLLWL63tobjyFiguXRV2KFPAPqprkP+Es8R/wDQwar/AOBsn+NAH3PRXwx/wlniP/oYNV/8DZP8aP8AhLPEf/Qwar/4Gyf40Afc9FfDH/CWeJP+hg1X/wADJP8A4qvT/gRr2r6h8QZYb7Vb65hFjI2ye4d1zuTnBNAH0sSAMk15X8RPiCbdpdF0eUrN924uFP3P9lT6+p7fXpL8QfiCLMSaRpEubn7s0yn/AFfsPf8AlXkKJLcTqkatJLI2AByWJrz8Vibe5Dc+wyLIlK2KxS91bJ/mxIopJ5UiijZ5HIVUUZJJ7CvcfAPgKPQIV1DUEV9TccDqIQew9/U/gOOrPAPgBNEjXUdSQPqDj5VPIhHoPf3r0GqwuG5ffnuY59nnt39Xw79xbvv/AMAr3tpDfWkttcRrJFIpVlYZBBr5x8WeHpfDWuzWTAmFvngc/wASE/zHSvpauM+I/hsa54eeaGMNd2gMkRA5I7r+IH8q0xVH2kLrdHFkGZPB4lRk/clo/wDM574T+J2lifQ7uTLxjfbEn+Huv4dfx9q9U618s6VqM2k6pb30BxJC4b6juK+nNOvYdR0+3vIG3RTRh1PsRmowdXnhyvdG/EuAWHxHtYfDP8y3RRRXafNhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABTScAn0paztcvhpuiXt6ekMLP+QpN2VyoRc5KK6ngnj3VjrHjC9kViYoW8iMegXg/+PZr0D4Q6MINJuNWkUb7l9kZ/wBheP8A0LP5V44S80ufmeR2+pYmvp3QdNTSNDs7BORDEq59Tjk/jXm4Re0quoz7fiCawmAp4SHX9DTooor0z4YKKKKACmSyJDE8sjBURSzE9gKfXMfETUf7J+Hev3YbawspEQ+jONin82FAHxlqV6+pareX8md9zM8zZ9WYn+tfR3w++EXhDVPAWj6hrOj/AGi/uYfOkl+0zJuDMSvCuB90r2r5qiieeaOKNSzyMFVfUnpX3dpNiul6NY6emNtrbxwLj0VQv9KAOM/4Ul8PP+he/wDJ24/+OUf8KS+Hn/Qvf+Ttx/8AHK9ApCcDJoA8/PwU+HgHPh//AMnbj/45XDeIIvCfgnUJoPB2ni21No2hnuluZZPLQ4JUbmIzwOe1dT8QfiCLMSaRpEn+kn5ZplP+r9h7/wAq8hRJbiZUjVpJZGwAOSxNefisVb3Ibn1+RZFz2xWKVorZf5+QIktxMsaK0ksjYAHJYmvbfAPgFNEjTUtRRX1Bx8q9RCPQe/vR4A8Apoka6jqSK+oOPlU8iEe3v716DTwuF5ffnuRnue+3vh8O7QW77/8AAFooorvPkwprqHQqehGKdRQB81eMdHGh+KL2zVdsO/zIhjA2NzgfQ5H4V6d8I9YN5oM+nSMC1nJ8o/2G5H65rK+MumhTp2pKACS0LnHJ7r/JvzrB+FWoG08XraliEu4mTGeMj5gf0b868uH7rE26M+8xD/tDJFUfxR/Tf8D3qiiivUPgwooooAKKKKACiiigAooooAKKKKACiiigBK434oXX2fwRdoDhpWRB/wB9DP6A12Vec/GKQp4atEBxvulBHqNrH+grKu7U5HflcFPG00+6PKvC9p9u8UaZb9muEJHqAcn9BX00owoHtXzz8N4/M8eab6JvY/8AfDD+tfQ9cuAX7tvzPb4tnfFxh2QtFFFd58qFFFFABXlX7QGo/Y/hqbUNg3t5FER6hcyfzQV6rXz9+0rqOZNA0xW6CW4df++VX+T0AeVfDnTf7V+I2gWm3cpvI5GHqqHe36Ka+tvEHjXw34VX/ic6vb20mMiEtukI/wBxct+OK+NvD+vXvhnVP7S01lS8WN44pWGTHuUqWHvgnFFlpeueJ7+VrOzvtTunO+V0RpWJPdm/qaAPo+f9obwbFLsit9XuB/eit0A/8ecGqfiD4vQ6xo4j0GC7tmmyGluFVWVf9kAnr614nZ+FLnT7101WERSxHmHcGIPvg8fSt4lUUkkAAdT0Arz8Vire5Dc+wyLIlO2JxS91bIkVZJpQqq0kjtgADJYn+Zr27wD4BTRYk1LUUV9QcfKp5EI9B7+9fOJ8ZXuk6zb3mjyLHJbPuV2QMGPQ5B7YJr6Z+G/xDsvHujGQKtvqduALq2ByB6Ov+yf06e5eFw3L789yM+zz218Nh37q3ff/AIB29FFFd58kFFFFABRRRQBxfxQtPtPgi7cAFoWRx/30Af0JrxfwtdNZ+KtLnUkYuUBI9Cdp/Q17542QSeDdWB7Wzn8lJr5zs5PKvreQcFJVbp6GvLxnu1YyPueG37XAVqL8/wAUfVanKg+1LTIjmJPoKfXqHw73CiiigQUUUUAFFFFABRRRQAUUUUAFFFFABXmvxkH/ABTlkfS7X/0B69Jrhfixbed4MeX/AJ4zI/67f/Zqxrr92z0cply42k/NHmvwzfb48sAf4g4/8cJ/pX0JXzZ4JuRa+M9KlP8Az22cf7QK/wBa+kgcgGufAP8AdteZ7HFkbYyMu8f1Y6iiiu4+WCiiigAr58+M3gXxh4q8bC90zRpLmwgtY4I5Fmj55Zj8pbPViOnavoOgnAoA+X/AnwO1fVNVMvim2m07TYCC0ZI8yc/3RjoPU/l6j0bxd4t0/wAL6f8A8I14VhhtTGNsjQKAsPqB6v6n+tW/iD8QhYiTSNIkzdn5Zp1P+q9h/tfy+tePKsk0oRVaSR2wABksT/M15+KxVvchufXZFkXtLYrFK0Vsu/m/IFWSaUKoaSR2wABksT/M17B4U+Flj/ZEjeIrVbia6jKmAniJT6EH73uOnb3t+APACaNGmp6nGG1Bh8iHkQA/+zep/Ae/olPC4Xl9+e5Oe577ZvD4Z2it33/4B8ffFD4eTeAdcRYnefS7sFrWZ/vDHVG/2hxz3B+oGN4G8UzeDvF1jq8TN5KPsuUX/lpCfvL/AFHuBX098Y9Fi1n4ZaruUGWzQXcTf3SnX/x3cPxr49rvPkz77ikSaJJY2DRuoZWHQg9DUlcd8LNRbU/hhoFw5yy23k5/65sY/wD2WuxoAKKKKACiiigDB8ZMF8HauT/z6SD81NfN9shkuYUXG5nUD86+gviNci28Dai3d1WMD/eYL/WvCNDgNzr+nQhS2+5jBAGeNwzXmY3WpGJ9zwwuTBVqr/qyPqCL/VJ9BT6anCKPanV6aPh3uFFFFAgooooAKKKKACiiigAooooAKKKKAErC8Y2Laj4S1K2QFnaFioA6kcj9QK3abIoaNlPcYqZK6aNKNR06kZrdO58qW072t1DcR43xOHX6g5FfUtjcx3ljBcRNujkRWUjuCOK+aPEOnNpPiC/sWUKIpmCgf3Tyv6EV7P8AC7VxqPhOO2ZgZbMmJh7dV/Tj8K87BS5Jygz7Tiekq+GpYqG3+Z3NFFFemfDhRRQTgUAMd1RSzEBQOSa8v8dfEm3jtvsHh+7jnklX57uFwyop/ukcE+/b69JPiF8QVsVl0fSZAbogrPOp/wBUPQf7X8vr08aJCKSSAAO/QCvPxWKt7kNz6/IsiVRLFYpWitl3/wCASKsk0oVQ0kjtgADJYn+Zr2vwB4ATRo01TU0Daiw+ROogB/8AZvU/gPfjfgrd6FquvX6SANqdsoe33nhk6Myj1Bxn2I9692p4XDcvvz3Iz7PHWbw2Hdord9/+AL0ooorvPkzmviDMkHw58SO5wDps6fiyFR+pr4lr6g/aA8URaZ4OTQo3H2vU3G5QeViRgxP4sFHv83pXzFHG8sqRRqWkchVUDJJPagD67+CSMnwk0Xd/EZ2A9vOevQaxPCOjHw94R0nSWA8y1tUSTHTfj5v/AB7NbdABRRRQAUUUHgUAeZ/GLUDDo1nYq2DcTbmHqqj/ABK/lXC/Day+2eOLLIykIaVsj0GB+pFTfE7Vxqfi+WFH3Q2iiFcHI3dWP1ycf8Brp/g5pPyX2qyL94iGM49OW/mPyry3+9xXofdwX1HInfef6/8AAPWR0ooor1D4QKKKKACiiigAooooAKKKKACiiigAooooAKKKKAPHfjBohjurXWIk+WQeTMR69VP5ZH4CsL4aa+NG8TJbyvttb3Ebegf+E/nkfjXtXiDSIdd0S60+f7sqYBx90jkH8Dg1803lnPp19NaXKGOeFyrD0Iry8SnSqqqj7rJKsMwwE8DU3W3p0+4+qgQRmiuQ+H/ikeItDVZm/wBNtsRzZ43ccN+P8811+RjJr0oSU48yPi8RQnh6rpTWqAkAZNeY/EL4gixEmkaRJm7PyzTqf9V7D/a/l9aPiD8QRYiTSNIk/wBLPyzTqf8AVew/2v5fWvHlWSaUKqtJI7YAAyWJ/ma4cVire5Dc+oyLIlUtisUrRWy7+b8gVZJpQqhpJHbAAGSxP8zV3x/4D8QaD4TtdWcbrd2xdxRjJgz90se49T0Bx1zXr3gDwAmjRpqepxhtQYfIh5EAP/s3qfwHv388EVzA8E8SSQyKUeN1yrKRggjuKeFwvL789xZ5nzrN4fDO0Fu+/wDwD4U0rVb3RdTg1LTrh7e7t33xyL2P9R6jvX0X4S/aB0TULWKDxLHJpt6Bhp40LwufXjLL9MEe9Zfjb9nxbieS+8JXCQ7iWawuGIUf7j9vo35143q3gbxTocjLqGgX8QXq4hLp/wB9rlf1rvPkj6yX4m+CHi8weJ9N2+hmwfyPNcf4p+PvhrSrd49DD6te9FIVo4VPqWIyfwHPqK+YhaXBfYIJS2cY2HNbmk+BPFWtyrHp/h+/kDcCRoSiD6u2FH50AUvEHiDUvFGtT6rqtwZrqY8noqr2VR2Ar1H4G/DqbVtXh8U6lCV06zfdaq6/6+UdGH+yp5z/AHsehre8E/s+LBLFfeLp0k2kMLC3bKn/AH37/Rfzr3W3t4bS3jt7eJIoI1CRxou1VUcAADoKAJqKKKACiiigBKxPFeuR6B4eur5iN6piNT/E54A/Pr7ZraJABPpXhHxM8UDW9YFhbOWs7NiMg8O/c/h0/P1rDEVVThfqeplGXyxuJUOi1focVma7uSfmkmlf6lmJ/wAa+k/CujLoPhyz08HLRpl29WPJP5k15L8LfDn9qa4dTnXNtYkFQRw0h6fl1+uK90HAxXPgadk6j6nscUY5TqRwsNo7+otFFFd58mFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFACV5d8U/CRuYf7dso8zRDFwij7yf3vqP5fSvUeaZJGsqFHGVIwQazq01Ui4s68DjJ4SvGtDofMvh3Xbrw7rEV/bc7flkjzw6nqP8+lejeLvifDJpMdtocjfaLiMGSXGDCD2/3v5VzvxB8Ev4fvDf2UZOmzN0X/AJYse30PY/h6Z4avIdSrQvTP0OGEwOauGM3a3X+foPVXmkCqGkkdsADksTXtXw/8AJo8aapqkYbUHGUQ8iAf1b1Pbp65pfC7wpp4s01yWWK5um4jVTkQe3+9/L+fqQrrwuGt+8lufP8AEGdubeEoaRWj8/L0F7cUUUV6B8iFFFFABRRRQAUUUUAFFFFACUUdB1rg/HPj+DQInsbBkm1FhgjORDx1Pv6ConNQXNI6MNhauJqKlSV2yt8SfGo0m0bSdPl/06ZcO6n/AFK/4nt+dePaXplzrGpQWFom6aVto9AO5PsBzURNzqF7n95cXM7+7M7E/qTXu3gDwWnhuwNzdKrajOP3hznYOyj+vv8AQV5iUsVUu/hR9xOVHIcHyR1qS/r7kdB4e0W30DRrfT7cfLGvzMRy7dyfxrVoor1UklZHwM5yqSc5O7YtFFFMkKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigCvd2kN7bSW1xEskUilWRhkEV4b42+H1z4elkvbBXn00/Me7Q+x9R7/n6n3mmSRpKhR1DKRgg1jWoRqxsz0stzOtgKnNB6dV3PmbQfEWo+HL0XNhNtz9+NuUkHoRXtvhfx/pXiNFiZha3p48iRhlv90965vxb8K4pvMvdBxFJyWtSfkb/dP8P06fSvKLuzutPuWt7uCS3nTqjqQfTP/wBevPUquGdnqj66dHL88hz03y1Px+fc+qc56UtfP+gfEnXNGKxzyfbrYY+SY/MB7N1/PNelaP8AE/w/qaYuJzYy5xtuPlB+jdMV208VTn1PmMbkWMwru48y7rU7alqtb3ttdxLLbzxyIejI4IP41YyD3roTPHaadmLRRRTEJRSFgOpH4msrU/Euj6OM32oQQnGQpYbjj0HU0m0tWXCnObtFXZrVBdXlvZQPPczJFEgyzu2AB715rrfxgtYkeLRrVp5OgmmG1B746n9K8y1nxFqniCfzdRu3lAOVjHCL9FHFclXGQhpHVnv4DhvFYh81VckfPf7j0Dxd8VTKJLLQMqudrXbDqP8AZB/mfy715nDBdalerFCklxdTvwBlmcnkn/69bHh3wdq3iWUfZIdlsDhriQYQfT1PsPxxXt3hjwZpnhi3HkR+ZdMMSXDj5m+noPYfrXNGnVxL5p6I9ytjcDktN0sOuaf9bv8AQxvA3w/h0CNb+/VZdSYcd1hHoPU+p/L372iivShCMFyxPicTiquKqOrVd2xaKKKs5wooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooASsvWPD+l67b+TqFnHMB0JGGX6Ecj8K1KKTSasyoTlCXNB2Z47rnwguYWMujXQmX/njPwR9GHB/IVwOpaDqujsVv7CeDH8TLlf++hx+tfUFNeNXGGUH6iuOpgqctVofR4TifF0Vy1Eprz3PlSC6uLV99vPLC3rG5U/pW3beOPE1pxFrFx/wPD/APoQNe53/gvw9qRZrnSrdnY5Louxj+Iwawrj4TeHJv8AVJcQf7kxP881j9UrR+GR6i4iy6uv39HX0TPN1+JniteuoqfrCn+FMl+I/iuUn/ialR6LCn/xNd8fg3pHbUL7/vpP/iafH8HdFQ5e8vn9i6D+S0ewxP8AMH9qZGtVS/8AJUeUXXiXXL0n7Rq14wPUCUgfkOKzVV5pNqhnkc9ByWNe/Wvwx8L2xDNYtKw/56SsR+WcV0NjommaauLKwt4Bjny4wufyoWCqS+OQpcTYSirYal+SPBtJ+HviLV9rLZG2iP8Ay0uTs/Tr+lekeH/hVpOnbJtSJv7gc7XGIwf93v8AjXoGABwKWumnhKcNdzw8bxBjMUuW/KuyI44khQJGgVVGAAMYFS0UV1Hht33CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//2Q==\"}]}"},{"id":44372,"title":"Polarisation","description":"You have n polarising filters stacked one on top of another, and you know each axis angle. How much light gets passed through the filter bank? For more information, see \u003chttps://en.wikipedia.org/wiki/Polarizer Polarizer (Wikipedia)\u003e.\r\n\r\n    \u003e\u003e n = [0, 90];\r\n    \u003e\u003e polarised([0, 90])\r\n\r\n    ans = 0","description_html":"\u003cp\u003eYou have n polarising filters stacked one on top of another, and you know each axis angle. How much light gets passed through the filter bank? For more information, see \u003ca href = \"https://en.wikipedia.org/wiki/Polarizer\"\u003ePolarizer (Wikipedia)\u003c/a\u003e.\u003c/p\u003e\u003cpre\u003e    \u0026gt;\u0026gt; n = [0, 90];\r\n    \u0026gt;\u0026gt; polarised([0, 90])\u003c/pre\u003e\u003cpre\u003e    ans = 0\u003c/pre\u003e","function_template":"function y = polarised(x)\r\n  y = max(x);\r\nend","test_suite":"%%\r\nx = 5;\r\ny_correct = 0.5;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = 180;\r\ny_correct = 0.5;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = 365;\r\ny_correct = 0.5;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = [91, 1];\r\ny_correct = 0;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\na = randi([-360, 360]);\r\nb = 90*(1+2*randi([-3, 3]));\r\nx = [a, a+b];\r\ny_correct = 0;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\na = randi([-360, 360]);\r\nb = 90*(1+2*randi([-3, 3]));\r\nx = [a, a+b];\r\ny_correct = 0;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = [0, 22.5];\r\ny_correct = 0.85355339059/2;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = [0, -45];\r\ny_correct = 0.25;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = [5, 140];\r\ny_correct = 0.25;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = 5 + (1:5)*22.5;\r\ny_correct = 0.53079004294/2;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":10,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":269,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-10T21:58:52.000Z","updated_at":"2026-03-26T15:36:11.000Z","published_at":"2017-10-16T01:45: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\u003eYou have n polarising filters stacked one on top of another, and you know each axis angle. How much light gets passed through the filter bank? For more information, see\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/Polarizer\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePolarizer (Wikipedia)\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\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 n = [0, 90];\\n    \u003e\u003e polarised([0, 90])\\n\\n    ans = 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":44352,"title":"The Top 5 Primes","description":"This problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate \u003chttps://www.mathworks.com/matlabcentral/cody/contests/1?s_tid=Cody5YA_cody_home Cody's 5th birthday\u003e. \r\n\r\nIn this problem, let's find the top 5 greatest prime numbers along the first non-singleton dimension of an input array. \r\n\r\nExample \r\n\r\n* If the input is a vector, the output is a length-5 vector containing the top 5 prime numbers of the input sorted in descending order. Append NaNs as needed in the output if the number of primes is less than 5. \r\n\r\n  x = 1:10;\r\n  y = [7 5 3 2 NaN];\r\n\r\n* If the input is a m-by-n (m \u003e= 5) matrix, the output is a 5-by-n matrix containing the column-wise top 5 prime numbers of the input matrix sorted in descending order. Whenever there are less than 5 primes found in a specific column of the input, simply append NaNs as needed in the same column of the output. \r\n\r\n  % Input x is a matrix\r\n  x = [17     6     3\r\n       13     8    17\r\n        1     2     5\r\n        5     3     7\r\n        7    11     2\r\n       31     7     6];\r\n\r\n  % Output y\r\n  y = [31    11    17\r\n       17     7     7\r\n       13     3     5\r\n        7     2     3\r\n        5   NaN     2];\r\n\r\nPrevious problem in this series: \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44342-spot-the-first-occurrence-of-5 Spot the First Occurrence of 5\u003e","description_html":"\u003cp\u003eThis problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/contests/1?s_tid=Cody5YA_cody_home\"\u003eCody's 5th birthday\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eIn this problem, let's find the top 5 greatest prime numbers along the first non-singleton dimension of an input array.\u003c/p\u003e\u003cp\u003eExample\u003c/p\u003e\u003cul\u003e\u003cli\u003eIf the input is a vector, the output is a length-5 vector containing the top 5 prime numbers of the input sorted in descending order. Append NaNs as needed in the output if the number of primes is less than 5.\u003c/li\u003e\u003c/ul\u003e\u003cpre class=\"language-matlab\"\u003ex = 1:10;\r\ny = [7 5 3 2 NaN];\r\n\u003c/pre\u003e\u003cul\u003e\u003cli\u003eIf the input is a m-by-n (m \u0026gt;= 5) matrix, the output is a 5-by-n matrix containing the column-wise top 5 prime numbers of the input matrix sorted in descending order. Whenever there are less than 5 primes found in a specific column of the input, simply append NaNs as needed in the same column of the output.\u003c/li\u003e\u003c/ul\u003e\u003cpre class=\"language-matlab\"\u003e% Input x is a matrix\r\nx = [17     6     3\r\n     13     8    17\r\n      1     2     5\r\n      5     3     7\r\n      7    11     2\r\n     31     7     6];\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003e% Output y\r\ny = [31    11    17\r\n     17     7     7\r\n     13     3     5\r\n      7     2     3\r\n      5   NaN     2];\r\n\u003c/pre\u003e\u003cp\u003ePrevious problem in this series: \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44342-spot-the-first-occurrence-of-5\"\u003eSpot the First Occurrence of 5\u003c/a\u003e\u003c/p\u003e","function_template":"function y = top5primes(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','top5primes.m')\r\n\r\n%%\r\nx = 1:10;\r\ny_correct = [7 5 3 2 NaN];\r\nassert(isequaln(top5primes(x),y_correct))\r\n\r\n%%\r\nx = (1:2:100).';\r\ny_correct = [97 89 83 79 73].';\r\nassert(isequaln(top5primes(x),y_correct))\r\n\r\n%%\r\nx = [17     6     3\r\n     13     8    17\r\n      1     2     5\r\n      5     3     7\r\n      7    11     2\r\n     31     7     6];\r\ny_correct = [31    11    17\r\n             17     7     7\r\n             13     3     5\r\n              7     2     3\r\n              5   NaN     2];\r\nassert(isequaln(top5primes(x),y_correct))\r\n\r\n%%\r\nx = interp1(magic(30).',1:5).';\r\ny_correct = [877   733   863   719   881\r\n             829   701   751   173   769\r\n             797   139    59   157    29\r\n              89   107    43   109    13\r\n              73   NaN    11    61   NaN];\r\nassert(isequaln(top5primes(x),y_correct))\r\n\r\n%%\r\nrng(0);\r\nx = reshape(randperm(200,180),36,5);\r\ny_correct = [163   181   173   197   193\r\n              71   179   149   191   157\r\n              23   167   113   139   151\r\n              19   131   101    83   137\r\n             NaN   109    67    73   127];\r\nassert(isequaln(top5primes(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":7,"comments_count":1,"created_by":12569,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":340,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-01T01:52:48.000Z","updated_at":"2026-03-18T12:39:29.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\u003eThis problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate\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/contests/1?s_tid=Cody5YA_cody_home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody's 5th birthday\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\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn this problem, let's find the top 5 greatest prime numbers along the first non-singleton dimension of an input array.\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=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the input is a vector, the output is a length-5 vector containing the top 5 prime numbers of the input sorted in descending order. Append NaNs as needed in the output if the number of primes is less than 5.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[x = 1:10;\\ny = [7 5 3 2 NaN];]]\u003e\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the input is a m-by-n (m \u0026gt;= 5) matrix, the output is a 5-by-n matrix containing the column-wise top 5 prime numbers of the input matrix sorted in descending order. Whenever there are less than 5 primes found in a specific column of the input, simply append NaNs as needed in the same column of the output.\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 x is a matrix\\nx = [17     6     3\\n     13     8    17\\n      1     2     5\\n      5     3     7\\n      7    11     2\\n     31     7     6];\\n\\n% Output y\\ny = [31    11    17\\n     17     7     7\\n     13     3     5\\n      7     2     3\\n      5   NaN     2];]]\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 problem in this series:\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/44342-spot-the-first-occurrence-of-5\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSpot the First Occurrence of 5\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":44350,"title":"Breaking Out of the Matrix","description":"Do you want to take the Red Pill, or the Blue Pill?\r\n\r\nIf you take the Blue Pill, you will simply pass along to the next problem, not knowing what Cody has in store for you.\r\n\r\nIf you take the Red Pill, you will be asked to write a MATLAB function that will Break a Matrix. The inputs to the function will be a matrix M, along with a number of rows (R) and columns (C). You goal is to break the larger 2-D matrix up into a 3-D matrix comprised of enough RxC matrices so that you can recreate the 2-D matrix. When creating your 3-D matrix, go down the columns first, and then across the rows.  Increment only one column (or one row) at a time.  Do not go C columns down at each step.\r\n\r\nFor example, R=2 and C=3, and M is as follows:\r\n\r\n M=[1 4 7 10\r\n    2 5 8 11\r\n    3 6 9 12]\r\n\r\nThis means that your output should be a 2x3x4 matrix:\r\n\r\n X(:,:,1) =\r\n     1     4     7\r\n     2     5     8\r\n X(:,:,2) =\r\n     2     5     8\r\n     3     6     9\r\n X(:,:,3) =\r\n     4     7    10\r\n     5     8    11\r\n X(:,:,4) =\r\n     5     8    11\r\n     6     9    12\r\n\r\nYou can assume that R and C will always be less than or equal to the appropriate dimension of the original matrix. Good luck!\r\n","description_html":"\u003cp\u003eDo you want to take the Red Pill, or the Blue Pill?\u003c/p\u003e\u003cp\u003eIf you take the Blue Pill, you will simply pass along to the next problem, not knowing what Cody has in store for you.\u003c/p\u003e\u003cp\u003eIf you take the Red Pill, you will be asked to write a MATLAB function that will Break a Matrix. The inputs to the function will be a matrix M, along with a number of rows (R) and columns (C). You goal is to break the larger 2-D matrix up into a 3-D matrix comprised of enough RxC matrices so that you can recreate the 2-D matrix. When creating your 3-D matrix, go down the columns first, and then across the rows.  Increment only one column (or one row) at a time.  Do not go C columns down at each step.\u003c/p\u003e\u003cp\u003eFor example, R=2 and C=3, and M is as follows:\u003c/p\u003e\u003cpre\u003e M=[1 4 7 10\r\n    2 5 8 11\r\n    3 6 9 12]\u003c/pre\u003e\u003cp\u003eThis means that your output should be a 2x3x4 matrix:\u003c/p\u003e\u003cpre\u003e X(:,:,1) =\r\n     1     4     7\r\n     2     5     8\r\n X(:,:,2) =\r\n     2     5     8\r\n     3     6     9\r\n X(:,:,3) =\r\n     4     7    10\r\n     5     8    11\r\n X(:,:,4) =\r\n     5     8    11\r\n     6     9    12\u003c/pre\u003e\u003cp\u003eYou can assume that R and C will always be less than or equal to the appropriate dimension of the original matrix. Good luck!\u003c/p\u003e","function_template":"function y = BreakTheMatrix(M,R,C)\r\n  y = x;\r\nend","test_suite":"%%\r\nM=[1 4 7 10;\r\n2 5 8 11;\r\n3 6 9 12];\r\nR=2;C=3;\r\nX(:,:,1) =[1 4 7 ; 2 5 8];\r\nX(:,:,2) =[2 5 8 ; 3 6 9];\r\nX(:,:,3) =[4 7 10 ; 5 8 11];\r\nX(:,:,4) =[5 8 11 ; 6 9 12];\r\nassert(isequal(BreakTheMatrix(M,R,C),X))\r\n%%\r\nx=1:ceil(35+25*rand());r=1;c=1;\r\nM=BreakTheMatrix(x,r,c);\r\nassert(all(arrayfun(@(y) (M(:,:,y)==y),1:numel(x))))\r\n%%\r\nx=eye(7);r=2;c=2;\r\nM=BreakTheMatrix(x,r,c);\r\nids=[1 8 15 22 29 36];\r\nurs=ids(1:5)+1;\r\nlls=urs+5;\r\nz=setxor(1:size(M,3),[ids urs lls]);\r\na1=arrayfun(@(a) isequal(M(:,:,a),eye(2)),ids);\r\na2=arrayfun(@(a) isequal(M(:,:,a),[0 1 ; 0 0]),urs);\r\na3=arrayfun(@(a) isequal(M(:,:,a),[0 0 ; 1 0]),lls);\r\na4=arrayfun(@(a) isequal(M(:,:,a),zeros(2)),z);\r\nassert(all([a1 a2 a3 a4]))\r\n%%\r\nu=ceil(10*rand())+4;\r\nx=magic(u);r=u;c=u;\r\nM=BreakTheMatrix(x,r,c);\r\nassert(isequal(M,x))\r\n%%\r\ntemp=ceil(8*rand)+3;\r\nx=ones(temp);r=2;c=2;\r\nM=BreakTheMatrix(x,r,c);\r\nassert(size(M,3)==(temp-1)^2);\r\nassert(all(arrayfun(@(a) isequal(M(:,:,a),ones(2)),1:size(M,3))))\r\n%%\r\nx=eye(7);r=7;c=7;\r\nassert(isequal(x,BreakTheMatrix(x,r,c)))","published":true,"deleted":false,"likes_count":9,"comments_count":14,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":379,"test_suite_updated_at":"2017-10-31T19:02:59.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-28T14:36:19.000Z","updated_at":"2026-03-31T15:14:35.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\u003eDo you want to take the Red Pill, or the Blue Pill?\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 you take the Blue Pill, you will simply pass along to the next problem, not knowing what Cody has in store for you.\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 you take the Red Pill, you will be asked to write a MATLAB function that will Break a Matrix. The inputs to the function will be a matrix M, along with a number of rows (R) and columns (C). You goal is to break the larger 2-D matrix up into a 3-D matrix comprised of enough RxC matrices so that you can recreate the 2-D matrix. When creating your 3-D matrix, go down the columns first, and then across the rows. Increment only one column (or one row) at a time. Do not go C columns down at each step.\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, R=2 and C=3, and M is as follows:\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[ M=[1 4 7 10\\n    2 5 8 11\\n    3 6 9 12]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis means that your output should be a 2x3x4 matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ X(:,:,1) =\\n     1     4     7\\n     2     5     8\\n X(:,:,2) =\\n     2     5     8\\n     3     6     9\\n X(:,:,3) =\\n     4     7    10\\n     5     8    11\\n X(:,:,4) =\\n     5     8    11\\n     6     9    12]]\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 can assume that R and C will always be less than or equal to the appropriate dimension of the original matrix. 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":44306,"title":"Is it really a 5?","description":"A number containing at least one five will be passed to your function, which must return true or false depending upon whether the English spelling of the number may contain \"five\" anywhere. For example:\r\n\r\n n = 5; return true since it is spelled \"five\"\r\n n = 15; return false since it is spelled \"fifteen\" and does not contain the four-letter string \"five\"\r\n\r\nThis criterion applies to any common spelling of the number. For example, 1500 can be written fifteen hundred. But, it can also be written one thousand five hundred. So, 1500 would be considered to contain a \"five\" for this problem.\r\n\r\nSee the test suite for more examples.","description_html":"\u003cp\u003eA number containing at least one five will be passed to your function, which must return true or false depending upon whether the English spelling of the number may contain \"five\" anywhere. For example:\u003c/p\u003e\u003cpre\u003e n = 5; return true since it is spelled \"five\"\r\n n = 15; return false since it is spelled \"fifteen\" and does not contain the four-letter string \"five\"\u003c/pre\u003e\u003cp\u003eThis criterion applies to any common spelling of the number. For example, 1500 can be written fifteen hundred. But, it can also be written one thousand five hundred. So, 1500 would be considered to contain a \"five\" for this problem.\u003c/p\u003e\u003cp\u003eSee the test suite for more examples.\u003c/p\u003e","function_template":"function tf = is_it_really_a_5(n)\r\n tf = 0;\r\nend","test_suite":"%%\r\nn = 5;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 15;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 25;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 35;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 52;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 55;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 59;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 85;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 105;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 115;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 125;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 250;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 500;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 555;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 5000; %5,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 15000; %15,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 55555; %55,555\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50000; %50,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 55000; %55,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50500; %50,500\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50050; %50,050\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 50005; %50,005\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 500000; %500,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 5000000; %5,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 15000000; %15,000,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 50000000; %50,000,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 105000000; %105,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50050050; %50,050,050\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 50000005; %50,000,005\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50000015; %50,000,015\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 500000000; %500,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 5000000000; %5,000,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50000000000; %50,000,000,000\r\nassert(isequal(is_it_really_a_5(n),0))","published":true,"deleted":false,"likes_count":7,"comments_count":1,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":316,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-08T22:07:48.000Z","updated_at":"2026-03-18T13:28:44.000Z","published_at":"2017-10-16T01:45: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\u003eA number containing at least one five will be passed to your function, which must return true or false depending upon whether the English spelling of the number may contain \\\"five\\\" anywhere. 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[ n = 5; return true since it is spelled \\\"five\\\"\\n n = 15; return false since it is spelled \\\"fifteen\\\" and does not contain the four-letter string \\\"five\\\"]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis criterion applies to any common spelling of the number. For example, 1500 can be written fifteen hundred. But, it can also be written one thousand five hundred. So, 1500 would be considered to contain a \\\"five\\\" for this 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:r\u003e\u003cw:t\u003eSee the test suite for more examples.\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":44309,"title":"Pi Digit Probability","description":"Assume that the next digit of pi constant is determined by the historical digit distribution. What is the probability of next digit (N) being (n). \r\n\r\nFor example if we consider the first 100 digits of pi, we will see that the digit '3' is occured 12 times. So the probability of the being '3' the 101th digit will be 12/100 = 0.12.\r\n\r\nRound the results to four decimals.","description_html":"\u003cp\u003eAssume that the next digit of pi constant is determined by the historical digit distribution. What is the probability of next digit (N) being (n).\u003c/p\u003e\u003cp\u003eFor example if we consider the first 100 digits of pi, we will see that the digit '3' is occured 12 times. So the probability of the being '3' the 101th digit will be 12/100 = 0.12.\u003c/p\u003e\u003cp\u003eRound the results to four decimals.\u003c/p\u003e","function_template":"function y = pidigit(N,n)\r\n  y = x;\r\nend","test_suite":"%%\r\nN = 101;\r\nn = 3;\r\ny_correct = 0.1200;\r\nassert(abs(pidigit(N,n)-y_correct)\u003c0.0001)\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\\d\\.\\+\\-\\*\\/]+','match')))) % modified from the comment of Alfonso on https://www.mathworks.com/matlabcentral/cody/problems/44343\r\n\r\n%%\r\nN = 201;\r\nn = 6;\r\ny_correct = 0.0750;\r\nassert(abs(pidigit(N,n)-y_correct)\u003c0.0001)\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\\d\\.\\+\\-\\*\\/]+','match'))))\r\n\r\n%%\r\nN = 202;\r\nn = 6;\r\ny_correct = 0.0796;\r\nassert(abs(pidigit(N,n)-y_correct)\u003c0.0001)\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\\d\\.\\+\\-\\*\\/]+','match'))))\r\n\r\n%%\r\nN = 203;\r\nn = 6;\r\ny_correct = 0.0792;\r\nassert(abs(pidigit(N,n)-y_correct)\u003c0.0001)\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\\d\\.\\+\\-\\*\\/]+','match'))))\r\n\r\n%%\r\nN = 1001;\r\nn = 9;\r\ny_correct = 0.1050;\r\nassert(abs(pidigit(N,n)-y_correct)\u003c0.0001)\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\\d\\.\\+\\-\\*\\/]+','match'))))\r\n","published":true,"deleted":false,"likes_count":18,"comments_count":27,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":852,"test_suite_updated_at":"2017-10-21T07:59:48.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-11T06:41:07.000Z","updated_at":"2026-04-04T18:34:50.000Z","published_at":"2017-10-16T01:45: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\u003eAssume that the next digit of pi constant is determined by the historical digit distribution. What is the probability of next digit (N) being (n).\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 if we consider the first 100 digits of pi, we will see that the digit '3' is occured 12 times. So the probability of the being '3' the 101th digit will be 12/100 = 0.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\u003eRound the results to four decimals.\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":44380,"title":"ASCII Birthday Cake","description":"Given an age and a name, give draw an ASCII birthday cake. For example, given the name \"CODY\" and the age 5, return a string with the following (no trailing spaces)\r\n\r\n   6 6 6 6 6\r\n   | | | | |\r\n __|_|_|_|_|__\r\n{             }\r\n{             }\r\n{    CODY     }\r\n{             }\r\n{_____________}\r\n\r\nThis uses the \u003chttps://www.mathworks.com/help/matlab/ref/string.html string datatype\u003e, not a char array.","description_html":"\u003cp\u003eGiven an age and a name, give draw an ASCII birthday cake. For example, given the name \"CODY\" and the age 5, return a string with the following (no trailing spaces)\u003c/p\u003e\u003cpre\u003e   6 6 6 6 6\r\n   | | | | |\r\n __|_|_|_|_|__\r\n{             }\r\n{             }\r\n{    CODY     }\r\n{             }\r\n{_____________}\u003c/pre\u003e\u003cp\u003eThis uses the \u003ca href = \"https://www.mathworks.com/help/matlab/ref/string.html\"\u003estring datatype\u003c/a\u003e, not a char array.\u003c/p\u003e","function_template":"function s = birthday_cake(name, n)\r\n    s = \"\";\r\n    s = s + \"name\";\r\nend","test_suite":"%%\r\ncake = string(char([32 32 32 54 32 54 32 54 32 54 32 54 10 32 32 32 124 32 124 32 124 32 124 32 124 10 32 95 95 124 95 124 95 124 95 124 95 124 95 95 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 67 79 68 89 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 95 95 95 95 95 95 95 95 95 95 95 95 95 125 10]));\r\nfprintf('%s\\n', cake);\r\nassert(isequal(birthday_cake(\"CODY\", 5), cake));\r\n\r\n%%\r\ncake = string(char([32 32 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 10 32 32 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 10 32 95 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 95 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 64 98 109 116 114 97 110 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 125 10]));\r\nfprintf('%s\\n', cake);\r\nassert(isequal(birthday_cake(\"@bmtran\", 29), cake));\r\n\r\n%%\r\ncake = string(char([32 32 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 10 32 32 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 10 32 95 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 95 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 77 65 84 76 65 66 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 125 10]));\r\nfprintf('%s\\n', cake);\r\nassert(isequal(birthday_cake(\"MATLAB\", 33), cake));\r\n\r\n%%\r\ncake = string(char([32 32 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 10 32 32 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 10 32 95 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 95 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 67 108 101 118 101 32 77 111 108 101 114 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 125 10]));\r\nfprintf('%s\\n', cake);\r\nassert(isequal(birthday_cake(\"Cleve Moler\", 78), cake));\r\n\r\n%%\r\ncake = string(char([32 32 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 10 32 32 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 10 32 95 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 95 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 65 108 97 110 32 84 117 114 105 110 103 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 125 10]));\r\nfprintf('%s\\n', cake);\r\nassert(isequal(birthday_cake(\"Alan Turing\", 105), cake));\r\n\r\n%%\r\ncake = string(char([32 32 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 10 32 32 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 10 32 95 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 95 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 83 105 114 32 73 115 97 97 99 32 78 101 119 116 111 110 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 125 10]));\r\nfprintf('%s\\n', cake);\r\nassert(isequal(birthday_cake(\"Sir Isaac Newton\", 375), cake));","published":true,"deleted":false,"likes_count":10,"comments_count":4,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":227,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-12T19:48:13.000Z","updated_at":"2026-03-25T05:11:31.000Z","published_at":"2017-10-16T01:45: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\u003eGiven an age and a name, give draw an ASCII birthday cake. For example, given the name \\\"CODY\\\" and the age 5, return a string with the following (no trailing spaces)\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[   6 6 6 6 6\\n   | | | | |\\n __|_|_|_|_|__\\n{             }\\n{             }\\n{    CODY     }\\n{             }\\n{_____________}]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis uses the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/help/matlab/ref/string.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estring datatype\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, not a char array.\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":44345,"title":"MATLAB Counter","description":"Write a function f = counter(x0,b) to construct a counter handle f that counts with an initial value x0 and a step size b. \r\n\r\nE.g.,\r\n\r\n  \u003e\u003e f = counter(0,1)  % Initialize a counter f() with initial_count = 0 and step_size = 1\r\n  \u003e\u003e f()\r\n  ans =\r\n       0\r\n  \u003e\u003e f()\r\n  ans =\r\n       1\r\n  \u003e\u003e f()\r\n  ans =\r\n       2\r\n\r\n\r\n","description_html":"\u003cp\u003eWrite a function f = counter(x0,b) to construct a counter handle f that counts with an initial value x0 and a step size b.\u003c/p\u003e\u003cp\u003eE.g.,\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u0026gt;\u0026gt; f = counter(0,1)  % Initialize a counter f() with initial_count = 0 and step_size = 1\r\n\u0026gt;\u0026gt; f()\r\nans =\r\n     0\r\n\u0026gt;\u0026gt; f()\r\nans =\r\n     1\r\n\u0026gt;\u0026gt; f()\r\nans =\r\n     2\r\n\u003c/pre\u003e","function_template":"function y = counter(x,b)\r\n  y = x;\r\nend","test_suite":"%%\r\nassessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','counter.m')\r\n\r\n%%\r\nf = counter(0,1);\r\nassert(isequal(f(),0))\r\nassert(isequal(f(),1))\r\nassert(isequal(2,f()))\r\nassert(isequal(3,f()))\r\n\r\n%%\r\nf = counter(1,0);\r\nassert(isequal(f(),1))\r\nassert(isequal(f(),1))\r\nassert(isequal(1,f()))\r\nassert(isequal(1,f()))\r\n\r\n%%\r\nf = counter(10,2);\r\nassert(isequal(f(),10))\r\nassert(isequal(f(),12))\r\nassert(isequal(14,f()))\r\nassert(isequal(16,f()))\r\n\r\n%%\r\nf = counter(0,5);\r\ny_correct = [0, 5, 10, 15, 20, 55];\r\nassert(isequal([f() f() f() f() f() f()+f()],y_correct))\r\n\r\n%%\r\nx0 = randi(10);\r\nb = randi(10);\r\nf = counter(x0,b);\r\ny_correct = x0 + (0:1000)*b;\r\nassert(isequal(arrayfun(@(n)f(),0:1000),y_correct))","published":true,"deleted":false,"likes_count":23,"comments_count":9,"created_by":12569,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":299,"test_suite_updated_at":"2017-10-17T00:19:49.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-24T01:58:21.000Z","updated_at":"2026-04-03T06:36:03.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\u003eWrite a function f = counter(x0,b) to construct a counter handle f that counts with an initial value x0 and a step size b.\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\u003eE.g.,\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 f = counter(0,1)  % Initialize a counter f() with initial_count = 0 and step_size = 1\\n\u003e\u003e f()\\nans =\\n     0\\n\u003e\u003e f()\\nans =\\n     1\\n\u003e\u003e f()\\nans =\\n     2]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":369,"title":"Basic electricity in a dry situation","description":"\u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \r\n\r\nThis is a very hypothetical situation between two individuals in a very dry atmosphere. \r\n\r\nHe came running in rubber boots when she was combing her hair. \r\n\r\nAround N number of electrons moved from one person to the other upon contact. \r\n\r\nWhat was the voltage between them before the contact? \r\n\r\nAssume it is a simple RC type electrical circuit with equivalent capacitance of about 16 pico farads. \r\n\r\nPlease assume that every electron carries about 160 zepto coulombs.\r\n\r\nFor more info on capacitors: \u003chttps://en.wikipedia.org/wiki/Capacitor\u003e","description_html":"\u003cp\u003e\u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889 \u0026#9889\u003c/p\u003e\u003cp\u003eThis is a very hypothetical situation between two individuals in a very dry atmosphere.\u003c/p\u003e\u003cp\u003eHe came running in rubber boots when she was combing her hair.\u003c/p\u003e\u003cp\u003eAround N number of electrons moved from one person to the other upon contact.\u003c/p\u003e\u003cp\u003eWhat was the voltage between them before the contact?\u003c/p\u003e\u003cp\u003eAssume it is a simple RC type electrical circuit with equivalent capacitance of about 16 pico farads.\u003c/p\u003e\u003cp\u003ePlease assume that every electron carries about 160 zepto coulombs.\u003c/p\u003e\u003cp\u003eFor more info on capacitors: \u003ca href = \"https://en.wikipedia.org/wiki/Capacitor\"\u003ehttps://en.wikipedia.org/wiki/Capacitor\u003c/a\u003e\u003c/p\u003e","function_template":"function V = volts(N)\r\n  V = 10000;\r\nend","test_suite":"%%\r\nN = 10^10;\r\nV = 150;\r\nassert(volts(N)\u003eV/pi)\r\n%%\r\nN = 10^11;\r\nV = 700;\r\nassert(volts(N)\u003cV*pi)\r\n%%\r\nN = 10^12;\r\nV = 10000;\r\nassert(volts(N)\u003eV/sqrt(pi))\r\n","published":true,"deleted":false,"likes_count":8,"comments_count":4,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":595,"test_suite_updated_at":"2012-02-20T20:05:18.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2012-02-20T20:05:18.000Z","updated_at":"2026-03-18T13:23:56.000Z","published_at":"2017-10-16T01:45:05.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\u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889 \u0026amp;#9889\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 is a very hypothetical situation between two individuals in a very dry atmosphere.\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\u003eHe came running in rubber boots when she was combing her hair.\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\u003eAround N number of electrons moved from one person to the other upon contact.\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\u003eWhat was the voltage between them before the contact?\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\u003eAssume it is a simple RC type electrical circuit with equivalent capacitance of about 16 pico farads.\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\u003ePlease assume that every electron carries about 160 zepto coulombs.\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 more info on capacitors:\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/Capacitor\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/Capacitor\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":361,"title":"Energy of a photon","description":"\u0026#9883 \u0026#9762 \u0026#9883 \u0026#9762 \u0026#9883 \u0026#9762 \u0026#9883\r\nGiven the frequency F of a photon in giga hertz.\r\nFind energy E of this photon in giga electron volts.\r\nAssume h, Planck's constant is about 4 femto electron-volt-second.\r\nTo maximize benefits, it may help not looking at the Test Suite before trying any solution!\r\nFor more info: \u003chttps://en.wikipedia.org/wiki/Planck_constant\u003e","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 171px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 85.5px; transform-origin: 407px 85.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 187px 8px; transform-origin: 187px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e\u0026amp;#9883 \u0026amp;#9762 \u0026amp;#9883 \u0026amp;#9762 \u0026amp;#9883 \u0026amp;#9762 \u0026amp;#9883\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: 151px 8px; transform-origin: 151px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven the frequency F of a photon in giga hertz.\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: 158.5px 8px; transform-origin: 158.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFind energy E of this photon in giga electron volts.\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: 211px 8px; transform-origin: 211px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAssume h, Planck's constant is about 4 femto electron-volt-second.\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: 276.5px 8px; transform-origin: 276.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eTo maximize benefits, it may help not looking at the Test Suite before trying any solution!\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: 44.5px 8px; transform-origin: 44.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor more info:\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\u003ca target='_blank' href = \"https://en.wikipedia.org/wiki/Planck_constant\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e\u0026lt;https://en.wikipedia.org/wiki/Planck_constant\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 4px 8px; transform-origin: 4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u0026gt;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function E = photon_energy(F)\r\n  E=100/F;\r\nend","test_suite":"%%\r\nF = 1;\r\nE_correct = 3/10^15;\r\nassert(photon_energy(F)\u003eE_correct)\r\n%%\r\nF = 100;\r\nE_correct = 500/10^15;\r\nassert(photon_energy(F)\u003cE_correct)\r\n%%\r\nF = 500;\r\nE_correct = 2100/10^15;\r\nassert(photon_energy(F)\u003cE_correct)\r\n%%\r\nF = 420;\r\nE_correct = 1680/10^15;\r\nassert(isequal(photon_energy(F),E_correct))\r\n%%\r\nF = 0.25;\r\nE_correct = 1e-15;\r\nassert(isequal(photon_energy(F),E_correct))","published":true,"deleted":false,"likes_count":15,"comments_count":11,"created_by":166,"edited_by":223089,"edited_at":"2022-12-24T15:16:49.000Z","deleted_by":null,"deleted_at":null,"solvers_count":1465,"test_suite_updated_at":"2022-12-24T15:16:49.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2012-02-19T23:13:56.000Z","updated_at":"2026-04-01T13:59:42.000Z","published_at":"2017-10-16T01:45:05.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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u0026amp;#9883 \u0026amp;#9762 \u0026amp;#9883 \u0026amp;#9762 \u0026amp;#9883 \u0026amp;#9762 \u0026amp;#9883\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\u003eGiven the frequency F of a photon in giga hertz.\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\u003eFind energy E of this photon in giga electron volts.\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\u003eAssume h, Planck's constant is about 4 femto electron-volt-second.\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\u003eTo maximize benefits, it may help not looking at the Test Suite before trying any solution!\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 more info:\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/Planck_constant\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/Planck_constant\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\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":2736,"title":"Pernicious Anniversary Problem","description":"Since Cody is 5 years old, it's pernicious. A \u003chttp://rosettacode.org/wiki/Pernicious_numbers Pernicious number\u003e is an integer whose population count is a prime. Check if the given number is pernicious.","description_html":"\u003cp\u003eSince Cody is 5 years old, it's pernicious. A \u003ca href = \"http://rosettacode.org/wiki/Pernicious_numbers\"\u003ePernicious number\u003c/a\u003e is an integer whose population count is a prime. Check if the given number is pernicious.\u003c/p\u003e","function_template":"function y = isPernicious(x)\r\n  y = false;\r\nend","test_suite":"%%\r\nx = 5;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 1;\r\ny_correct = false;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 2^randi(16);\r\ny_correct = false;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 17;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 18;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 61;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 6;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 2115;\r\ny_correct = false;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 2114;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n%%\r\nx = 2017;\r\ny_correct = true;\r\nassert(isequal(isPernicious(x),y_correct))\r\n\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":13,"comments_count":1,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":837,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2014-12-08T08:48:45.000Z","updated_at":"2026-03-18T13:27:13.000Z","published_at":"2017-10-16T01:45:06.000Z","restored_at":"2017-10-25T14:37:50.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\u003eSince Cody is 5 years old, it's pernicious. A\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://rosettacode.org/wiki/Pernicious_numbers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePernicious number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is an integer whose population count is a prime. Check if the given number is pernicious.\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":44315,"title":"Predicting life and death of a memory-less light bulb","description":"*\u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161* \r\n\r\nYou have a light bulb that can fail any moment according to the exponential probability distribution. \r\n\r\nAt any moment, the probability that it will survive just N hours = exp(-N*P), where P is a constant. \r\n\r\nNotice that this probability is very small if N is very large. \r\n\r\nNow suppose, the bulb has already survived N hours. \r\n\r\nPlease calculate the probability of its surviving M more hours.\r\n","description_html":"\u003cp\u003e\u003cb\u003e\u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161\u003c/b\u003e\u003c/p\u003e\u003cp\u003eYou have a light bulb that can fail any moment according to the exponential probability distribution.\u003c/p\u003e\u003cp\u003eAt any moment, the probability that it will survive just N hours = exp(-N*P), where P is a constant.\u003c/p\u003e\u003cp\u003eNotice that this probability is very small if N is very large.\u003c/p\u003e\u003cp\u003eNow suppose, the bulb has already survived N hours.\u003c/p\u003e\u003cp\u003ePlease calculate the probability of its surviving M more hours.\u003c/p\u003e","function_template":"function hope = fate(N,P,M)\r\n  hope=exp(-(N+M)*P);\r\nend","test_suite":"%%\r\nN = 1;\r\nP=1;\r\nM=0;\r\nhope_correct = 1;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN = 1;\r\nP=0;\r\nM=1;\r\nhope_correct = 1;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN=1;\r\nP=1;\r\nM=1;\r\nhope_correct = 0.3679;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN=2;\r\nP=1;\r\nM=1;\r\nhope_correct = 0.3679;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN=2;\r\nP=1;\r\nM=2;\r\nhope_correct = 0.1353;\r\nassert(fate(N,P,M)\u003chope_correct*1.1)\r\n%%\r\nN=2;\r\nP=2;\r\nM=2;\r\nhope_correct = 0.0183;\r\nassert(fate(N,P,M)\u003chope_correct*1.1)\r\n%%","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":336,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-12T02:53:45.000Z","updated_at":"2026-03-25T02:55:11.000Z","published_at":"2017-10-16T01:45: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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161\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 have a light bulb that can fail any moment according to the exponential probability distribution.\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\u003eAt any moment, the probability that it will survive just N hours = exp(-N*P), where P is a constant.\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\u003eNotice that this probability is very small if N is very large.\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\u003eNow suppose, the bulb has already survived N hours.\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\u003ePlease calculate the probability of its surviving M more hours.\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":44370,"title":"Octoberfest festival","description":"A group of students decided to visit Octoberfest festival. First they ordered one beer, then after half-hour they taken one more, after one more half-hour they ordered two more beers like sum of previous two times. Then after having spend a good time and anoter half an hour they ordered three beers. The situation went on. Task: calculate how many beers they ordered after n half-hours for given n - number of half-hours.\r\n\r\nExample:\r\n\r\nn=1 result will be 2;\r\n\r\nn=2 result will be 4.","description_html":"\u003cp\u003eA group of students decided to visit Octoberfest festival. First they ordered one beer, then after half-hour they taken one more, after one more half-hour they ordered two more beers like sum of previous two times. Then after having spend a good time and anoter half an hour they ordered three beers. The situation went on. Task: calculate how many beers they ordered after n half-hours for given n - number of half-hours.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003en=1 result will be 2;\u003c/p\u003e\u003cp\u003en=2 result will be 4.\u003c/p\u003e","function_template":"function totalNumberOfOrderedBeers = OctoberfestFestival(n)  \r\n  totalNumberOfOrderedBeers=n\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 2;\r\nassert(isequal(OctoberfestFestival(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = 20;\r\nassert(isequal(OctoberfestFestival(x),y_correct))\r\n%%\r\nx = 10;\r\ny_correct = 232;\r\nassert(isequal(OctoberfestFestival(x),y_correct))","published":true,"deleted":false,"likes_count":4,"comments_count":11,"created_by":90467,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":498,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-10T19:33:58.000Z","updated_at":"2026-03-18T12:47:33.000Z","published_at":"2017-10-16T01:45: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\u003eA group of students decided to visit Octoberfest festival. First they ordered one beer, then after half-hour they taken one more, after one more half-hour they ordered two more beers like sum of previous two times. Then after having spend a good time and anoter half an hour they ordered three beers. The situation went on. Task: calculate how many beers they ordered after n half-hours for given n - number of half-hours.\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\u003en=1 result will be 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=2 result will be 4.\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":44314,"title":"A Simple Tide Gauge with MATLAB","description":"*\u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767* \r\n\r\nYou are standing in a few inches of sea water on a beach.\r\n\r\nYou are wondering whether the high tide is coming soon or it has just passed. \r\n\r\nTherefore, you will write a code in MATLAB to analyze following data. \r\n\r\nYou followed the sequence of water lines left by several swash of waves. \r\n\r\nThe data array A contains the distances the water traveled past your feet during each upward swash of waves. \r\n\r\nYour code will return 1 if the high tide is coming soon. \r\n\r\nYour code will return 0 if the high tide has just passed.    \r\n","description_html":"\u003cp\u003e\u003cb\u003e\u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767 \u0026#8767\u003c/b\u003e\u003c/p\u003e\u003cp\u003eYou are standing in a few inches of sea water on a beach.\u003c/p\u003e\u003cp\u003eYou are wondering whether the high tide is coming soon or it has just passed.\u003c/p\u003e\u003cp\u003eTherefore, you will write a code in MATLAB to analyze following data.\u003c/p\u003e\u003cp\u003eYou followed the sequence of water lines left by several swash of waves.\u003c/p\u003e\u003cp\u003eThe data array A contains the distances the water traveled past your feet during each upward swash of waves.\u003c/p\u003e\u003cp\u003eYour code will return 1 if the high tide is coming soon.\u003c/p\u003e\u003cp\u003eYour code will return 0 if the high tide has just passed.\u003c/p\u003e","function_template":"function tide = gauge(A)\r\n  tide=max(A)-min(A);\r\n  tide=tide*0;\r\nend","test_suite":"%%\r\nA = [5 8 10 12 8 13 14 10 10 15];\r\ntide_correct = 1;\r\nassert(isequal(gauge(A),tide_correct))\r\n%%\r\nA = [15 16 11 9 10 15 7 12 6 11 5 6];\r\ntide_correct = 0;\r\nassert(isequal(gauge(A),tide_correct))\r\n%%\r\nA = [9 15 3 9 5 18 4 17 18 19 8 13 12 21 17 24];\r\ntide_correct = 1;\r\nassert(isequal(gauge(A),tide_correct))\r\n%%\r\nA = [22 12 22 12 9 14 17 16 15 8 13 6 10 7 13 3];\r\ntide_correct = 0;\r\nassert(isequal(gauge(A),tide_correct))\r\n%%\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":3,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":394,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-12T00:26:53.000Z","updated_at":"2026-03-25T04:12:58.000Z","published_at":"2017-10-16T01:45: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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u0026amp;#8767 \u0026amp;#8767 \u0026amp;#8767 \u0026amp;#8767 \u0026amp;#8767 \u0026amp;#8767 \u0026amp;#8767 \u0026amp;#8767\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 standing in a few inches of sea water on a beach.\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 wondering whether the high tide is coming soon or it has just passed.\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\u003eTherefore, you will write a code in MATLAB to analyze following data.\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 followed the sequence of water lines left by several swash of waves.\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 data array A contains the distances the water traveled past your feet during each upward swash of waves.\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\u003eYour code will return 1 if the high tide is coming soon.\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\u003eYour code will return 0 if the high tide has just passed.\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":564,"title":"How to subtract?","description":"*\u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn* \r\n\r\n* Imagine you need to subtract one number from another using MATLAB.\r\n* You will not be using eval for this task.\r\n* Given two ASCII strings representing two integers X and Y.\r\n* Each of them has only 12 or less ASCII characters.\r\n* Each of them represents signed integers, such as '+2345'\r\n* Please output the result of (X-Y) in a similar style.","description_html":"\u003cp\u003e\u003cb\u003e\u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn \u0026plusmn\u003c/b\u003e\u003c/p\u003e\u003cul\u003e\u003cli\u003eImagine you need to subtract one number from another using MATLAB.\u003c/li\u003e\u003cli\u003eYou will not be using eval for this task.\u003c/li\u003e\u003cli\u003eGiven two ASCII strings representing two integers X and Y.\u003c/li\u003e\u003cli\u003eEach of them has only 12 or less ASCII characters.\u003c/li\u003e\u003cli\u003eEach of them represents signed integers, such as '+2345'\u003c/li\u003e\u003cli\u003ePlease output the result of (X-Y) in a similar style.\u003c/li\u003e\u003c/ul\u003e","function_template":"function Z = mysub(X,Y)\r\n   Z = 0;\r\nend\r\n","test_suite":"%%\r\nX='+68768686834554';\r\nY='+76574535435398';\r\nZ_correct='-7805848600844';\r\nassert(isequal(mysub(X,Y),Z_correct))\r\n\r\n%%\r\nX='+1';\r\nY='+2';\r\nZ_correct ='-1';\r\nassert(isequal(mysub(X,Y),Z_correct))\r\n\r\n%%\r\nX='+100';\r\nY='+20';\r\nZ_correct ='+80';\r\nassert(isequal(mysub(X,Y),Z_correct))\r\n","published":true,"deleted":false,"likes_count":7,"comments_count":11,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1535,"test_suite_updated_at":"2017-10-16T20:04:25.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2012-04-08T02:27:39.000Z","updated_at":"2026-02-04T22:10:20.000Z","published_at":"2017-10-16T01:45:05.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\u003e\u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn \u0026amp;plusmn\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eImagine you need to subtract one number from another using MATLAB.\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will not be using eval for this task.\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two ASCII strings representing two integers X and Y.\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEach of them has only 12 or less ASCII characters.\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEach of them represents signed integers, such as '+2345'\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePlease output the result of (X-Y) in a similar style.\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":44369,"title":"Circle/Pentagon Overlap","description":"Your function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return the number of pentagon vertices that lie within or on the circle. The tolerance for lying on the circle is 0.02.","description_html":"\u003cp\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return the number of pentagon vertices that lie within or on the circle. The tolerance for lying on the circle is 0.02.\u003c/p\u003e","function_template":"function y = circle_pentagon_overlap(p,cp,r)\r\n y = 0;\r\nend","test_suite":"%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 4;\r\ny_correct = 0;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 15;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [2,0];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [2,0.75];\r\nr = 5;\r\ny_correct = 3;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [7.5,0];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,-5];\r\nr = 9;\r\ny_correct = 4;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19,8];\r\nr = 5;\r\ny_correct = 3;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19.5,10];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19.5,10];\r\nr = 6.6;\r\ny_correct = 4;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19.5,10];\r\nr = 7;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8;\r\ny_correct = 0;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":327,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-10T18:44:43.000Z","updated_at":"2026-03-18T12:46:34.000Z","published_at":"2017-10-16T01:45: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\",\"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\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return the number of pentagon vertices that lie within or on the circle. The tolerance for lying on the circle is 0.02.\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":44358,"title":"I Plead the Fifth","description":"Write a function to provide a yes or no answer to the input string. However, it must plead the 5th amendment (return an empty string) if the number five or any variation thereof (e.g., fifth, fifty, fifteen, 5) is within the input string.","description_html":"\u003cp\u003eWrite a function to provide a yes or no answer to the input string. However, it must plead the 5th amendment (return an empty string) if the number five or any variation thereof (e.g., fifth, fifty, fifteen, 5) is within the input string.\u003c/p\u003e","function_template":"function answer = I_plead_the_fifth(question)\r\n str = 'yes/no';\r\nend","test_suite":"%%\r\nquestion = 'Are you the fifth child?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Were you at home on the night of 24 Oct 1974?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Did you go to work on 15 Oct 1955?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Did you go to the bowling alley last week?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Do you like bread?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Are there five fingers on your right hand?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Do you like pumpkins?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Do you have fifteen siblings?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Do two quarters equal fifty cents?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Do you own five dogs?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Is my name Harry?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))","published":true,"deleted":false,"likes_count":6,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":427,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-03T17:12:42.000Z","updated_at":"2026-03-22T03:30:09.000Z","published_at":"2017-10-16T01:45: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\",\"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 to provide a yes or no answer to the input string. However, it must plead the 5th amendment (return an empty string) if the number five or any variation thereof (e.g., fifth, fifty, fifteen, 5) is within the input 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":44363,"title":"Is this is a Tic Tac Toe X Win?","description":"For the game of Tic Tac Toe we will be storing the state of the game in a matrix M.\r\nFor this game:\r\n\r\nWe would store the state as this:\r\n-1  1  1 \r\n 1 -1 -1\r\n 1 -1 -1\r\nIf there were any blanks squares, they would be 0;\r\nFor this challenge, given a game state, does X (1) have a three in a row on any row, column or major diagonal?","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: 243.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 121.65px; transform-origin: 407px 121.65px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 50.5px 8px; transform-origin: 50.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor the game of\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\u003ca target='_blank' href = \"https://en.wikipedia.org/wiki/Tic-tac-toe\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eTic Tac Toe\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 167.5px 8px; transform-origin: 167.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e we will be storing the state of the game in a matrix M.\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: 45.5px 8px; transform-origin: 45.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor this game:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\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: 102.5px 8px; transform-origin: 102.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWe would store the state as this:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 61.3px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 30.65px; transform-origin: 404px 30.65px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 36px 8.5px; tab-size: 4; transform-origin: 36px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e-1  1  1 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 32px 8.5px; tab-size: 4; transform-origin: 32px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e 1 -1 -1\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 32px 8.5px; tab-size: 4; transform-origin: 32px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e 1 -1 -1\u003c/span\u003e\u003c/span\u003e\u003c/div\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: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; 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: 158px 8px; transform-origin: 158px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf there were any blanks squares, they would be 0;\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: 349px 8px; transform-origin: 349px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor this challenge, given a game state, does X (1) have a three in a row on any row, column or major diagonal?\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function flagWin = your_fcn_name(M)\r\n  flagWin = false\r\nend","test_suite":"%%\r\nx = [1 1 1\r\n     0 0 0\r\n     0 0 0];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [1 0 0\r\n     0 1 0\r\n     0 0 1];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [1 0 0\r\n     0 -1 0\r\n     1 0 1];\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [1 0 0\r\n     1 0 0\r\n     1 0 0];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [1 0 0\r\n     1 -1 0\r\n     1 0 0];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [0 0 1\r\n     0 1 0\r\n     1 0 0];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [1  0 0\r\n     0 -1 0\r\n     0  0 1];\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [1 0 0\r\n     0 1 0\r\n     0 0 1];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [-1 0 0\r\n     0 -1 0\r\n     0 0 -1];\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":240,"edited_by":223089,"edited_at":"2022-07-28T15:36:47.000Z","deleted_by":null,"deleted_at":null,"solvers_count":532,"test_suite_updated_at":"2022-07-28T15:36:47.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-09T23:11:43.000Z","updated_at":"2026-03-18T12:43:46.000Z","published_at":"2017-10-16T01:45:09.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\u003eFor the game of\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/Tic-tac-toe\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eTic Tac Toe\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e we will be storing the state of the game in a matrix M.\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 this game:\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\u003eWe would store the state as this:\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[-1  1  1 \\n 1 -1 -1\\n 1 -1 -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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf there were any blanks squares, they would be 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\u003eFor this challenge, given a game state, does X (1) have a three in a row on any row, column or major diagonal?\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":44384,"title":"Find the nearest prime number","description":"Happy 5th birthday, Cody! Since 5 is a prime number, let's have some fun looking for other prime numbers.\r\n\r\nGiven a positive integer x, find the nearest prime number. Keep in mind that the nearest prime may be less than x.\r\n\r\n*Examples*\r\n\r\n  nearestprime(5) = 5\r\n  nearestprime(36) = 37\r\n  nearestprime(200) = 199\r\n\r\nNOTE: You may ignore cases in which two prime numbers are equally close to x. (e.g., x=12 --\u003e 11 and 13 are both primes). ","description_html":"\u003cp\u003eHappy 5th birthday, Cody! Since 5 is a prime number, let's have some fun looking for other prime numbers.\u003c/p\u003e\u003cp\u003eGiven a positive integer x, find the nearest prime number. Keep in mind that the nearest prime may be less than x.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExamples\u003c/b\u003e\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003enearestprime(5) = 5\r\nnearestprime(36) = 37\r\nnearestprime(200) = 199\r\n\u003c/pre\u003e\u003cp\u003eNOTE: You may ignore cases in which two prime numbers are equally close to x. (e.g., x=12 --\u0026gt; 11 and 13 are both primes).\u003c/p\u003e","function_template":"function y = nearestprime(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 0;\r\ny_correct = 2;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 5;\r\ny_correct = 5;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 100;\r\ny_correct = 101;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 500;\r\ny_correct = 499;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 911;\r\ny_correct = 911;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 2500;\r\ny_correct = 2503;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 8000;\r\ny_correct = 7993;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 100000;\r\ny_correct = 100003;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 1300000;\r\ny_correct = 1299989;\r\nassert(isequal(nearestprime(x),y_correct))\r\n\r\n%%\r\nx = 179424710;\r\ny_correct = 179424719;\r\nassert(isequal(nearestprime(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":9,"comments_count":1,"created_by":4793,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":663,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-13T19:42:15.000Z","updated_at":"2026-03-20T10:59:25.000Z","published_at":"2017-10-16T01:45: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\u003eHappy 5th birthday, Cody! Since 5 is a prime number, let's have some fun looking for other prime numbers.\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\u003eGiven a positive integer x, find the nearest prime number. Keep in mind that the nearest prime may be less than x.\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\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[nearestprime(5) = 5\\nnearestprime(36) = 37\\nnearestprime(200) = 199]]\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: You may ignore cases in which two prime numbers are equally close to x. (e.g., x=12 --\u0026gt; 11 and 13 are both primes).\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":44385,"title":"Extra safe primes","description":"Did you know that the number 5 is the first safe prime? A safe prime is a prime number that can be expressed as 2p+1, where p is also a prime.\r\n\r\nTo celebrate Cody's Five-Year Anniversary, write a function to determine if a positive integer n is a safe prime in which the prime p (such that n=2p+1) is *also a safe prime*.\r\n\r\n*Examples*\r\n\r\n  isextrasafe(5) = false % because 5=2*2+1 and 2 is not a safe prime\r\n  isextrasafe(23) = true % because 23=2*11+1 and 11 is also a safe prime (11=2*5+1)\r\n","description_html":"\u003cp\u003eDid you know that the number 5 is the first safe prime? A safe prime is a prime number that can be expressed as 2p+1, where p is also a prime.\u003c/p\u003e\u003cp\u003eTo celebrate Cody's Five-Year Anniversary, write a function to determine if a positive integer n is a safe prime in which the prime p (such that n=2p+1) is \u003cb\u003ealso a safe prime\u003c/b\u003e.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExamples\u003c/b\u003e\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eisextrasafe(5) = false % because 5=2*2+1 and 2 is not a safe prime\r\nisextrasafe(23) = true % because 23=2*11+1 and 11 is also a safe prime (11=2*5+1)\r\n\u003c/pre\u003e","function_template":"function tf = isextrasafe(x)\r\n    tf = false;\r\nend","test_suite":"%%\r\nx = 0;\r\nassert(isequal(isextrasafe(x),false))\r\n\r\n%%\r\nx = 5;\r\nassert(isequal(isextrasafe(x),false))\r\n\r\n%%\r\nx = 7;\r\nassert(isequal(isextrasafe(x),false))\r\n\r\n%%\r\nx = 11;\r\nassert(isequal(isextrasafe(x),true))\r\n\r\n%%\r\nx = 15;\r\nassert(isequal(isextrasafe(x),false))\r\n\r\n%%\r\nx = 23;\r\nassert(isequal(isextrasafe(x),true))\r\n\r\n%%\r\nx = 71;\r\nassert(isequal(isextrasafe(x),false))\r\n\r\n%%\r\nx = 719;\r\nassert(isequal(isextrasafe(x),true))\r\n\r\n%%\r\nx = 2039;\r\nassert(isequal(isextrasafe(x),true))\r\n\r\n%%\r\nx = 2040;\r\nassert(isequal(isextrasafe(x),false))\r\n\r\n%%\r\nx = 5807;\r\nassert(isequal(isextrasafe(x),true))","published":true,"deleted":false,"likes_count":13,"comments_count":4,"created_by":4793,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":756,"test_suite_updated_at":"2017-10-19T17:09:19.000Z","rescore_all_solutions":true,"group_id":34,"created_at":"2017-10-13T20:02:13.000Z","updated_at":"2026-03-25T08:22:41.000Z","published_at":"2017-10-16T01:45: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\u003eDid you know that the number 5 is the first safe prime? A safe prime is a prime number that can be expressed as 2p+1, where p is also a prime.\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\u003eTo celebrate Cody's Five-Year Anniversary, write a function to determine if a positive integer n is a safe prime in which the prime p (such that n=2p+1) 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\u003ealso a safe prime\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\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[isextrasafe(5) = false % because 5=2*2+1 and 2 is not a safe prime\\nisextrasafe(23) = true % because 23=2*11+1 and 11 is also a safe prime (11=2*5+1)]]\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":44319,"title":"Write c^3 as sum of two squares a^2+b^2","description":"write c^3 as sum of two squares a^2+b^2. a and b must be integer and greater than zero.\r\n\r\nFor example \r\n\r\n 5^3 = 2^2 + 11^2\r\n 5^3 = 5^2 + 10^2\r\n 10^3 = 10^2 + 30^2\r\n 10^3 = 18^2 + 26^2\r\n\r\nsort output matrix so that each row and first column is in ascending order.","description_html":"\u003cp\u003ewrite c^3 as sum of two squares a^2+b^2. a and b must be integer and greater than zero.\u003c/p\u003e\u003cp\u003eFor example\u003c/p\u003e\u003cpre\u003e 5^3 = 2^2 + 11^2\r\n 5^3 = 5^2 + 10^2\r\n 10^3 = 10^2 + 30^2\r\n 10^3 = 18^2 + 26^2\u003c/pre\u003e\u003cp\u003esort output matrix so that each row and first column is in ascending order.\u003c/p\u003e","function_template":"function y = sumoftwosquares(c)\r\n\r\nend","test_suite":"%%\r\nc = 1;\r\ny_correct = [];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 5;\r\ny_correct = [2 11; 5 10];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 6;\r\ny_correct = [];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 10;\r\ny_correct = [10 30; 18 26];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 20;\r\ny_correct = [16 88; 40 80];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 24;\r\ny_correct = [];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 40;\r\ny_correct = [80 240; 144 208];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 65;\r\ny_correct = [7 524; 65 520; 140 505; 191 488; 208 481; 260 455; 320 415; 364 377];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 100;\r\ny_correct = [280 960; 352 936; 600 800];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 123;\r\ny_correct = [];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 340;\r\ny_correct = [408 6256;1360 6120; 1680 6040; 2280 5840; 2584 5712; 3304 5328; 3824 4968; 4080 4760];\r\nassert(isequal(sumoftwosquares(c),y_correct))\r\n\r\n%%\r\nc = 500;\r\ny_correct = [1160 11120; 2000 11000; 5000 10000; 5744 9592; 7600 8200];\r\nassert(isequal(sumoftwosquares(c),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":329,"test_suite_updated_at":"2017-10-16T17:19:22.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-12T19:54:46.000Z","updated_at":"2026-04-01T13:09:32.000Z","published_at":"2017-10-16T01:45: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\u003ewrite c^3 as sum of two squares a^2+b^2. a and b must be integer and greater than zero.\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[ 5^3 = 2^2 + 11^2\\n 5^3 = 5^2 + 10^2\\n 10^3 = 10^2 + 30^2\\n 10^3 = 18^2 + 26^2]]\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\u003esort output matrix so that each row and first column is in ascending order.\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":44360,"title":"Pentagonal Numbers","description":"Your function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascending order. Additionally, it should return an array that indicates those numbers that are divisible by 5. For example,\r\n\r\n [p,d] = pentagonal_numbers(10,40)\r\n\r\nshould return\r\n\r\n p = [12,22,35]\r\n d = [ 0, 0, 1]","description_html":"\u003cp\u003eYour function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascending order. Additionally, it should return an array that indicates those numbers that are divisible by 5. For example,\u003c/p\u003e\u003cpre\u003e [p,d] = pentagonal_numbers(10,40)\u003c/pre\u003e\u003cp\u003eshould return\u003c/p\u003e\u003cpre\u003e p = [12,22,35]\r\n d = [ 0, 0, 1]\u003c/pre\u003e","function_template":"function [p,d] = pentagonal_numbers(10,40)\r\n p = [5];\r\n d = [1];\r\nend","test_suite":"%%\r\nx1 = 1; x2 = 25;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1,5,12,22]))\r\nassert(isequal(d,[0,1,0,0]))\r\n\r\n%%\r\nx1 = 1; x2 = 4;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,1))\r\nassert(isequal(d,0))\r\n\r\n%%\r\nx1 = 10; x2 = 40;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[12,22,35]))\r\nassert(isequal(d,[0,0,1]))\r\n\r\n%%\r\nx1 = 10; x2 = 99;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[12,22,35,51,70,92]))\r\nassert(isequal(d,[0,0,1,0,1,0]))\r\n\r\n%%\r\nx1 = 100; x2 = 999;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[117,145,176,210,247,287,330,376,425,477,532,590,651,715,782,852,925]))\r\nassert(isequal(d,[0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1]))\r\n\r\n%%\r\nx1 = 40; x2 = 50;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isempty(p))\r\nassert(isempty(d))\r\n\r\n%%\r\nx1 = 1000; x2 = 1500;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1001,1080,1162,1247,1335,1426]))\r\nassert(isequal(d,[0,1,0,0,1,0]))\r\n\r\n%%\r\nx1 = 1500; x2 = 3000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1520,1617,1717,1820,1926,2035,2147,2262,2380,2501,2625,2752,2882]))\r\nassert(isequal(d,[1,0,0,1,0,1,0,0,1,0,1,0,0]))\r\n\r\n%%\r\nx1 = 1; x2 = 3000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1,5,12,22,35,51,70,92,117,145,176,210,247,287,330,376,425,477,532,590,651,715,782,852,925,1001,1080,1162,1247,1335,1426,1520,1617,1717,1820,1926,2035,2147,2262,2380,2501,2625,2752,2882]))\r\nassert(isequal(d,[0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0]))\r\n\r\n%%\r\nx1 = 10000; x2 = 12000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[10045,10292,10542,10795,11051,11310,11572,11837]))\r\nassert(isequal(d,[1,0,0,1,0,1,0,0]))\r\n\r\n%%\r\nx1 = 100000; x2 = 110000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[100492,101270,102051,102835,103622,104412,105205,106001,106800,107602,108407,109215]))\r\nassert(isequal(d,[0,1,0,1,0,0,1,0,1,0,0,1]))\r\n\r\n%%\r\nx1 = 1000000; x2 = 1010101;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1000825,1003277,1005732,1008190]))\r\nassert(isequal(d,[1,0,0,1]))","published":true,"deleted":false,"likes_count":12,"comments_count":3,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":677,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-05T17:43:36.000Z","updated_at":"2026-03-18T12:42:40.000Z","published_at":"2017-10-16T01:45: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\u003eYour function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascending order. Additionally, it should return an array that indicates those numbers that are divisible by 5. 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[ [p,d] = pentagonal_numbers(10,40)]]\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[ p = [12,22,35]\\n d = [ 0, 0, 1]]]\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":44368,"title":"Inscribed Pentagon?","description":"Your function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon will be centered about the circle. The function should return one of the following values:\r\n\r\n  0: the pentagon is completely enclosed within the circle but is not inscribed\r\n  1: the pentagon is inscribed in the circle (within ±0.02)\r\n  2: the vertices of the pentagon extend beyond the circle\r\n\r\nPoints will be rounded to the nearest hundredth. See the test cases for examples.","description_html":"\u003cp\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon will be centered about the circle. The function should return one of the following values:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0: the pentagon is completely enclosed within the circle but is not inscribed\r\n1: the pentagon is inscribed in the circle (within ±0.02)\r\n2: the vertices of the pentagon extend beyond the circle\r\n\u003c/pre\u003e\u003cp\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples.\u003c/p\u003e","function_template":"function y = inscribed_pentagon(p,cp,r)\r\n y = 0;\r\nend","test_suite":"%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [25.01,12.47; 25.98,4.58; 18.78,1.23; 13.37,7.03; 17.22,13.97];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.27,11.12; 23.92,5.87; 19.12,3.63; 15.52,7.50; 18.08,12.13];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [32.54,38.78; 38.84,26.41; 29.02,16.59; 16.65,22.89; 18.83,36.61];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.49,35.54; 34.69,27.29; 28.14,20.74; 19.89,24.95; 21.34,34.09];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),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":306,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-10T16:31:01.000Z","updated_at":"2026-03-18T12:45:42.000Z","published_at":"2017-10-16T01:45: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\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon will be centered about the circle. The function should return one of the following values:\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[0: the pentagon is completely enclosed within the circle but is not inscribed\\n1: the pentagon is inscribed in the circle (within ±0.02)\\n2: the vertices of the pentagon extend beyond the circle]]\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\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples.\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":44342,"title":"Spot the First Occurrence of 5","description":"This problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate \u003chttps://www.mathworks.com/matlabcentral/cody/contests/1?s_tid=Cody5YA_cody_home Cody's 5th birthday\u003e. \r\n\r\nIn this problem, let's determine the position (index) of the first occurrence of 5 along the first non-singleton dimension of an input array. \r\n\r\nE.g., \r\n\r\n* If the input is a vector, return the index of the first occurrence of 5. \r\n\r\n  x = [1 2 5 3 5];\r\n  y = 3;\r\n\r\n* If the input is a matrix, return the index of the first occurrence of 5 in each column. If 5 is not found, simply return 0; \r\n\r\n  % Input x is a matrix\r\n  x = [1 2 5\r\n       5 9 1\r\n       5 6 5];\r\n\r\n  % Output y\r\n  y = [2 0 1];\r\n\r\nNext problem in this series: \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44352-the-top-5-primes The Top 5 Primes\u003e","description_html":"\u003cp\u003eThis problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/contests/1?s_tid=Cody5YA_cody_home\"\u003eCody's 5th birthday\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eIn this problem, let's determine the position (index) of the first occurrence of 5 along the first non-singleton dimension of an input array.\u003c/p\u003e\u003cp\u003eE.g.,\u003c/p\u003e\u003cul\u003e\u003cli\u003eIf the input is a vector, return the index of the first occurrence of 5.\u003c/li\u003e\u003c/ul\u003e\u003cpre class=\"language-matlab\"\u003ex = [1 2 5 3 5];\r\ny = 3;\r\n\u003c/pre\u003e\u003cul\u003e\u003cli\u003eIf the input is a matrix, return the index of the first occurrence of 5 in each column. If 5 is not found, simply return 0;\u003c/li\u003e\u003c/ul\u003e\u003cpre class=\"language-matlab\"\u003e% Input x is a matrix\r\nx = [1 2 5\r\n     5 9 1\r\n     5 6 5];\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003e% Output y\r\ny = [2 0 1];\r\n\u003c/pre\u003e\u003cp\u003eNext problem in this series: \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44352-the-top-5-primes\"\u003eThe Top 5 Primes\u003c/a\u003e\u003c/p\u003e","function_template":"function y = locOf5(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','locOf5.m')\r\n\r\n%%\r\nx = 2:2:20;\r\ny_correct = 0;\r\nassert(isequal(locOf5(x),y_correct))\r\n\r\n%%\r\nx = rot90(1:10);\r\ny_correct = 6;\r\nassert(isequal(locOf5(x),y_correct))\r\n\r\n%%\r\nx = [1 2 5\r\n     5 9 1\r\n     5 6 5];\r\ny_correct = [2 0 1];\r\nassert(isequal(locOf5(x),y_correct))\r\n\r\n%%\r\nx = magic(5);\r\ny_correct = [0 2 0 0 0];\r\nassert(isequal(locOf5(x),y_correct))\r\n\r\n%%\r\nx = [1 2 3 4 5;\r\n     5 4 3 2 1\r\n     2 3 5 2 1\r\n     1 5 2 6 8\r\n     3 5 2 2 5];\r\ny_correct = [2 4 3 0 1];\r\nassert(isequal(locOf5(x),y_correct))\r\n\r\n% %%\r\n% x = randi([-10,10],20,1e6); \r\n% x(x==5) = 0;\r\n% p = sort(randi([0 size(x,1)],5,size(x,2)));\r\n% y_correct = p(1,:);\r\n% p(2:end,~y_correct) = 0;\r\n% [~,col,v] = find(p);\r\n% x((col-1)*size(x,1)+v) = 5;\r\n% assert(isequal(locOf5(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":12569,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":434,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-20T14:43:55.000Z","updated_at":"2026-03-18T13:43:25.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\u003eThis problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate\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/contests/1?s_tid=Cody5YA_cody_home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody's 5th birthday\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\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn this problem, let's determine the position (index) of the first occurrence of 5 along the first non-singleton dimension of an input array.\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\u003eE.g.,\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the input is a vector, return the index of the first occurrence of 5.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[x = [1 2 5 3 5];\\ny = 3;]]\u003e\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the input is a matrix, return the index of the first occurrence of 5 in each column. If 5 is not found, simply return 0;\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 x is a matrix\\nx = [1 2 5\\n     5 9 1\\n     5 6 5];\\n\\n% Output y\\ny = [2 0 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\u003eNext problem in this series:\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/44352-the-top-5-primes\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eThe Top 5 Primes\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":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":44338,"title":"Recaman Sequence - I","description":"Recaman Sequence (A005132 - \u003chttp://oeis.org/A005132 - OEIS Link\u003e) is defined as follow;\r\n\r\n  seq(0) = 0; \r\n  for n \u003e 0, seq(n) = seq(n-1) - n if positive and not already in the sequence, \r\n  otherwise seq(n) = seq(n-1) + n. \r\n\r\n  seq = 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9 ...\r\nindex = 1, 2, 3 ,...\r\n\r\nTo avoid zero index, start indexing from 1.\r\nreturn the first n elements in Recaman Sequence\r\n\r\n*Related Challenges :*\r\n\r\n# Recaman Sequence - I\r\n# \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44339 Recaman Sequence - II\u003e\r\n# \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44340 Recaman Sequence - III\u003e\r\n","description_html":"\u003cp\u003eRecaman Sequence (A005132 - \u003ca href = \"http://oeis.org/A005132\"\u003e- OEIS Link\u003c/a\u003e) is defined as follow;\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eseq(0) = 0; \r\nfor n \u0026gt; 0, seq(n) = seq(n-1) - n if positive and not already in the sequence, \r\notherwise seq(n) = seq(n-1) + n. \r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eseq = 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9 ...\r\nindex = 1, 2, 3 ,...\r\n\u003c/pre\u003e\u003cp\u003eTo avoid zero index, start indexing from 1.\r\nreturn the first n elements in Recaman Sequence\u003c/p\u003e\u003cp\u003e\u003cb\u003eRelated Challenges :\u003c/b\u003e\u003c/p\u003e\u003col\u003e\u003cli\u003eRecaman Sequence - I\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44339\"\u003eRecaman Sequence - II\u003c/a\u003e\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44340\"\u003eRecaman Sequence - III\u003c/a\u003e\u003c/li\u003e\u003c/ol\u003e","function_template":"function y = Recaman(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 0;\r\nassert(isequal(Recaman(x),y_correct))\r\n\r\n%%\r\nx = 5;\r\ny_correct = [0 1 3 6 2];\r\nassert(isequal(Recaman(x),y_correct))\r\n\r\n%%\r\nx = 8;\r\ny_correct = [0 1 3 6 2 7 13 20];\r\nassert(isequal(Recaman(x),y_correct))\r\n\r\n%%\r\nx = 10;\r\ny_correct = [0 1 3 6 2 7 13 20 12 21];\r\nassert(isequal(Recaman(x),y_correct))\r\n\r\n%%\r\nx = 5e4;\r\ny = Recaman(x);\r\nassert(isequal(length(Recaman(x)),x))\r\nassert(isequal(y(954),739))\r\nassert(isequal(y(7589),17654))\r\nassert(isequal(y(12345),18554))\r\n\r\n%%\r\nx = 1e5;\r\ny = Recaman(x);\r\nassert(isequal(length(Recaman(x)),x))\r\nassert(isequal(y(1e4),8658))\r\nassert(isequal(y(2e4),34358))\r\nassert(isequal(y(3e4),92474))\r\nassert(isequal(y(4e4),102344))","published":true,"deleted":false,"likes_count":3,"comments_count":8,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":321,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-19T06:55:43.000Z","updated_at":"2026-03-22T11:16:16.000Z","published_at":"2017-10-16T01:45: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\u003eRecaman Sequence (A005132 -\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://oeis.org/A005132\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e- OEIS Link\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e) is defined as follow;\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[seq(0) = 0; \\nfor n \u003e 0, seq(n) = seq(n-1) - n if positive and not already in the sequence, \\notherwise seq(n) = seq(n-1) + n. \\n\\nseq = 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9 ...\\nindex = 1, 2, 3 ,...]]\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\u003eTo avoid zero index, start indexing from 1. return the first n elements in Recaman Sequence\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\u003eRecaman Sequence - I\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/44339\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eRecaman Sequence - II\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:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44340\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eRecaman Sequence - III\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":44334,"title":"Sums of Multiple Pairs of Triangular Numbers","description":"This is a follow-up to \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44289 Problem 44289\u003e - Find two triangular numbers whose sum is input.\r\n\r\nThere are some numbers that are the sum of multiple pairs of triangular numbers.  For example, 81 = 36+45 = 15+66 = 3+78.  Given a number X, find all of the possible pairs of triangular numbers that add up to X.  Your answer should be in a 2-by-X matrix.  Each column of the matrix should sum to X, and each pair of triangular numbers should only appear once.  The top row sorted from low to high.  The output for 81 would be:\r\n\r\n [ 3   15  36 \r\n  78   66  45]\r\n\r\nGood luck!","description_html":"\u003cp\u003eThis is a follow-up to \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44289\"\u003eProblem 44289\u003c/a\u003e - Find two triangular numbers whose sum is input.\u003c/p\u003e\u003cp\u003eThere are some numbers that are the sum of multiple pairs of triangular numbers.  For example, 81 = 36+45 = 15+66 = 3+78.  Given a number X, find all of the possible pairs of triangular numbers that add up to X.  Your answer should be in a 2-by-X matrix.  Each column of the matrix should sum to X, and each pair of triangular numbers should only appear once.  The top row sorted from low to high.  The output for 81 would be:\u003c/p\u003e\u003cpre\u003e [ 3   15  36 \r\n  78   66  45]\u003c/pre\u003e\u003cp\u003eGood luck!\u003c/p\u003e","function_template":"function y = multi_triangular(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 21;\r\ny_correct = [6;15];\r\nassert(isequal(multi_triangular(x),y_correct))\r\n%%\r\nx=81;\r\ny_correct=[ 3   15  36 ;  78   66  45];\r\nassert(isequal(multi_triangular(x),y_correct))\r\n%%\r\nx=20;\r\ny_correct=[ 10 10];\r\nassert(isequal(multi_triangular(x),y_correct'))\r\n%%\r\nx=17956;\r\ny_correct=[ 1 190 378 1485 2556  4095 4753 6328 8911;\r\n 17955 17766 17578 16471 15400 13861 13203 11628 9045];\r\nassert(isequal(multi_triangular(x),y_correct))\r\n%%\r\nx=70;\r\ny_correct=[15 55];\r\nassert(isequal(multi_triangular(x),y_correct'));\r\n%%\r\nx=37052031;\r\ny_correct=[7503 16110 93528 119316 136503 393828 496506 778128 1033203 1194285 1675365 1876953 2503203 2627778 3214380 3436131 3983253 4226778 4943940 5112003 5279625 6063903 6417153 7055646 7771653 8456328 8855736 9801378 10015050 11221953 11580078 12834711 13846953 14084778 15149760 15387378 15531951 17096628 17567628 18395145;\r\n37044528 37035921 36958503 36932715 36915528 36658203 36555525 36273903 36018828 35857746 35376666 35175078 34548828 34424253 33837651 33615900 33068778 32825253 32108091 31940028 31772406 30988128 30634878 29996385 29280378 28595703 28196295 27250653 27036981 25830078 25471953 24217320 23205078 22967253 21902271 21664653 21520080 19955403 19484403 18656886];\r\nassert(isequal(multi_triangular(x),y_correct));\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":247,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-15T19:37:34.000Z","updated_at":"2026-03-22T12:09:49.000Z","published_at":"2017-10-16T01:45: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\u003eThis is a follow-up 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=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44289\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44289\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e - Find two triangular numbers whose sum is input.\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\u003eThere are some numbers that are the sum of multiple pairs of triangular numbers. For example, 81 = 36+45 = 15+66 = 3+78. Given a number X, find all of the possible pairs of triangular numbers that add up to X. Your answer should be in a 2-by-X matrix. Each column of the matrix should sum to X, and each pair of triangular numbers should only appear once. The top row sorted from low to high. The output for 81 would be:\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[ [ 3   15  36 \\n  78   66  45]]]\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\u003eGood 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":44321,"title":"Van Eck's Sequence's nth member","description":"Return the Van Eck's Sequence's nth member.\r\n\r\nFor detailed info : \u003chttp://oeis.org/A181391 OEIS link\u003e and \u003chttps://www.theguardian.com/science/alexs-adventures-in-numberland/2014/oct/07/neil-sloane-the-man-who-loved-only-integer-sequences here\u003e\r\n\r\n seq = 0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5...\r\n\r\nFirst member is 0;\r\n\r\nSecond member is 0;\r\n\r\nthird member is 1 etc\r\n","description_html":"\u003cp\u003eReturn the Van Eck's Sequence's nth member.\u003c/p\u003e\u003cp\u003eFor detailed info : \u003ca href = \"http://oeis.org/A181391\"\u003eOEIS link\u003c/a\u003e and \u003ca href = \"https://www.theguardian.com/science/alexs-adventures-in-numberland/2014/oct/07/neil-sloane-the-man-who-loved-only-integer-sequences\"\u003ehere\u003c/a\u003e\u003c/p\u003e\u003cpre\u003e seq = 0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5...\u003c/pre\u003e\u003cp\u003eFirst member is 0;\u003c/p\u003e\u003cp\u003eSecond member is 0;\u003c/p\u003e\u003cp\u003ethird member is 1 etc\u003c/p\u003e","function_template":"function result = VanEcksSequence(n)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 0;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 2;\r\ny_correct = 0;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 4;\r\ny_correct = 0;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 6;\r\ny_correct = 0;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 11;\r\ny_correct = 0;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 50;\r\ny_correct = 3;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 500;\r\ny_correct = 4;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n\r\n%%\r\nx = 5000;\r\ny_correct = 402;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n\r\n%%\r\nx = 50000;\r\ny_correct = 114;\r\nassert(isequal(VanEcksSequence(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":12,"comments_count":1,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":331,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-13T08:14:57.000Z","updated_at":"2026-03-24T14:52:41.000Z","published_at":"2017-10-16T01:45:07.000Z","restored_at":"2017-09-28T06:15:18.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\u003eReturn the Van Eck's Sequence's nth member.\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 detailed info :\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://oeis.org/A181391\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOEIS link\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=\\\"https://www.theguardian.com/science/alexs-adventures-in-numberland/2014/oct/07/neil-sloane-the-man-who-loved-only-integer-sequences\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\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=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ seq = 0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 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\u003eFirst member is 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSecond member is 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethird member is 1 etc\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":44339,"title":"Recaman Sequence - II","description":"Take an arbitrary starting point as input and create Recaman Sequence. Then find the 1, return its index.\r\n\r\nFor example: if n = 0 (default Recaman sequence)\r\n  \r\n  seq = [0 1 3 6 2];\r\n\r\n1 is in the second place. \r\n\r\nif n = 10;\r\n\r\n  seq = [10 9 7 4 8 3 9 2 10 1 11 22 34 21];\r\n\r\n1 is in the 10th place\r\n\r\n*Related Challenges :*\r\n\r\n# \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44338 Recaman Sequence - I\u003e\r\n# Recaman Sequence - II\r\n# \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44340 Recaman Sequence - III\u003e","description_html":"\u003cp\u003eTake an arbitrary starting point as input and create Recaman Sequence. Then find the 1, return its index.\u003c/p\u003e\u003cp\u003eFor example: if n = 0 (default Recaman sequence)\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eseq = [0 1 3 6 2];\r\n\u003c/pre\u003e\u003cp\u003e1 is in the second place.\u003c/p\u003e\u003cp\u003eif n = 10;\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eseq = [10 9 7 4 8 3 9 2 10 1 11 22 34 21];\r\n\u003c/pre\u003e\u003cp\u003e1 is in the 10th place\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/44338\"\u003eRecaman Sequence - I\u003c/a\u003e\u003c/li\u003e\u003cli\u003eRecaman Sequence - II\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44340\"\u003eRecaman Sequence - III\u003c/a\u003e\u003c/li\u003e\u003c/ol\u003e","function_template":"function y = RecamanII(startPoint)\r\n\r\nend","test_suite":"%%\r\nx = 0;\r\ny_correct = 2;\r\nassert(isequal(RecamanII(x),y_correct))\r\n\r\n%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(RecamanII(x),y_correct))\r\n\r\n%%\r\nx = 3;\r\ny_correct = 4;\r\nassert(isequal(RecamanII(x),y_correct))\r\n\r\n%%\r\nx = 90;\r\ny_correct = 35;\r\nassert(isequal(RecamanII(x),y_correct))\r\n\r\n%%\r\nx = 123456;\r\ny_correct = 895;\r\nassert(isequal(RecamanII(x),y_correct))\r\n\r\n%%\r\nx = 123456789;\r\ny_correct = 46633;\r\nassert(isequal(RecamanII(x),y_correct))\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":280,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-19T07:08:59.000Z","updated_at":"2026-03-22T11:06:47.000Z","published_at":"2017-10-16T01:45: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\u003eTake an arbitrary starting point as input and create Recaman Sequence. Then find the 1, return its index.\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: if n = 0 (default Recaman sequence)\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[seq = [0 1 3 6 2];]]\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\u003e1 is in the second place.\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 n = 10;\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[seq = [10 9 7 4 8 3 9 2 10 1 11 22 34 21];]]\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\u003e1 is in the 10th place\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/44338\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eRecaman Sequence - I\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\u003eRecaman Sequence - II\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/44340\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eRecaman Sequence - III\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":44305,"title":"5 Prime Numbers","description":"Your function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\r\n\r\nFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\r\n\r\n p = [61,67,71,73,79, ... 149,151,157,163, ... 241,251,257,263, ... 349,353,359,367, ... 983,991,997]\r\n\r\nThis set contains at least five numbers that contain a five; the first five are:\r\n\r\n p5 = [151,157,251,257,353]\r\n\r\nwhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).","description_html":"\u003cdiv style = \"text-align: start; line-height: 20px; 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: normal; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; transform-origin: 420.4375px 118px; vertical-align: baseline; perspective-origin: 420.4375px 118px; \"\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; transform-origin: 309px 31.5px; white-space: pre-wrap; perspective-origin: 309px 31.5px; 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; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYour function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\u003c/span\u003e\u003c/span\u003e\u003c/div\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; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; 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; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 417.4375px 10px; perspective-origin: 417.4375px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; 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-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e p = [61,67,71,73,79, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e149,151,157,163, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e241,251,257,263, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e349,353,359,367, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e983,991,997]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eThis set contains at least five numbers that contain a five; the first five are:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 417.4375px 10px; perspective-origin: 417.4375px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; 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-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e p5 = [151,157,251,257,353]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 21px; white-space: pre-wrap; perspective-origin: 309px 21px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003ewhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = five_primes(n_min,n_max)\r\n  y = [];\r\nend","test_suite":"%%\r\nn_min = 60;\r\nn_max = 1000;\r\ny_correct = [151,157,251,257,353];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 60;\r\nn_max = 300;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 1;\r\nn_max = 200;\r\ny_correct = [5,53,59,151,157];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 1;\r\nn_max = 100;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 600;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 555;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 500000000;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 5020;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 5200;\r\ny_correct = [5003,5009,5011,5021,5023];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 55555555;\r\ny_correct = [5003,5009,5011,5021,5023];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 55555;\r\nn_max = 56789;\r\ny_correct = [55579,55589,55603,55609,55619];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 987654321;\r\nn_max = 988777666;\r\ny_correct = [987654323,987654337,987654347,987654359,987654361];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))","published":true,"deleted":false,"likes_count":7,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":453,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-08T18:33:05.000Z","updated_at":"2026-04-06T09:57:52.000Z","published_at":"2017-10-16T01:45:06.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\u003eYour function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, for n_min = 60 and n_max = 1000, the set of prime numbers 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[ p = [61,67,71,73,79, … 149,151,157,163, … 241,251,257,263, … 349,353,359,367, … 983,991,997]]]\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\u003eThis set contains at least five numbers that contain a five; the first five are:\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[ p5 = [151,157,251,257,353]]]\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\u003ewhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).\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":44307,"title":"The glass half full","description":"Identical glasses are placed in a triangular tower structure, such that the top level (L = 1) comprises one glass, the next level down (L = 2) comprises three glasses, the next level down (L = 3) comprises six glasses, and so on.\r\n\r\nFollow the \u003chttps://imgur.com/a/j9ZZa link\u003e to see a diagram shows the first three levels. The glasses in each levels are represented by the blue circles, while the yellow circles represent the positions of the glasses in the next higher level.\r\n\r\nWater is poured into the top glass at a constant volumetric flow rate. When the glass is filled, the water starts spilling over and into the glasses below. Note that *water only spills outward* , meaning that at some point, some glasses will remain empty.\r\n\r\nGiven the volume of a glass in liters, v, the volumetric flow rate in liters per second, u, and an integer, L, representing a level in the glass structure, return the total number of glasses in that level, g, the number of glasses in that level that will be filled with water, f, and the time, in seconds, it would take to fill all \"fillable\" glasses in that level, t, starting with no water in any of the levels.\r\n\r\nExample:\r\n\r\nInput: v = 0.25, u = 0.1, L = 2\r\n\r\nOutput: g = 3, f = 3, t = 10","description_html":"\u003cp\u003eIdentical glasses are placed in a triangular tower structure, such that the top level (L = 1) comprises one glass, the next level down (L = 2) comprises three glasses, the next level down (L = 3) comprises six glasses, and so on.\u003c/p\u003e\u003cp\u003eFollow the \u003ca href = \"https://imgur.com/a/j9ZZa\"\u003elink\u003c/a\u003e to see a diagram shows the first three levels. The glasses in each levels are represented by the blue circles, while the yellow circles represent the positions of the glasses in the next higher level.\u003c/p\u003e\u003cp\u003eWater is poured into the top glass at a constant volumetric flow rate. When the glass is filled, the water starts spilling over and into the glasses below. Note that \u003cb\u003ewater only spills outward\u003c/b\u003e , meaning that at some point, some glasses will remain empty.\u003c/p\u003e\u003cp\u003eGiven the volume of a glass in liters, v, the volumetric flow rate in liters per second, u, and an integer, L, representing a level in the glass structure, return the total number of glasses in that level, g, the number of glasses in that level that will be filled with water, f, and the time, in seconds, it would take to fill all \"fillable\" glasses in that level, t, starting with no water in any of the levels.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003eInput: v = 0.25, u = 0.1, L = 2\u003c/p\u003e\u003cp\u003eOutput: g = 3, f = 3, t = 10\u003c/p\u003e","function_template":"function [g, f, t] = filltime(v, u, L)\r\n    [g, f, t] = [v, u, L];\r\nend","test_suite":"%%\r\n[g f t] = filltime(0.25, 0.1, 2);\r\nassert(isequal([g f t],[3 3 10]))\r\n\r\n%%\r\n[g f t] = filltime(0.45, 0.3, 6);\r\nassert(isequal([g f t],[21 15 69]))\r\n\r\n%%\r\n[g f t] = filltime(3, 0.8, 7);\r\nassert(isequal([g f t],[28 18 240]))\r\n\r\n\r\n%%\r\n[g f t] = filltime(2, 8, 47);\r\nassert(isequal([g f t],[1128 138 811]))","published":true,"deleted":false,"likes_count":8,"comments_count":1,"created_by":15521,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":259,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-09T07:06:17.000Z","updated_at":"2026-03-18T13:30:02.000Z","published_at":"2017-10-16T01:45: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\u003eIdentical glasses are placed in a triangular tower structure, such that the top level (L = 1) comprises one glass, the next level down (L = 2) comprises three glasses, the next level down (L = 3) comprises six glasses, and so on.\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\u003eFollow the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://imgur.com/a/j9ZZa\\\"\u003e\u003cw:r\u003e\u003cw:t\u003elink\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e to see a diagram shows the first three levels. The glasses in each levels are represented by the blue circles, while the yellow circles represent the positions of the glasses in the next higher level.\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\u003eWater is poured into the top glass at a constant volumetric flow rate. When the glass is filled, the water starts spilling over and into the glasses below. Note that\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\u003ewater only spills outward\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e , meaning that at some point, some glasses will remain empty.\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\u003eGiven the volume of a glass in liters, v, the volumetric flow rate in liters per second, u, and an integer, L, representing a level in the glass structure, return the total number of glasses in that level, g, the number of glasses in that level that will be filled with water, f, and the time, in seconds, it would take to fill all \\\"fillable\\\" glasses in that level, t, starting with no water in any of the levels.\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=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInput: v = 0.25, u = 0.1, L = 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\u003eOutput: g = 3, f = 3, t = 10\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":44375,"title":"Missing five","description":"Convert decimal numbers to a base-9 notation missing the digit *5*\r\n\r\n\u003c\u003chttp://www.alfnie.com/software/missing5.jpg\u003e\u003e\r\n\r\nToo many five-themed problems? Wondering whether everything would be simpler if we just got rid of the digit 5? Let's try!\r\n\r\nIn a world without 5's, positive integers may be represented using a base-9 notation that uses only the digits 0, 1, 2, 3, 4, 6, 7, 8, and 9. We'll call this the \"missing-5\" notation. The following list shows the first 100 positive numbers (i.e. 1 through 100) using \"missing-5\" notation:\r\n\r\n    '1'      '2'      '3'      '4'      '6'      '7'      '8'      '9'      '10'     '11' \r\n    '12'     '13'     '14'     '16'     '17'     '18'     '19'     '20'     '21'     '22' \r\n    '23'     '24'     '26'     '27'     '28'     '29'     '30'     '31'     '32'     '33' \r\n    '34'     '36'     '37'     '38'     '39'     '40'     '41'     '42'     '43'     '44' \r\n    '46'     '47'     '48'     '49'     '60'     '61'     '62'     '63'     '64'     '66' \r\n    '67'     '68'     '69'     '70'     '71'     '72'     '73'     '74'     '76'     '77' \r\n    '78'     '79'     '80'     '81'     '82'     '83'     '84'     '86'     '87'     '88' \r\n    '89'     '90'     '91'     '92'     '93'     '94'     '96'     '97'     '98'     '99' \r\n    '100'    '101'    '102'    '103'    '104'    '106'    '107'    '108'    '109'    '110'\r\n    '111'    '112'    '113'    '114'    '116'    '117'    '118'    '119'    '120'    '121'\r\n\r\nYou may notice that this is simply the sorted list of positive numbers which do not contain the digit 5 in their decimal representation. \r\n\r\nYour function should convert a positive decimal number N into its \"missing-5\" notation. For example\r\n\r\n dec2missing5(20)\r\n\r\nshould return _'22'_ (the 20th positive number in missing-5 notation), and\r\n\r\n dec2missing5(100)\r\n\r\nshould return _'121'_ (the 100th positive number in missing-5 notation)\r\n\r\nGood luck!\r\n\r\n_Small print_: Your function may output a number, a char array, or a string; whatever you find simpler (e.g. in the example above, valid outputs are 121, '121', or \"121\"). Input numbers in testsuite are always relatively low valued positive integers (\u003c10,000)","description_html":"\u003cp\u003eConvert decimal numbers to a base-9 notation missing the digit \u003cb\u003e5\u003c/b\u003e\u003c/p\u003e\u003cimg src = \"http://www.alfnie.com/software/missing5.jpg\"\u003e\u003cp\u003eToo many five-themed problems? Wondering whether everything would be simpler if we just got rid of the digit 5? Let's try!\u003c/p\u003e\u003cp\u003eIn a world without 5's, positive integers may be represented using a base-9 notation that uses only the digits 0, 1, 2, 3, 4, 6, 7, 8, and 9. We'll call this the \"missing-5\" notation. The following list shows the first 100 positive numbers (i.e. 1 through 100) using \"missing-5\" notation:\u003c/p\u003e\u003cpre\u003e    '1'      '2'      '3'      '4'      '6'      '7'      '8'      '9'      '10'     '11' \r\n    '12'     '13'     '14'     '16'     '17'     '18'     '19'     '20'     '21'     '22' \r\n    '23'     '24'     '26'     '27'     '28'     '29'     '30'     '31'     '32'     '33' \r\n    '34'     '36'     '37'     '38'     '39'     '40'     '41'     '42'     '43'     '44' \r\n    '46'     '47'     '48'     '49'     '60'     '61'     '62'     '63'     '64'     '66' \r\n    '67'     '68'     '69'     '70'     '71'     '72'     '73'     '74'     '76'     '77' \r\n    '78'     '79'     '80'     '81'     '82'     '83'     '84'     '86'     '87'     '88' \r\n    '89'     '90'     '91'     '92'     '93'     '94'     '96'     '97'     '98'     '99' \r\n    '100'    '101'    '102'    '103'    '104'    '106'    '107'    '108'    '109'    '110'\r\n    '111'    '112'    '113'    '114'    '116'    '117'    '118'    '119'    '120'    '121'\u003c/pre\u003e\u003cp\u003eYou may notice that this is simply the sorted list of positive numbers which do not contain the digit 5 in their decimal representation.\u003c/p\u003e\u003cp\u003eYour function should convert a positive decimal number N into its \"missing-5\" notation. For example\u003c/p\u003e\u003cpre\u003e dec2missing5(20)\u003c/pre\u003e\u003cp\u003eshould return \u003ci\u003e'22'\u003c/i\u003e (the 20th positive number in missing-5 notation), and\u003c/p\u003e\u003cpre\u003e dec2missing5(100)\u003c/pre\u003e\u003cp\u003eshould return \u003ci\u003e'121'\u003c/i\u003e (the 100th positive number in missing-5 notation)\u003c/p\u003e\u003cp\u003eGood luck!\u003c/p\u003e\u003cp\u003e\u003ci\u003eSmall print\u003c/i\u003e: Your function may output a number, a char array, or a string; whatever you find simpler (e.g. in the example above, valid outputs are 121, '121', or \"121\"). Input numbers in testsuite are always relatively low valued positive integers (\u0026lt;10,000)\u003c/p\u003e","function_template":"function y = dec2missing5(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(regexprep(char(string(dec2missing5(3))),'^0*',''),'3'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(14))),'^0*',''),'16'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(19))),'^0*',''),'21'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(80))),'^0*',''),'99'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(91))),'^0*',''),'111'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(313))),'^0*',''),'388'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(732))),'^0*',''),'1003'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(748))),'^0*',''),'1021'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(1249))),'^0*',''),'1738'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(1873))),'^0*',''),'2611'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(2790))),'^0*',''),'3840'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(3035))),'^0*',''),'4142'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(3391))),'^0*',''),'4688'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(3547))),'^0*',''),'4881'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(3724))),'^0*',''),'6098'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4057))),'^0*',''),'6608'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4221))),'^0*',''),'6810'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4389))),'^0*',''),'7017'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4444))),'^0*',''),'7088'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4489))),'^0*',''),'7138'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4530))),'^0*',''),'7193'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4533))),'^0*',''),'7197'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4569))),'^0*',''),'7237'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4585))),'^0*',''),'7264'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4651))),'^0*',''),'7338'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(4680))),'^0*',''),'7380'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(5455))),'^0*',''),'8431'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(5711))),'^0*',''),'8846'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(5949))),'^0*',''),'9140'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(5999))),'^0*',''),'9206'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6075))),'^0*',''),'9300'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6526))),'^0*',''),'9961'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6601))),'^0*',''),'10044'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6634))),'^0*',''),'10091'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6728))),'^0*',''),'10206'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6787))),'^0*',''),'10281'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(6902))),'^0*',''),'10419'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(7037))),'^0*',''),'10689'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(7212))),'^0*',''),'10903'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(7493))),'^0*',''),'11246'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(7962))),'^0*',''),'11927'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(7996))),'^0*',''),'11974'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8062))),'^0*',''),'12048'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8109))),'^0*',''),'12110'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8248))),'^0*',''),'12284'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8427))),'^0*',''),'12603'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8538))),'^0*',''),'12737'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8620))),'^0*',''),'12838'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(8959))),'^0*',''),'13264'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(9190))),'^0*',''),'13641'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(9289))),'^0*',''),'13771'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(9436))),'^0*',''),'13944'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(9480))),'^0*',''),'14003'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(9533))),'^0*',''),'14072'))\r\n%%\r\nassert(isequal(regexprep(char(string(dec2missing5(9541))),'^0*',''),'14081'))\r\n%%\r\nfor n=1:100, assert(all(char(string(dec2missing5(randi(10000))))~='5')); end\r\n%%\r\nx='1000'; for n=1:7, x=char(string(dec2missing5(str2double(x)))); end; assert(isequal(regexprep(x,'^0*',''),'11027'));\r\n%%\r\nx='234'; for n=1:10, x=char(string(dec2missing5(str2double(x)))); end; assert(isequal(regexprep(x,'^0*',''),'4240'));\r\n%%\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[13944,14003,14072,14081]),regexp(fileread('dec2missing5.m'),'((\\s*[\\+\\-\\*\\/]\\s*)?[\\d\\.])+','match'))),'please do not use look-up table solutions');\r\n\r\n","published":true,"deleted":false,"likes_count":9,"comments_count":7,"created_by":43,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":381,"test_suite_updated_at":"2017-10-31T17:07:46.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-11T00:58:23.000Z","updated_at":"2026-03-18T12:51:12.000Z","published_at":"2017-10-16T01:45: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\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/media/image1.JPEG\"}],\"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\u003eConvert decimal numbers to a base-9 notation missing the digit\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\u003e5\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:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\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\u003eToo many five-themed problems? Wondering whether everything would be simpler if we just got rid of the digit 5? Let's try!\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\u003eIn a world without 5's, positive integers may be represented using a base-9 notation that uses only the digits 0, 1, 2, 3, 4, 6, 7, 8, and 9. We'll call this the \\\"missing-5\\\" notation. The following list shows the first 100 positive numbers (i.e. 1 through 100) using \\\"missing-5\\\" notation:\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[    '1'      '2'      '3'      '4'      '6'      '7'      '8'      '9'      '10'     '11' \\n    '12'     '13'     '14'     '16'     '17'     '18'     '19'     '20'     '21'     '22' \\n    '23'     '24'     '26'     '27'     '28'     '29'     '30'     '31'     '32'     '33' \\n    '34'     '36'     '37'     '38'     '39'     '40'     '41'     '42'     '43'     '44' \\n    '46'     '47'     '48'     '49'     '60'     '61'     '62'     '63'     '64'     '66' \\n    '67'     '68'     '69'     '70'     '71'     '72'     '73'     '74'     '76'     '77' \\n    '78'     '79'     '80'     '81'     '82'     '83'     '84'     '86'     '87'     '88' \\n    '89'     '90'     '91'     '92'     '93'     '94'     '96'     '97'     '98'     '99' \\n    '100'    '101'    '102'    '103'    '104'    '106'    '107'    '108'    '109'    '110'\\n    '111'    '112'    '113'    '114'    '116'    '117'    '118'    '119'    '120'    '121']]\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 may notice that this is simply the sorted list of positive numbers which do not contain the digit 5 in their decimal representation.\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\u003eYour function should convert a positive decimal number N into its \\\"missing-5\\\" notation. 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[ dec2missing5(20)]]\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\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\u003e'22'\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (the 20th positive number in missing-5 notation), and\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[ dec2missing5(100)]]\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\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\u003e'121'\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (the 100th positive number in missing-5 notation)\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\u003eGood luck!\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\u003eSmall print\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e: Your function may output a number, a char array, or a string; whatever you find simpler (e.g. in the example above, valid outputs are 121, '121', or \\\"121\\\"). Input numbers in testsuite are always relatively low valued positive integers (\u0026lt;10,000)\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\"},{\"partUri\":\"/media/image1.JPEG\",\"contentType\":\"image/JPEG\",\"content\":\"data:image/JPEG;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCADqASMDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD3+iiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAoopCwA5IAoAKK5fXPH2g6GXjmuxLcp/wAsIRubPoew/EivP9U+MGpTsV02yht0/vSkux/AYA/WsKmIpw3Z6eEyfGYrWnDTu9D2fcB1IH41G08SDLSIB7kV8333jHxFqP8Ax8avc4z0jbyx/wCO4rGlmlnk3zSPI/Tc7EmuZ4+P2Ue5S4Rq2vVqJfj/AJH1C2r6epwb2AH0Mg/xpyanZSn5LqFvo4NfLFFT9ff8pv8A6ow/5/fh/wAE+sBIh6Mp/GnDB6V8sWup6hZEfZb65gHYRysv8jXR6f8AEnxNYYBvVuUH8M6A/qMH9auOPg/iVjkrcJ4mKvSmpfgfQlFeX6R8YbOXbHqllJAe8kR3r+XUfrXf6XrenazbibT7uOdD3U8j6jqPxrqhWhP4WeDisuxOFf76DX5GlRRRWpxBRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAJRSH1Nee+OPiLFoofTtLZJr88O/VYfr6t7fn6GJ1IwV5HThcJVxVRU6SuzpPEfi3S/DNuHvJsytny4U+Z3/DsPc8V434i+Imta6zxRymytCeIoW5I/2m6n8MCuYuLi51G8aaeSSe5lblmO5mPpXoPhT4V3N+q3etl7aA4K26n52/3j/D9Ov0rzZVquIfLDRH2lLLsBlFNVcW+af9bI8/srC61G4W3sreSeZuixrk13Wj/CTV75RJqM8dip/gx5jY/A4/WvXtL0TTtGtxBp9pHAg67Ryfqep/GtGt6eBitZ6nmYzinEVPdw65V+JwVh8J/D9oo+0ie7YdTJIRn8FxXQ23g/w9a4MOkWgI6MYVJ/PGa3KOldUaUI7I8Crj8TWf7ybfzKS6Rp8YwlnAB7IBUc2haXcD97p9tJ/vRKf6Vo0VXKuxh7ap/MzmLz4feGbxCH0qGPPeIbD/47iuX1P4O2Eu59Ov5rds5CSDzFH8j+pr0+is5UKct0ddDNMZQd4VGfOus/D/xBoqtLJafaIB/y0t/n/MdR+VYFlf3WnXK3FlcSQTDo0bYNfVBAYYIBrlPEfgDRvEAaRovs12ek8XBz7joa5KmBtrTZ9HhOKOdezxsLp9V/kcf4Y+LLhhbeIFBHAW5jX/0JR/T8q9VtrqG9t0nt5VkicZVkOQRXzr4l8Har4ZlP2mLzbUnCXEY+U/X+6frS+FvGGoeFrnMDebaMcyW7HAb3Hofepp4qVN8lU1xuQ4fF0/rGXtenT/gH0hRWRoPiGw8RWC3VjLuHG5DwyH0IrX5r0k01dHxdSnKnJwmrNC0UUUyAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAEo6UVyXjrxYnhnRz5RBvpwVgQ9vVj7D/CplJQXMzbD0J16ipU1dsw/iN47GlxvpGly/wCnOP3sin/Uj/4o/p+VeP2dndanfR2trE89xK2FUckn1/8Ar01VudQvcKHnuZ5M4HLOxP8AMmvevA3guHwzp/mzhZNQmUebJj7o/ur7fzx9K8tKWKqXex93UnQyHCKMdakv6+4h8GfD+z8PQpd3SrcakRkyEcR57L/j1rt8YHFFFenCEYKyPhcTiauJqOpVd2xaKKKswCiiigAooooAKKKKACiikJAGTQBBd2tveWzwXMSSwuMMrrkEe9fOnjLT9J0zxDNa6ROZIU++vURv3UHvj9Old58QviEYPN0XRpv3vK3Fyh+56qp/vep7fXp5PFFJPMkMMbSSOQqooyWJ6ACvLxlWMnyRV2fdcNYCvQi8TVlyxfTv5s0/D3iG98Oaml5aOdvSSMn5XX3FfQ3h/XbPxDpUV9aOCrcMvdG7g+9eF6/4F1Tw9o9tqFyA6yDEyoM+SSeAT39PrxzTPBfiqbwxrCuWLWUxCzx57f3h7ipw9WVGXJU2N82wFDNKLxOFacl26+R9GUVDb3EV1bxzwuHjdQyspyCD3qavWPz9pp2YtFFFAgooooAKKKKACiiigAooooAKKKKACiiigAooooAguriO0tpLiZwkcalmY9AAOtfNvinX5vEeuz30hPlZ2wL/AHUHT8e59zXqHxa182WkRaTA+Jbw5kweRGOv5nA/OvLvCuhv4h8Q21gAfLJ3zEdkHX/D6kV5uMqOc1Sifa8OYWGGoTx9b5eh6J8K/CQjhGv3kf7xwRaqw+6vQt9T0Ht9a9VFRW8EdrbxwRKEjRQqqBwAKlrupU1Tgoo+Wx+MnjK8q0+v5C0UUVocYUUUUAFFfI/xQ8Yay/xJ1xLLWL63tobjyFiguXRV2KFPAPqprkP+Es8R/wDQwar/AOBsn+NAH3PRXwx/wlniP/oYNV/8DZP8aP8AhLPEf/Qwar/4Gyf40Afc9FfDH/CWeJP+hg1X/wADJP8A4qvT/gRr2r6h8QZYb7Vb65hFjI2ye4d1zuTnBNAH0sSAMk15X8RPiCbdpdF0eUrN924uFP3P9lT6+p7fXpL8QfiCLMSaRpEubn7s0yn/AFfsPf8AlXkKJLcTqkatJLI2AByWJrz8Vibe5Dc+wyLIlK2KxS91bJ/mxIopJ5UiijZ5HIVUUZJJ7CvcfAPgKPQIV1DUEV9TccDqIQew9/U/gOOrPAPgBNEjXUdSQPqDj5VPIhHoPf3r0GqwuG5ffnuY59nnt39Xw79xbvv/AMAr3tpDfWkttcRrJFIpVlYZBBr5x8WeHpfDWuzWTAmFvngc/wASE/zHSvpauM+I/hsa54eeaGMNd2gMkRA5I7r+IH8q0xVH2kLrdHFkGZPB4lRk/clo/wDM574T+J2lifQ7uTLxjfbEn+Huv4dfx9q9U618s6VqM2k6pb30BxJC4b6juK+nNOvYdR0+3vIG3RTRh1PsRmowdXnhyvdG/EuAWHxHtYfDP8y3RRRXafNhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABTScAn0paztcvhpuiXt6ekMLP+QpN2VyoRc5KK6ngnj3VjrHjC9kViYoW8iMegXg/+PZr0D4Q6MINJuNWkUb7l9kZ/wBheP8A0LP5V44S80ufmeR2+pYmvp3QdNTSNDs7BORDEq59Tjk/jXm4Re0quoz7fiCawmAp4SHX9DTooor0z4YKKKKACmSyJDE8sjBURSzE9gKfXMfETUf7J+Hev3YbawspEQ+jONin82FAHxlqV6+pareX8md9zM8zZ9WYn+tfR3w++EXhDVPAWj6hrOj/AGi/uYfOkl+0zJuDMSvCuB90r2r5qiieeaOKNSzyMFVfUnpX3dpNiul6NY6emNtrbxwLj0VQv9KAOM/4Ul8PP+he/wDJ24/+OUf8KS+Hn/Qvf+Ttx/8AHK9ApCcDJoA8/PwU+HgHPh//AMnbj/45XDeIIvCfgnUJoPB2ni21No2hnuluZZPLQ4JUbmIzwOe1dT8QfiCLMSaRpEn+kn5ZplP+r9h7/wAq8hRJbiZUjVpJZGwAOSxNefisVb3Ibn1+RZFz2xWKVorZf5+QIktxMsaK0ksjYAHJYmvbfAPgFNEjTUtRRX1Bx8q9RCPQe/vR4A8Apoka6jqSK+oOPlU8iEe3v716DTwuF5ffnuRnue+3vh8O7QW77/8AAFooorvPkwprqHQqehGKdRQB81eMdHGh+KL2zVdsO/zIhjA2NzgfQ5H4V6d8I9YN5oM+nSMC1nJ8o/2G5H65rK+MumhTp2pKACS0LnHJ7r/JvzrB+FWoG08XraliEu4mTGeMj5gf0b868uH7rE26M+8xD/tDJFUfxR/Tf8D3qiiivUPgwooooAKKKKACiiigAooooAKKKKACiiigBK434oXX2fwRdoDhpWRB/wB9DP6A12Vec/GKQp4atEBxvulBHqNrH+grKu7U5HflcFPG00+6PKvC9p9u8UaZb9muEJHqAcn9BX00owoHtXzz8N4/M8eab6JvY/8AfDD+tfQ9cuAX7tvzPb4tnfFxh2QtFFFd58qFFFFABXlX7QGo/Y/hqbUNg3t5FER6hcyfzQV6rXz9+0rqOZNA0xW6CW4df++VX+T0AeVfDnTf7V+I2gWm3cpvI5GHqqHe36Ka+tvEHjXw34VX/ic6vb20mMiEtukI/wBxct+OK+NvD+vXvhnVP7S01lS8WN44pWGTHuUqWHvgnFFlpeueJ7+VrOzvtTunO+V0RpWJPdm/qaAPo+f9obwbFLsit9XuB/eit0A/8ecGqfiD4vQ6xo4j0GC7tmmyGluFVWVf9kAnr614nZ+FLnT7101WERSxHmHcGIPvg8fSt4lUUkkAAdT0Arz8Vire5Dc+wyLIlO2JxS91bIkVZJpQqq0kjtgADJYn+Zr27wD4BTRYk1LUUV9QcfKp5EI9B7+9fOJ8ZXuk6zb3mjyLHJbPuV2QMGPQ5B7YJr6Z+G/xDsvHujGQKtvqduALq2ByB6Ov+yf06e5eFw3L789yM+zz218Nh37q3ff/AIB29FFFd58kFFFFABRRRQBxfxQtPtPgi7cAFoWRx/30Af0JrxfwtdNZ+KtLnUkYuUBI9Cdp/Q17542QSeDdWB7Wzn8lJr5zs5PKvreQcFJVbp6GvLxnu1YyPueG37XAVqL8/wAUfVanKg+1LTIjmJPoKfXqHw73CiiigQUUUUAFFFFABRRRQAUUUUAFFFFABXmvxkH/ABTlkfS7X/0B69Jrhfixbed4MeX/AJ4zI/67f/Zqxrr92z0cply42k/NHmvwzfb48sAf4g4/8cJ/pX0JXzZ4JuRa+M9KlP8Az22cf7QK/wBa+kgcgGufAP8AdteZ7HFkbYyMu8f1Y6iiiu4+WCiiigAr58+M3gXxh4q8bC90zRpLmwgtY4I5Fmj55Zj8pbPViOnavoOgnAoA+X/AnwO1fVNVMvim2m07TYCC0ZI8yc/3RjoPU/l6j0bxd4t0/wAL6f8A8I14VhhtTGNsjQKAsPqB6v6n+tW/iD8QhYiTSNIkzdn5Zp1P+q9h/tfy+tePKsk0oRVaSR2wABksT/M15+KxVvchufXZFkXtLYrFK0Vsu/m/IFWSaUKoaSR2wABksT/M17B4U+Flj/ZEjeIrVbia6jKmAniJT6EH73uOnb3t+APACaNGmp6nGG1Bh8iHkQA/+zep/Ae/olPC4Xl9+e5Oe577ZvD4Z2it33/4B8ffFD4eTeAdcRYnefS7sFrWZ/vDHVG/2hxz3B+oGN4G8UzeDvF1jq8TN5KPsuUX/lpCfvL/AFHuBX098Y9Fi1n4ZaruUGWzQXcTf3SnX/x3cPxr49rvPkz77ikSaJJY2DRuoZWHQg9DUlcd8LNRbU/hhoFw5yy23k5/65sY/wD2WuxoAKKKKACiiigDB8ZMF8HauT/z6SD81NfN9shkuYUXG5nUD86+gviNci28Dai3d1WMD/eYL/WvCNDgNzr+nQhS2+5jBAGeNwzXmY3WpGJ9zwwuTBVqr/qyPqCL/VJ9BT6anCKPanV6aPh3uFFFFAgooooAKKKKACiiigAooooAKKKKAErC8Y2Laj4S1K2QFnaFioA6kcj9QK3abIoaNlPcYqZK6aNKNR06kZrdO58qW072t1DcR43xOHX6g5FfUtjcx3ljBcRNujkRWUjuCOK+aPEOnNpPiC/sWUKIpmCgf3Tyv6EV7P8AC7VxqPhOO2ZgZbMmJh7dV/Tj8K87BS5Jygz7Tiekq+GpYqG3+Z3NFFFemfDhRRQTgUAMd1RSzEBQOSa8v8dfEm3jtvsHh+7jnklX57uFwyop/ukcE+/b69JPiF8QVsVl0fSZAbogrPOp/wBUPQf7X8vr08aJCKSSAAO/QCvPxWKt7kNz6/IsiVRLFYpWitl3/wCASKsk0oVQ0kjtgADJYn+Zr2vwB4ATRo01TU0Daiw+ROogB/8AZvU/gPfjfgrd6FquvX6SANqdsoe33nhk6Myj1Bxn2I9692p4XDcvvz3Iz7PHWbw2Hdord9/+AL0ooorvPkzmviDMkHw58SO5wDps6fiyFR+pr4lr6g/aA8URaZ4OTQo3H2vU3G5QeViRgxP4sFHv83pXzFHG8sqRRqWkchVUDJJPagD67+CSMnwk0Xd/EZ2A9vOevQaxPCOjHw94R0nSWA8y1tUSTHTfj5v/AB7NbdABRRRQAUUUHgUAeZ/GLUDDo1nYq2DcTbmHqqj/ABK/lXC/Day+2eOLLIykIaVsj0GB+pFTfE7Vxqfi+WFH3Q2iiFcHI3dWP1ycf8Brp/g5pPyX2qyL94iGM49OW/mPyry3+9xXofdwX1HInfef6/8AAPWR0ooor1D4QKKKKACiiigAooooAKKKKACiiigAooooAKKKKAPHfjBohjurXWIk+WQeTMR69VP5ZH4CsL4aa+NG8TJbyvttb3Ebegf+E/nkfjXtXiDSIdd0S60+f7sqYBx90jkH8Dg1803lnPp19NaXKGOeFyrD0Iry8SnSqqqj7rJKsMwwE8DU3W3p0+4+qgQRmiuQ+H/ikeItDVZm/wBNtsRzZ43ccN+P8811+RjJr0oSU48yPi8RQnh6rpTWqAkAZNeY/EL4gixEmkaRJm7PyzTqf9V7D/a/l9aPiD8QRYiTSNIk/wBLPyzTqf8AVew/2v5fWvHlWSaUKqtJI7YAAyWJ/ma4cVire5Dc+oyLIlUtisUrRWy7+b8gVZJpQqhpJHbAAGSxP8zV3x/4D8QaD4TtdWcbrd2xdxRjJgz90se49T0Bx1zXr3gDwAmjRpqepxhtQYfIh5EAP/s3qfwHv388EVzA8E8SSQyKUeN1yrKRggjuKeFwvL789xZ5nzrN4fDO0Fu+/wDwD4U0rVb3RdTg1LTrh7e7t33xyL2P9R6jvX0X4S/aB0TULWKDxLHJpt6Bhp40LwufXjLL9MEe9Zfjb9nxbieS+8JXCQ7iWawuGIUf7j9vo35143q3gbxTocjLqGgX8QXq4hLp/wB9rlf1rvPkj6yX4m+CHi8weJ9N2+hmwfyPNcf4p+PvhrSrd49DD6te9FIVo4VPqWIyfwHPqK+YhaXBfYIJS2cY2HNbmk+BPFWtyrHp/h+/kDcCRoSiD6u2FH50AUvEHiDUvFGtT6rqtwZrqY8noqr2VR2Ar1H4G/DqbVtXh8U6lCV06zfdaq6/6+UdGH+yp5z/AHsehre8E/s+LBLFfeLp0k2kMLC3bKn/AH37/Rfzr3W3t4bS3jt7eJIoI1CRxou1VUcAADoKAJqKKKACiiigBKxPFeuR6B4eur5iN6piNT/E54A/Pr7ZraJABPpXhHxM8UDW9YFhbOWs7NiMg8O/c/h0/P1rDEVVThfqeplGXyxuJUOi1focVma7uSfmkmlf6lmJ/wAa+k/CujLoPhyz08HLRpl29WPJP5k15L8LfDn9qa4dTnXNtYkFQRw0h6fl1+uK90HAxXPgadk6j6nscUY5TqRwsNo7+otFFFd58mFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFACV5d8U/CRuYf7dso8zRDFwij7yf3vqP5fSvUeaZJGsqFHGVIwQazq01Ui4s68DjJ4SvGtDofMvh3Xbrw7rEV/bc7flkjzw6nqP8+lejeLvifDJpMdtocjfaLiMGSXGDCD2/3v5VzvxB8Ev4fvDf2UZOmzN0X/AJYse30PY/h6Z4avIdSrQvTP0OGEwOauGM3a3X+foPVXmkCqGkkdsADksTXtXw/8AJo8aapqkYbUHGUQ8iAf1b1Pbp65pfC7wpp4s01yWWK5um4jVTkQe3+9/L+fqQrrwuGt+8lufP8AEGdubeEoaRWj8/L0F7cUUUV6B8iFFFFABRRRQAUUUUAFFFFACUUdB1rg/HPj+DQInsbBkm1FhgjORDx1Pv6ConNQXNI6MNhauJqKlSV2yt8SfGo0m0bSdPl/06ZcO6n/AFK/4nt+dePaXplzrGpQWFom6aVto9AO5PsBzURNzqF7n95cXM7+7M7E/qTXu3gDwWnhuwNzdKrajOP3hznYOyj+vv8AQV5iUsVUu/hR9xOVHIcHyR1qS/r7kdB4e0W30DRrfT7cfLGvzMRy7dyfxrVoor1UklZHwM5yqSc5O7YtFFFMkKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigCvd2kN7bSW1xEskUilWRhkEV4b42+H1z4elkvbBXn00/Me7Q+x9R7/n6n3mmSRpKhR1DKRgg1jWoRqxsz0stzOtgKnNB6dV3PmbQfEWo+HL0XNhNtz9+NuUkHoRXtvhfx/pXiNFiZha3p48iRhlv90965vxb8K4pvMvdBxFJyWtSfkb/dP8P06fSvKLuzutPuWt7uCS3nTqjqQfTP/wBevPUquGdnqj66dHL88hz03y1Px+fc+qc56UtfP+gfEnXNGKxzyfbrYY+SY/MB7N1/PNelaP8AE/w/qaYuJzYy5xtuPlB+jdMV208VTn1PmMbkWMwru48y7rU7alqtb3ttdxLLbzxyIejI4IP41YyD3roTPHaadmLRRRTEJRSFgOpH4msrU/Euj6OM32oQQnGQpYbjj0HU0m0tWXCnObtFXZrVBdXlvZQPPczJFEgyzu2AB715rrfxgtYkeLRrVp5OgmmG1B746n9K8y1nxFqniCfzdRu3lAOVjHCL9FHFclXGQhpHVnv4DhvFYh81VckfPf7j0Dxd8VTKJLLQMqudrXbDqP8AZB/mfy715nDBdalerFCklxdTvwBlmcnkn/69bHh3wdq3iWUfZIdlsDhriQYQfT1PsPxxXt3hjwZpnhi3HkR+ZdMMSXDj5m+noPYfrXNGnVxL5p6I9ytjcDktN0sOuaf9bv8AQxvA3w/h0CNb+/VZdSYcd1hHoPU+p/L372iivShCMFyxPicTiquKqOrVd2xaKKKs5wooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooASsvWPD+l67b+TqFnHMB0JGGX6Ecj8K1KKTSasyoTlCXNB2Z47rnwguYWMujXQmX/njPwR9GHB/IVwOpaDqujsVv7CeDH8TLlf++hx+tfUFNeNXGGUH6iuOpgqctVofR4TifF0Vy1Eprz3PlSC6uLV99vPLC3rG5U/pW3beOPE1pxFrFx/wPD/APoQNe53/gvw9qRZrnSrdnY5Louxj+Iwawrj4TeHJv8AVJcQf7kxP881j9UrR+GR6i4iy6uv39HX0TPN1+JniteuoqfrCn+FMl+I/iuUn/ialR6LCn/xNd8fg3pHbUL7/vpP/iafH8HdFQ5e8vn9i6D+S0ewxP8AMH9qZGtVS/8AJUeUXXiXXL0n7Rq14wPUCUgfkOKzVV5pNqhnkc9ByWNe/Wvwx8L2xDNYtKw/56SsR+WcV0NjommaauLKwt4Bjny4wufyoWCqS+OQpcTYSirYal+SPBtJ+HviLV9rLZG2iP8Ay0uTs/Tr+lekeH/hVpOnbJtSJv7gc7XGIwf93v8AjXoGABwKWumnhKcNdzw8bxBjMUuW/KuyI44khQJGgVVGAAMYFS0UV1Hht33CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//2Q==\"}]}"},{"id":44372,"title":"Polarisation","description":"You have n polarising filters stacked one on top of another, and you know each axis angle. How much light gets passed through the filter bank? For more information, see \u003chttps://en.wikipedia.org/wiki/Polarizer Polarizer (Wikipedia)\u003e.\r\n\r\n    \u003e\u003e n = [0, 90];\r\n    \u003e\u003e polarised([0, 90])\r\n\r\n    ans = 0","description_html":"\u003cp\u003eYou have n polarising filters stacked one on top of another, and you know each axis angle. How much light gets passed through the filter bank? For more information, see \u003ca href = \"https://en.wikipedia.org/wiki/Polarizer\"\u003ePolarizer (Wikipedia)\u003c/a\u003e.\u003c/p\u003e\u003cpre\u003e    \u0026gt;\u0026gt; n = [0, 90];\r\n    \u0026gt;\u0026gt; polarised([0, 90])\u003c/pre\u003e\u003cpre\u003e    ans = 0\u003c/pre\u003e","function_template":"function y = polarised(x)\r\n  y = max(x);\r\nend","test_suite":"%%\r\nx = 5;\r\ny_correct = 0.5;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = 180;\r\ny_correct = 0.5;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = 365;\r\ny_correct = 0.5;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = [91, 1];\r\ny_correct = 0;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\na = randi([-360, 360]);\r\nb = 90*(1+2*randi([-3, 3]));\r\nx = [a, a+b];\r\ny_correct = 0;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\na = randi([-360, 360]);\r\nb = 90*(1+2*randi([-3, 3]));\r\nx = [a, a+b];\r\ny_correct = 0;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = [0, 22.5];\r\ny_correct = 0.85355339059/2;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = [0, -45];\r\ny_correct = 0.25;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = [5, 140];\r\ny_correct = 0.25;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n%%\r\nx = 5 + (1:5)*22.5;\r\ny_correct = 0.53079004294/2;\r\nassert(abs(polarised(x)-y_correct) \u003c 1e-10)\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":10,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":269,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-10T21:58:52.000Z","updated_at":"2026-03-26T15:36:11.000Z","published_at":"2017-10-16T01:45: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\u003eYou have n polarising filters stacked one on top of another, and you know each axis angle. How much light gets passed through the filter bank? For more information, see\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/Polarizer\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePolarizer (Wikipedia)\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\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 n = [0, 90];\\n    \u003e\u003e polarised([0, 90])\\n\\n    ans = 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":44352,"title":"The Top 5 Primes","description":"This problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate \u003chttps://www.mathworks.com/matlabcentral/cody/contests/1?s_tid=Cody5YA_cody_home Cody's 5th birthday\u003e. \r\n\r\nIn this problem, let's find the top 5 greatest prime numbers along the first non-singleton dimension of an input array. \r\n\r\nExample \r\n\r\n* If the input is a vector, the output is a length-5 vector containing the top 5 prime numbers of the input sorted in descending order. Append NaNs as needed in the output if the number of primes is less than 5. \r\n\r\n  x = 1:10;\r\n  y = [7 5 3 2 NaN];\r\n\r\n* If the input is a m-by-n (m \u003e= 5) matrix, the output is a 5-by-n matrix containing the column-wise top 5 prime numbers of the input matrix sorted in descending order. Whenever there are less than 5 primes found in a specific column of the input, simply append NaNs as needed in the same column of the output. \r\n\r\n  % Input x is a matrix\r\n  x = [17     6     3\r\n       13     8    17\r\n        1     2     5\r\n        5     3     7\r\n        7    11     2\r\n       31     7     6];\r\n\r\n  % Output y\r\n  y = [31    11    17\r\n       17     7     7\r\n       13     3     5\r\n        7     2     3\r\n        5   NaN     2];\r\n\r\nPrevious problem in this series: \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44342-spot-the-first-occurrence-of-5 Spot the First Occurrence of 5\u003e","description_html":"\u003cp\u003eThis problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/contests/1?s_tid=Cody5YA_cody_home\"\u003eCody's 5th birthday\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eIn this problem, let's find the top 5 greatest prime numbers along the first non-singleton dimension of an input array.\u003c/p\u003e\u003cp\u003eExample\u003c/p\u003e\u003cul\u003e\u003cli\u003eIf the input is a vector, the output is a length-5 vector containing the top 5 prime numbers of the input sorted in descending order. Append NaNs as needed in the output if the number of primes is less than 5.\u003c/li\u003e\u003c/ul\u003e\u003cpre class=\"language-matlab\"\u003ex = 1:10;\r\ny = [7 5 3 2 NaN];\r\n\u003c/pre\u003e\u003cul\u003e\u003cli\u003eIf the input is a m-by-n (m \u0026gt;= 5) matrix, the output is a 5-by-n matrix containing the column-wise top 5 prime numbers of the input matrix sorted in descending order. Whenever there are less than 5 primes found in a specific column of the input, simply append NaNs as needed in the same column of the output.\u003c/li\u003e\u003c/ul\u003e\u003cpre class=\"language-matlab\"\u003e% Input x is a matrix\r\nx = [17     6     3\r\n     13     8    17\r\n      1     2     5\r\n      5     3     7\r\n      7    11     2\r\n     31     7     6];\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003e% Output y\r\ny = [31    11    17\r\n     17     7     7\r\n     13     3     5\r\n      7     2     3\r\n      5   NaN     2];\r\n\u003c/pre\u003e\u003cp\u003ePrevious problem in this series: \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44342-spot-the-first-occurrence-of-5\"\u003eSpot the First Occurrence of 5\u003c/a\u003e\u003c/p\u003e","function_template":"function y = top5primes(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','top5primes.m')\r\n\r\n%%\r\nx = 1:10;\r\ny_correct = [7 5 3 2 NaN];\r\nassert(isequaln(top5primes(x),y_correct))\r\n\r\n%%\r\nx = (1:2:100).';\r\ny_correct = [97 89 83 79 73].';\r\nassert(isequaln(top5primes(x),y_correct))\r\n\r\n%%\r\nx = [17     6     3\r\n     13     8    17\r\n      1     2     5\r\n      5     3     7\r\n      7    11     2\r\n     31     7     6];\r\ny_correct = [31    11    17\r\n             17     7     7\r\n             13     3     5\r\n              7     2     3\r\n              5   NaN     2];\r\nassert(isequaln(top5primes(x),y_correct))\r\n\r\n%%\r\nx = interp1(magic(30).',1:5).';\r\ny_correct = [877   733   863   719   881\r\n             829   701   751   173   769\r\n             797   139    59   157    29\r\n              89   107    43   109    13\r\n              73   NaN    11    61   NaN];\r\nassert(isequaln(top5primes(x),y_correct))\r\n\r\n%%\r\nrng(0);\r\nx = reshape(randperm(200,180),36,5);\r\ny_correct = [163   181   173   197   193\r\n              71   179   149   191   157\r\n              23   167   113   139   151\r\n              19   131   101    83   137\r\n             NaN   109    67    73   127];\r\nassert(isequaln(top5primes(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":7,"comments_count":1,"created_by":12569,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":340,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-01T01:52:48.000Z","updated_at":"2026-03-18T12:39:29.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\u003eThis problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate\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/contests/1?s_tid=Cody5YA_cody_home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody's 5th birthday\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\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn this problem, let's find the top 5 greatest prime numbers along the first non-singleton dimension of an input array.\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=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the input is a vector, the output is a length-5 vector containing the top 5 prime numbers of the input sorted in descending order. Append NaNs as needed in the output if the number of primes is less than 5.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[x = 1:10;\\ny = [7 5 3 2 NaN];]]\u003e\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the input is a m-by-n (m \u0026gt;= 5) matrix, the output is a 5-by-n matrix containing the column-wise top 5 prime numbers of the input matrix sorted in descending order. Whenever there are less than 5 primes found in a specific column of the input, simply append NaNs as needed in the same column of the output.\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 x is a matrix\\nx = [17     6     3\\n     13     8    17\\n      1     2     5\\n      5     3     7\\n      7    11     2\\n     31     7     6];\\n\\n% Output y\\ny = [31    11    17\\n     17     7     7\\n     13     3     5\\n      7     2     3\\n      5   NaN     2];]]\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 problem in this series:\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/44342-spot-the-first-occurrence-of-5\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSpot the First Occurrence of 5\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":44350,"title":"Breaking Out of the Matrix","description":"Do you want to take the Red Pill, or the Blue Pill?\r\n\r\nIf you take the Blue Pill, you will simply pass along to the next problem, not knowing what Cody has in store for you.\r\n\r\nIf you take the Red Pill, you will be asked to write a MATLAB function that will Break a Matrix. The inputs to the function will be a matrix M, along with a number of rows (R) and columns (C). You goal is to break the larger 2-D matrix up into a 3-D matrix comprised of enough RxC matrices so that you can recreate the 2-D matrix. When creating your 3-D matrix, go down the columns first, and then across the rows.  Increment only one column (or one row) at a time.  Do not go C columns down at each step.\r\n\r\nFor example, R=2 and C=3, and M is as follows:\r\n\r\n M=[1 4 7 10\r\n    2 5 8 11\r\n    3 6 9 12]\r\n\r\nThis means that your output should be a 2x3x4 matrix:\r\n\r\n X(:,:,1) =\r\n     1     4     7\r\n     2     5     8\r\n X(:,:,2) =\r\n     2     5     8\r\n     3     6     9\r\n X(:,:,3) =\r\n     4     7    10\r\n     5     8    11\r\n X(:,:,4) =\r\n     5     8    11\r\n     6     9    12\r\n\r\nYou can assume that R and C will always be less than or equal to the appropriate dimension of the original matrix. Good luck!\r\n","description_html":"\u003cp\u003eDo you want to take the Red Pill, or the Blue Pill?\u003c/p\u003e\u003cp\u003eIf you take the Blue Pill, you will simply pass along to the next problem, not knowing what Cody has in store for you.\u003c/p\u003e\u003cp\u003eIf you take the Red Pill, you will be asked to write a MATLAB function that will Break a Matrix. The inputs to the function will be a matrix M, along with a number of rows (R) and columns (C). You goal is to break the larger 2-D matrix up into a 3-D matrix comprised of enough RxC matrices so that you can recreate the 2-D matrix. When creating your 3-D matrix, go down the columns first, and then across the rows.  Increment only one column (or one row) at a time.  Do not go C columns down at each step.\u003c/p\u003e\u003cp\u003eFor example, R=2 and C=3, and M is as follows:\u003c/p\u003e\u003cpre\u003e M=[1 4 7 10\r\n    2 5 8 11\r\n    3 6 9 12]\u003c/pre\u003e\u003cp\u003eThis means that your output should be a 2x3x4 matrix:\u003c/p\u003e\u003cpre\u003e X(:,:,1) =\r\n     1     4     7\r\n     2     5     8\r\n X(:,:,2) =\r\n     2     5     8\r\n     3     6     9\r\n X(:,:,3) =\r\n     4     7    10\r\n     5     8    11\r\n X(:,:,4) =\r\n     5     8    11\r\n     6     9    12\u003c/pre\u003e\u003cp\u003eYou can assume that R and C will always be less than or equal to the appropriate dimension of the original matrix. Good luck!\u003c/p\u003e","function_template":"function y = BreakTheMatrix(M,R,C)\r\n  y = x;\r\nend","test_suite":"%%\r\nM=[1 4 7 10;\r\n2 5 8 11;\r\n3 6 9 12];\r\nR=2;C=3;\r\nX(:,:,1) =[1 4 7 ; 2 5 8];\r\nX(:,:,2) =[2 5 8 ; 3 6 9];\r\nX(:,:,3) =[4 7 10 ; 5 8 11];\r\nX(:,:,4) =[5 8 11 ; 6 9 12];\r\nassert(isequal(BreakTheMatrix(M,R,C),X))\r\n%%\r\nx=1:ceil(35+25*rand());r=1;c=1;\r\nM=BreakTheMatrix(x,r,c);\r\nassert(all(arrayfun(@(y) (M(:,:,y)==y),1:numel(x))))\r\n%%\r\nx=eye(7);r=2;c=2;\r\nM=BreakTheMatrix(x,r,c);\r\nids=[1 8 15 22 29 36];\r\nurs=ids(1:5)+1;\r\nlls=urs+5;\r\nz=setxor(1:size(M,3),[ids urs lls]);\r\na1=arrayfun(@(a) isequal(M(:,:,a),eye(2)),ids);\r\na2=arrayfun(@(a) isequal(M(:,:,a),[0 1 ; 0 0]),urs);\r\na3=arrayfun(@(a) isequal(M(:,:,a),[0 0 ; 1 0]),lls);\r\na4=arrayfun(@(a) isequal(M(:,:,a),zeros(2)),z);\r\nassert(all([a1 a2 a3 a4]))\r\n%%\r\nu=ceil(10*rand())+4;\r\nx=magic(u);r=u;c=u;\r\nM=BreakTheMatrix(x,r,c);\r\nassert(isequal(M,x))\r\n%%\r\ntemp=ceil(8*rand)+3;\r\nx=ones(temp);r=2;c=2;\r\nM=BreakTheMatrix(x,r,c);\r\nassert(size(M,3)==(temp-1)^2);\r\nassert(all(arrayfun(@(a) isequal(M(:,:,a),ones(2)),1:size(M,3))))\r\n%%\r\nx=eye(7);r=7;c=7;\r\nassert(isequal(x,BreakTheMatrix(x,r,c)))","published":true,"deleted":false,"likes_count":9,"comments_count":14,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":379,"test_suite_updated_at":"2017-10-31T19:02:59.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-28T14:36:19.000Z","updated_at":"2026-03-31T15:14:35.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\u003eDo you want to take the Red Pill, or the Blue Pill?\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 you take the Blue Pill, you will simply pass along to the next problem, not knowing what Cody has in store for you.\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 you take the Red Pill, you will be asked to write a MATLAB function that will Break a Matrix. The inputs to the function will be a matrix M, along with a number of rows (R) and columns (C). You goal is to break the larger 2-D matrix up into a 3-D matrix comprised of enough RxC matrices so that you can recreate the 2-D matrix. When creating your 3-D matrix, go down the columns first, and then across the rows. Increment only one column (or one row) at a time. Do not go C columns down at each step.\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, R=2 and C=3, and M is as follows:\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[ M=[1 4 7 10\\n    2 5 8 11\\n    3 6 9 12]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis means that your output should be a 2x3x4 matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ X(:,:,1) =\\n     1     4     7\\n     2     5     8\\n X(:,:,2) =\\n     2     5     8\\n     3     6     9\\n X(:,:,3) =\\n     4     7    10\\n     5     8    11\\n X(:,:,4) =\\n     5     8    11\\n     6     9    12]]\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 can assume that R and C will always be less than or equal to the appropriate dimension of the original matrix. 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":44306,"title":"Is it really a 5?","description":"A number containing at least one five will be passed to your function, which must return true or false depending upon whether the English spelling of the number may contain \"five\" anywhere. For example:\r\n\r\n n = 5; return true since it is spelled \"five\"\r\n n = 15; return false since it is spelled \"fifteen\" and does not contain the four-letter string \"five\"\r\n\r\nThis criterion applies to any common spelling of the number. For example, 1500 can be written fifteen hundred. But, it can also be written one thousand five hundred. So, 1500 would be considered to contain a \"five\" for this problem.\r\n\r\nSee the test suite for more examples.","description_html":"\u003cp\u003eA number containing at least one five will be passed to your function, which must return true or false depending upon whether the English spelling of the number may contain \"five\" anywhere. For example:\u003c/p\u003e\u003cpre\u003e n = 5; return true since it is spelled \"five\"\r\n n = 15; return false since it is spelled \"fifteen\" and does not contain the four-letter string \"five\"\u003c/pre\u003e\u003cp\u003eThis criterion applies to any common spelling of the number. For example, 1500 can be written fifteen hundred. But, it can also be written one thousand five hundred. So, 1500 would be considered to contain a \"five\" for this problem.\u003c/p\u003e\u003cp\u003eSee the test suite for more examples.\u003c/p\u003e","function_template":"function tf = is_it_really_a_5(n)\r\n tf = 0;\r\nend","test_suite":"%%\r\nn = 5;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 15;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 25;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 35;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 52;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 55;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 59;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 85;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 105;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 115;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 125;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 250;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 500;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 555;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 5000; %5,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 15000; %15,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 55555; %55,555\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50000; %50,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 55000; %55,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50500; %50,500\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50050; %50,050\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 50005; %50,005\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 500000; %500,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 5000000; %5,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 15000000; %15,000,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 50000000; %50,000,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 105000000; %105,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50050050; %50,050,050\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 50000005; %50,000,005\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50000015; %50,000,015\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 500000000; %500,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 5000000000; %5,000,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50000000000; %50,000,000,000\r\nassert(isequal(is_it_really_a_5(n),0))","published":true,"deleted":false,"likes_count":7,"comments_count":1,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":316,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-08T22:07:48.000Z","updated_at":"2026-03-18T13:28:44.000Z","published_at":"2017-10-16T01:45: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\u003eA number containing at least one five will be passed to your function, which must return true or false depending upon whether the English spelling of the number may contain \\\"five\\\" anywhere. 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[ n = 5; return true since it is spelled \\\"five\\\"\\n n = 15; return false since it is spelled \\\"fifteen\\\" and does not contain the four-letter string \\\"five\\\"]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis criterion applies to any common spelling of the number. For example, 1500 can be written fifteen hundred. But, it can also be written one thousand five hundred. So, 1500 would be considered to contain a \\\"five\\\" for this 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:r\u003e\u003cw:t\u003eSee the test suite for more examples.\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":44309,"title":"Pi Digit Probability","description":"Assume that the next digit of pi constant is determined by the historical digit distribution. What is the probability of next digit (N) being (n). \r\n\r\nFor example if we consider the first 100 digits of pi, we will see that the digit '3' is occured 12 times. So the probability of the being '3' the 101th digit will be 12/100 = 0.12.\r\n\r\nRound the results to four decimals.","description_html":"\u003cp\u003eAssume that the next digit of pi constant is determined by the historical digit distribution. What is the probability of next digit (N) being (n).\u003c/p\u003e\u003cp\u003eFor example if we consider the first 100 digits of pi, we will see that the digit '3' is occured 12 times. So the probability of the being '3' the 101th digit will be 12/100 = 0.12.\u003c/p\u003e\u003cp\u003eRound the results to four decimals.\u003c/p\u003e","function_template":"function y = pidigit(N,n)\r\n  y = x;\r\nend","test_suite":"%%\r\nN = 101;\r\nn = 3;\r\ny_correct = 0.1200;\r\nassert(abs(pidigit(N,n)-y_correct)\u003c0.0001)\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\\d\\.\\+\\-\\*\\/]+','match')))) % modified from the comment of Alfonso on https://www.mathworks.com/matlabcentral/cody/problems/44343\r\n\r\n%%\r\nN = 201;\r\nn = 6;\r\ny_correct = 0.0750;\r\nassert(abs(pidigit(N,n)-y_correct)\u003c0.0001)\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\\d\\.\\+\\-\\*\\/]+','match'))))\r\n\r\n%%\r\nN = 202;\r\nn = 6;\r\ny_correct = 0.0796;\r\nassert(abs(pidigit(N,n)-y_correct)\u003c0.0001)\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\\d\\.\\+\\-\\*\\/]+','match'))))\r\n\r\n%%\r\nN = 203;\r\nn = 6;\r\ny_correct = 0.0792;\r\nassert(abs(pidigit(N,n)-y_correct)\u003c0.0001)\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\\d\\.\\+\\-\\*\\/]+','match'))))\r\n\r\n%%\r\nN = 1001;\r\nn = 9;\r\ny_correct = 0.1050;\r\nassert(abs(pidigit(N,n)-y_correct)\u003c0.0001)\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\\d\\.\\+\\-\\*\\/]+','match'))))\r\n","published":true,"deleted":false,"likes_count":18,"comments_count":27,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":852,"test_suite_updated_at":"2017-10-21T07:59:48.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-11T06:41:07.000Z","updated_at":"2026-04-04T18:34:50.000Z","published_at":"2017-10-16T01:45: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\u003eAssume that the next digit of pi constant is determined by the historical digit distribution. What is the probability of next digit (N) being (n).\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 if we consider the first 100 digits of pi, we will see that the digit '3' is occured 12 times. So the probability of the being '3' the 101th digit will be 12/100 = 0.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\u003eRound the results to four decimals.\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":44380,"title":"ASCII Birthday Cake","description":"Given an age and a name, give draw an ASCII birthday cake. For example, given the name \"CODY\" and the age 5, return a string with the following (no trailing spaces)\r\n\r\n   6 6 6 6 6\r\n   | | | | |\r\n __|_|_|_|_|__\r\n{             }\r\n{             }\r\n{    CODY     }\r\n{             }\r\n{_____________}\r\n\r\nThis uses the \u003chttps://www.mathworks.com/help/matlab/ref/string.html string datatype\u003e, not a char array.","description_html":"\u003cp\u003eGiven an age and a name, give draw an ASCII birthday cake. For example, given the name \"CODY\" and the age 5, return a string with the following (no trailing spaces)\u003c/p\u003e\u003cpre\u003e   6 6 6 6 6\r\n   | | | | |\r\n __|_|_|_|_|__\r\n{             }\r\n{             }\r\n{    CODY     }\r\n{             }\r\n{_____________}\u003c/pre\u003e\u003cp\u003eThis uses the \u003ca href = \"https://www.mathworks.com/help/matlab/ref/string.html\"\u003estring datatype\u003c/a\u003e, not a char array.\u003c/p\u003e","function_template":"function s = birthday_cake(name, n)\r\n    s = \"\";\r\n    s = s + \"name\";\r\nend","test_suite":"%%\r\ncake = string(char([32 32 32 54 32 54 32 54 32 54 32 54 10 32 32 32 124 32 124 32 124 32 124 32 124 10 32 95 95 124 95 124 95 124 95 124 95 124 95 95 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 67 79 68 89 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 95 95 95 95 95 95 95 95 95 95 95 95 95 125 10]));\r\nfprintf('%s\\n', cake);\r\nassert(isequal(birthday_cake(\"CODY\", 5), cake));\r\n\r\n%%\r\ncake = string(char([32 32 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 10 32 32 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 10 32 95 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 95 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 64 98 109 116 114 97 110 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 125 10]));\r\nfprintf('%s\\n', cake);\r\nassert(isequal(birthday_cake(\"@bmtran\", 29), cake));\r\n\r\n%%\r\ncake = string(char([32 32 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 10 32 32 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 10 32 95 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 95 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 77 65 84 76 65 66 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 125 10]));\r\nfprintf('%s\\n', cake);\r\nassert(isequal(birthday_cake(\"MATLAB\", 33), cake));\r\n\r\n%%\r\ncake = string(char([32 32 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 10 32 32 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 10 32 95 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 95 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 67 108 101 118 101 32 77 111 108 101 114 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 125 10]));\r\nfprintf('%s\\n', cake);\r\nassert(isequal(birthday_cake(\"Cleve Moler\", 78), cake));\r\n\r\n%%\r\ncake = string(char([32 32 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 10 32 32 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 10 32 95 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 95 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 65 108 97 110 32 84 117 114 105 110 103 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 125 10]));\r\nfprintf('%s\\n', cake);\r\nassert(isequal(birthday_cake(\"Alan Turing\", 105), cake));\r\n\r\n%%\r\ncake = string(char([32 32 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 32 54 10 32 32 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 32 124 10 32 95 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 124 95 95 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 83 105 114 32 73 115 97 97 99 32 78 101 119 116 111 110 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 125 10 123 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 125 10]));\r\nfprintf('%s\\n', cake);\r\nassert(isequal(birthday_cake(\"Sir Isaac Newton\", 375), cake));","published":true,"deleted":false,"likes_count":10,"comments_count":4,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":227,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-12T19:48:13.000Z","updated_at":"2026-03-25T05:11:31.000Z","published_at":"2017-10-16T01:45: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\u003eGiven an age and a name, give draw an ASCII birthday cake. For example, given the name \\\"CODY\\\" and the age 5, return a string with the following (no trailing spaces)\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[   6 6 6 6 6\\n   | | | | |\\n __|_|_|_|_|__\\n{             }\\n{             }\\n{    CODY     }\\n{             }\\n{_____________}]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis uses the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/help/matlab/ref/string.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estring datatype\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, not a char array.\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":44345,"title":"MATLAB Counter","description":"Write a function f = counter(x0,b) to construct a counter handle f that counts with an initial value x0 and a step size b. \r\n\r\nE.g.,\r\n\r\n  \u003e\u003e f = counter(0,1)  % Initialize a counter f() with initial_count = 0 and step_size = 1\r\n  \u003e\u003e f()\r\n  ans =\r\n       0\r\n  \u003e\u003e f()\r\n  ans =\r\n       1\r\n  \u003e\u003e f()\r\n  ans =\r\n       2\r\n\r\n\r\n","description_html":"\u003cp\u003eWrite a function f = counter(x0,b) to construct a counter handle f that counts with an initial value x0 and a step size b.\u003c/p\u003e\u003cp\u003eE.g.,\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u0026gt;\u0026gt; f = counter(0,1)  % Initialize a counter f() with initial_count = 0 and step_size = 1\r\n\u0026gt;\u0026gt; f()\r\nans =\r\n     0\r\n\u0026gt;\u0026gt; f()\r\nans =\r\n     1\r\n\u0026gt;\u0026gt; f()\r\nans =\r\n     2\r\n\u003c/pre\u003e","function_template":"function y = counter(x,b)\r\n  y = x;\r\nend","test_suite":"%%\r\nassessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','counter.m')\r\n\r\n%%\r\nf = counter(0,1);\r\nassert(isequal(f(),0))\r\nassert(isequal(f(),1))\r\nassert(isequal(2,f()))\r\nassert(isequal(3,f()))\r\n\r\n%%\r\nf = counter(1,0);\r\nassert(isequal(f(),1))\r\nassert(isequal(f(),1))\r\nassert(isequal(1,f()))\r\nassert(isequal(1,f()))\r\n\r\n%%\r\nf = counter(10,2);\r\nassert(isequal(f(),10))\r\nassert(isequal(f(),12))\r\nassert(isequal(14,f()))\r\nassert(isequal(16,f()))\r\n\r\n%%\r\nf = counter(0,5);\r\ny_correct = [0, 5, 10, 15, 20, 55];\r\nassert(isequal([f() f() f() f() f() f()+f()],y_correct))\r\n\r\n%%\r\nx0 = randi(10);\r\nb = randi(10);\r\nf = counter(x0,b);\r\ny_correct = x0 + (0:1000)*b;\r\nassert(isequal(arrayfun(@(n)f(),0:1000),y_correct))","published":true,"deleted":false,"likes_count":23,"comments_count":9,"created_by":12569,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":299,"test_suite_updated_at":"2017-10-17T00:19:49.000Z","rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-24T01:58:21.000Z","updated_at":"2026-04-03T06:36:03.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\u003eWrite a function f = counter(x0,b) to construct a counter handle f that counts with an initial value x0 and a step size b.\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\u003eE.g.,\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 f = counter(0,1)  % Initialize a counter f() with initial_count = 0 and step_size = 1\\n\u003e\u003e f()\\nans =\\n     0\\n\u003e\u003e f()\\nans =\\n     1\\n\u003e\u003e f()\\nans =\\n     2]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"group:Cody5:Easy","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":"group:Cody5:Easy","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"group":[["group:Cody5:Easy","","","Cody5:Easy",""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fac45c058c0\u003e":["Cody5:Easy"],"#\u003cMathWorks::Search::Field:0x00007fac45c05820\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fac45c04f60\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fac45c05b40\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fac45c05aa0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fac45c05a00\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fac45c05960\u003e":"group:Cody5:Easy"},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fac45c05960\u003e":"group:Cody5:Easy"},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007fac45c058c0\u003e":["Cody5:Easy"]}},"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":"group:Cody5:Easy","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"group":[["group:Cody5:Easy","","","Cody5:Easy",""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fac45c058c0\u003e":["Cody5:Easy"],"#\u003cMathWorks::Search::Field:0x00007fac45c05820\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fac45c04f60\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fac45c05b40\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fac45c05aa0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fac45c05a00\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fac45c05960\u003e":"group:Cody5:Easy"},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fac45c05960\u003e":"group:Cody5:Easy"},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007fac45c058c0\u003e":["Cody5:Easy"]}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":369,"difficulty_rating":"easy-medium"},{"id":361,"difficulty_rating":"easy-medium"},{"id":2736,"difficulty_rating":"easy-medium"},{"id":44315,"difficulty_rating":"easy-medium"},{"id":44370,"difficulty_rating":"easy-medium"},{"id":44314,"difficulty_rating":"easy-medium"},{"id":564,"difficulty_rating":"easy-medium"},{"id":44369,"difficulty_rating":"easy-medium"},{"id":44358,"difficulty_rating":"easy-medium"},{"id":44363,"difficulty_rating":"easy-medium"},{"id":44384,"difficulty_rating":"easy-medium"},{"id":44385,"difficulty_rating":"easy-medium"},{"id":44319,"difficulty_rating":"easy-medium"},{"id":44360,"difficulty_rating":"easy-medium"},{"id":44368,"difficulty_rating":"easy-medium"},{"id":44342,"difficulty_rating":"easy-medium"},{"id":44349,"difficulty_rating":"easy-medium"},{"id":44338,"difficulty_rating":"easy-medium"},{"id":44334,"difficulty_rating":"easy-medium"},{"id":44321,"difficulty_rating":"easy-medium"},{"id":44339,"difficulty_rating":"easy-medium"},{"id":44305,"difficulty_rating":"easy-medium"},{"id":44307,"difficulty_rating":"easy-medium"},{"id":44375,"difficulty_rating":"easy-medium"},{"id":44372,"difficulty_rating":"easy-medium"},{"id":44352,"difficulty_rating":"medium"},{"id":44350,"difficulty_rating":"medium"},{"id":44306,"difficulty_rating":"medium"},{"id":44309,"difficulty_rating":"medium"},{"id":44380,"difficulty_rating":"medium"},{"id":44345,"difficulty_rating":"medium-hard"}]}}