{"group":{"group":{"id":45,"name":"Number Manipulation II","lockable":false,"created_at":"2018-05-23T13:38:33.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Manipulate more numbers from one form to another.","is_default":false,"created_by":26769,"badge_id":60,"featured":false,"trending":false,"solution_count_in_trending_period":79,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":421,"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":"{\"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\u003eManipulate more numbers from one form to another.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}","description_html":"\u003cdiv style = \"text-align: start; line-height: normal; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; perspective-origin: 289.5px 10.5px; transform-origin: 289.5px 10.5px; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; perspective-origin: 266.5px 10.5px; transform-origin: 266.5px 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; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eManipulate more numbers from one form to another.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","published_at":"2019-05-08T20:15:26.000Z"},"current_player":null},"problems":[{"id":2193,"title":"Mysterious digits operation (easy)","description":"What is this digit operation?\r\n\r\n 0    -\u003e 0\r\n 1    -\u003e 9\r\n 121  -\u003e 9\r\n 44   -\u003e 6\r\n 15   -\u003e 5\r\n 1243 -\u003e 7\r\n ...","description_html":"\u003cp\u003eWhat is this digit operation?\u003c/p\u003e\u003cpre\u003e 0    -\u0026gt; 0\r\n 1    -\u0026gt; 9\r\n 121  -\u0026gt; 9\r\n 44   -\u0026gt; 6\r\n 15   -\u0026gt; 5\r\n 1243 -\u0026gt; 7\r\n ...\u003c/pre\u003e","function_template":"function y = what_digits(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 0;\r\ny_correct = 0;\r\nassert(isequal(what_digits(x),y_correct))\r\n%%\r\nx = 1;\r\ny_correct = 9;\r\nassert(isequal(what_digits(x),y_correct))\r\n%%\r\nx = 44;\r\ny_correct = 6;\r\nassert(isequal(what_digits(x),y_correct))\r\n%%\r\nx = 15;\r\ny_correct = 5;\r\nassert(isequal(what_digits(x),y_correct))\r\n%%\r\nx = 1243;\r\ny_correct = 7;\r\nassert(isequal(what_digits(x),y_correct))\r\n%%\r\nx = 10;\r\ny_correct = 0;\r\nassert(isequal(what_digits(x),y_correct))\r\n%%\r\nx = 1000;\r\ny_correct = 0;\r\nassert(isequal(what_digits(x),y_correct))\r\n%%\r\nx = 1e5;\r\ny_correct = 0;\r\nassert(isequal(what_digits(x),y_correct))\r\n%%\r\nx = 1e5+1;\r\ny_correct = 9;\r\nassert(isequal(what_digits(x),y_correct))\r\n%%\r\nx = 1e5-1;\r\ny_correct = 1;\r\nassert(isequal(what_digits(x),y_correct))","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":5390,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":319,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-02-18T11:03:52.000Z","updated_at":"2026-03-16T00:47:39.000Z","published_at":"2014-02-18T11:13:41.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eWhat is this digit operation?\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    -\u003e 0\\n 1    -\u003e 9\\n 121  -\u003e 9\\n 44   -\u003e 6\\n 15   -\u003e 5\\n 1243 -\u003e 7\\n ...]]\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":3079,"title":"Big numbers, repeated least significant digits","description":"This problem builds off of Problem 3077\r\nGiven an integer x which contains d digits, find the value of (minimum) n (n \u003e 1) such that the last d digits of x^n is equal to x. If the last d digits will never equal x, return inf.\r\nExample 1:\r\nx = 2; (therefore d = 1)\r\n2^2 = 4, 2^3 = 8, 2^4 = 16, 2^5 = 32\r\nn = 5;\r\nExample 2:\r\nx = 10; (therefore d = 2)\r\n10^2 = 100, 10^3 = 1000, etc\r\nn = inf;","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: 285.6px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 142.8px; transform-origin: 407px 142.8px; 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: 79.5px 8px; transform-origin: 79.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis problem builds off 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 = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 3077\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 384px 8px; transform-origin: 384px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"perspective-origin: 186.5px 8px; transform-origin: 186.5px 8px; \"\u003eGiven an integer x which contains d digits, find the value of \u003c/span\u003e\u003cspan style=\"border-block-end-style: solid; border-block-end-width: 1px; border-bottom-style: solid; border-bottom-width: 1px; perspective-origin: 2.5px 8.5px; transform-origin: 2.5px 8.5px; \"\u003e(\u003c/span\u003e\u003cspan style=\"perspective-origin: 27.5px 8px; transform-origin: 27.5px 8px; \"\u003eminimum\u003c/span\u003e\u003cspan style=\"border-block-end-style: solid; border-block-end-width: 1px; border-bottom-style: solid; border-bottom-width: 1px; perspective-origin: 2.5px 8.5px; transform-origin: 2.5px 8.5px; \"\u003e)\u003c/span\u003e\u003cspan style=\"perspective-origin: 165px 8px; transform-origin: 165px 8px; \"\u003e n (n \u0026gt; 1) such that the last d digits of x^n is equal to x. If the last d digits will never equal x, return inf.\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: 34.5px 8px; transform-origin: 34.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample 1:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 61.3px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 391px 30.65px; transform-origin: 391px 30.65px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 71px 8px; transform-origin: 71px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ex = 2; (therefore d = 1)\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 110px 8px; transform-origin: 110px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e2^2 = 4, 2^3 = 8, 2^4 = 16, 2^5 = 32\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 18px 8px; transform-origin: 18px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003en = 5;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\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: 34.5px 8px; transform-origin: 34.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample 2:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 61.3px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 391px 30.65px; transform-origin: 391px 30.65px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 75px 8px; transform-origin: 75px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ex = 10; (therefore d = 2)\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 90.5px 8px; transform-origin: 90.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e10^2 = 100, 10^3 = 1000, etc\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 21.5px 8px; transform-origin: 21.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003en = inf;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function n = bigNumRepeat(x)\r\n  n = x;\r\nend","test_suite":"%%\r\nx = 2;\r\nn_correct = 5;\r\nassert(isequal(bigNumRepeat(x),n_correct))\r\n\r\n%%\r\nx = 10;\r\nn_correct = inf;\r\nassert(isequal(bigNumRepeat(x),n_correct))\r\n\r\n%%\r\nx = [3 7 33 51 67 192 329 678 680 4731 10016 10081 35197 35199 51783 517839 517842];\r\nn_correct = [5 5 21 3 21 101 51 inf inf 501 626 626 5001 251 2501 12501 inf];\r\nfor ii = 1:numel(x)\r\n   assert(isequal(bigNumRepeat(x(ii)),n_correct(ii)))\r\nend","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":3096,"edited_by":223089,"edited_at":"2022-07-27T07:11:05.000Z","deleted_by":null,"deleted_at":null,"solvers_count":86,"test_suite_updated_at":"2015-03-16T15:16:23.000Z","rescore_all_solutions":false,"group_id":45,"created_at":"2015-03-13T18:49:43.000Z","updated_at":"2026-02-15T15:42:06.000Z","published_at":"2015-03-13T18:49:43.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem builds off 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=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3077\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an integer x which contains d digits, find the value of (minimum) n (n \u0026gt; 1) such that the last d digits of x^n is equal to x. If the last d digits will never equal x, return inf.\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 1:\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ex = 2; (therefore d = 1)\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2^2 = 4, 2^3 = 8, 2^4 = 16, 2^5 = 32\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en = 5;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample 2:\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ex = 10; (therefore d = 2)\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e10^2 = 100, 10^3 = 1000, etc\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en = inf;\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":2270,"title":"Bit calculation","description":"Give me the count of numbers from 1 to n having their last two bits as 0.\r\n\r\nFor example\r\n\r\nfunction y = ret_count(4)\r\n\r\n  y = x;\r\n\r\nend\r\n\r\nHere 4 means you have to check the numbers between 1 to 4.\r\n\r\n\r\nSo the answer will be 1 as binary value of 4 is 00000100.\r\n\r\nHere n in the function is the number of numbers to be checked starting from 1.","description_html":"\u003cp\u003eGive me the count of numbers from 1 to n having their last two bits as 0.\u003c/p\u003e\u003cp\u003eFor example\u003c/p\u003e\u003cp\u003efunction y = ret_count(4)\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ey = x;\r\n\u003c/pre\u003e\u003cp\u003eend\u003c/p\u003e\u003cp\u003eHere 4 means you have to check the numbers between 1 to 4.\u003c/p\u003e\u003cp\u003eSo the answer will be 1 as binary value of 4 is 00000100.\u003c/p\u003e\u003cp\u003eHere n in the function is the number of numbers to be checked starting from 1.\u003c/p\u003e","function_template":"function y = ret_count(n)\r\n  y = x;\r\nend","test_suite":"%%\r\nn = 1;\r\ny_correct = 0;\r\nassert(isequal(ret_count(n),y_correct))\r\n\r\n\r\n%%\r\nn = 4;\r\ny_correct = 1;\r\nassert(isequal(ret_count(n),y_correct))\r\n\r\n%%\r\nn = 72;\r\ny_correct = 18;\r\nassert(isequal(ret_count(n),y_correct))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":22816,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":243,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-04-08T07:33:36.000Z","updated_at":"2026-03-10T17:18:51.000Z","published_at":"2014-04-08T07:33:36.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGive me the count of numbers from 1 to n having their last two bits as 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\u003eFor example\u003c/w:t\u003e\u003c/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\u003efunction y = ret_count(4)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[y = x;]]\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\u003eend\u003c/w:t\u003e\u003c/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\u003eHere 4 means you have to check the numbers between 1 to 4.\u003c/w:t\u003e\u003c/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\u003eSo the answer will be 1 as binary value of 4 is 00000100.\u003c/w:t\u003e\u003c/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\u003eHere n in the function is the number of numbers to be checked starting from 1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2431,"title":"Power Times (of the day)","description":"Many times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\r\n\r\n - equation written forward, \"=\" doesn't coincide with \":\" --\u003e add 1 to output (e.g., 2:38)\r\n\r\n - equation written forward, \"=\" does coincide with \":\" -- \u003e add 100 to output (e.g., 8:23)\r\n\r\n - equation written backward, \"=\" doesn't coincide with \":\" --\u003e add 10 to output (e.g., 3:28)\r\n\r\n - equation written backward, \"=\" does coincide with \":\" --\u003e add 1000 to output (e.g., 9:23)\r\n\r\nExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=1).\r\n\r\nThis problem is related to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day  Problem 2432\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day Problem 2433\u003e.","description_html":"\u003cp\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\u003c/p\u003e\u003cpre\u003e - equation written forward, \"=\" doesn't coincide with \":\" --\u0026gt; add 1 to output (e.g., 2:38)\u003c/pre\u003e\u003cpre\u003e - equation written forward, \"=\" does coincide with \":\" -- \u0026gt; add 100 to output (e.g., 8:23)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" doesn't coincide with \":\" --\u0026gt; add 10 to output (e.g., 3:28)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" does coincide with \":\" --\u0026gt; add 1000 to output (e.g., 9:23)\u003c/pre\u003e\u003cp\u003eExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=1).\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\"\u003eProblem 2432\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\"\u003eProblem 2433\u003c/a\u003e.\u003c/p\u003e","function_template":"function out = power_time(time)\r\n out = 0;\r\nend","test_suite":"%%\r\ntime = '2:38';\r\ny_correct = 1;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '8:23';\r\ny_correct = 100;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '3:28';\r\ny_correct = 10;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '9:23';\r\ny_correct = 1000;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '7:22';\r\ny_correct = 0;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:31';\r\ny_correct = 1001;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '4:22';\r\ny_correct = 1100;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:02';\r\ny_correct = 1000;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '4:12';\r\ny_correct = 0;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '5:15';\r\ny_correct = 1001;\r\nassert(isequal(power_time(time),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":8,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":96,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T18:00:06.000Z","updated_at":"2026-01-15T14:21:57.000Z","published_at":"2014-07-15T18:00:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ - equation written forward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 1 to output (e.g., 2:38)\\n\\n - equation written forward, \\\"=\\\" does coincide with \\\":\\\" -- \u003e add 100 to output (e.g., 8:23)\\n\\n - equation written backward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 10 to output (e.g., 3:28)\\n\\n - equation written backward, \\\"=\\\" does coincide with \\\":\\\" --\u003e add 1000 to output (e.g., 9:23)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=1).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2432\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2433\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2432,"title":"Equation Times (of the day)","description":"Many times throughout the day can represent mathematical equations. In this problem, we focus on times that include the four basic operations (+,-,*,/). For example, 6:17 can be written as 6=1+7. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is an equation time, and if so, which basic operation it uses. There are also four types of equations that are categorized here, and a given time can fit more than one category:\r\n\r\n - equation written forward, \"=\" doesn't coincide with \":\" --\u003e add 1 to output (e.g., 2:35, 2+3=5)\r\n\r\n - equation written forward, \"=\" does coincide with \":\" -- \u003e add 100 to output (e.g., 2:53, 2=5-3)\r\n\r\n - equation written backward, \"=\" doesn't coincide with \":\" --\u003e add 10 to output (e.g., 3:26, 6=2*3)\r\n\r\n - equation written backward, \"=\" does coincide with \":\" --\u003e add 1000 to output (e.g., 4:28, 8/2=4)\r\n\r\nNote that some of these combinations are tied to each other due to the commutative nature of + and * and the inverse relation of +,- and **,/. The output should be a 4x2 matrix with 0s or 1s in the first column dependent on whether each operation (+,-,*,/) is applicable to a given time and the totals in the second column. Examples include: \r\n\r\n4:22 | out = [1 1100; 1 1; 1 1100; 1 1]; since 4=2+2, 2+2=4; 4-2=2; 4=2*2, 2*2=4; 4/2=2.\r\n\r\n5:15 | out = [0 0; 0 0; 1 1111; 1 1001]; since 5*1=5, 5=1*5, 5*1=5, 5=1*5; 5/1=5, 5/1=5.\r\n\r\nThis problem is related to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day Problem 2431\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day Problem 2433\u003e.","description_html":"\u003cp\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that include the four basic operations (+,-,*,/). For example, 6:17 can be written as 6=1+7. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is an equation time, and if so, which basic operation it uses. There are also four types of equations that are categorized here, and a given time can fit more than one category:\u003c/p\u003e\u003cpre\u003e - equation written forward, \"=\" doesn't coincide with \":\" --\u0026gt; add 1 to output (e.g., 2:35, 2+3=5)\u003c/pre\u003e\u003cpre\u003e - equation written forward, \"=\" does coincide with \":\" -- \u0026gt; add 100 to output (e.g., 2:53, 2=5-3)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" doesn't coincide with \":\" --\u0026gt; add 10 to output (e.g., 3:26, 6=2*3)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" does coincide with \":\" --\u0026gt; add 1000 to output (e.g., 4:28, 8/2=4)\u003c/pre\u003e\u003cp\u003eNote that some of these combinations are tied to each other due to the commutative nature of + and * and the inverse relation of +,- and ,/. The output should be a 4x2 matrix with 0s or 1s in the first column dependent on whether each operation (+,-,*,/) is applicable to a given time and the totals in the second column. Examples include:\u003c/p\u003e\u003cp\u003e4:22 | out = [1 1100; 1 1; 1 1100; 1 1]; since 4=2+2, 2+2=4; 4-2=2; 4=2*2, 2*2=4; 4/2=2.\u003c/p\u003e\u003cp\u003e5:15 | out = [0 0; 0 0; 1 1111; 1 1001]; since 5*1=5, 5=1*5, 5*1=5, 5=1*5; 5/1=5, 5/1=5.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\"\u003eProblem 2431\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\"\u003eProblem 2433\u003c/a\u003e.\u003c/p\u003e","function_template":"function out = equation_time(time)\r\n out = 0;\r\nend","test_suite":"%%\r\ntime = '4:22';\r\ny_correct = [1 1100;\r\n\t1 1;\r\n\t1 1100;\r\n\t1 1];\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '2:38';\r\ny_correct = zeros(4,2);\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '5:15';\r\ny_correct = [0 0;\r\n\t0 0;\r\n\t1 1111;\r\n \t1 1001];\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:23';\r\ny_correct = [1 11;\r\n\t1 1000;\r\n\t0 0;\r\n \t0 0];\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:02';\r\ny_correct = zeros(4,2);\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:11';\r\ny_correct = [0 0;\r\n\t0 0;\r\n\t1 1111;\r\n \t1 1111];\r\nassert(isequal(equation_time(time),y_correct))\r\n\r\n%%\r\ntime = '2:11';\r\ny_correct = [1 1100;\r\n\t1 1;\r\n\t0 0;\r\n \t0 0];\r\nassert(isequal(equation_time(time),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":79,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T18:39:02.000Z","updated_at":"2026-01-15T14:29:10.000Z","published_at":"2014-07-15T18:39:02.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that include the four basic operations (+,-,*,/). For example, 6:17 can be written as 6=1+7. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is an equation time, and if so, which basic operation it uses. There are also four types of equations that are categorized here, and a given time can fit more than one category:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ - equation written forward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 1 to output (e.g., 2:35, 2+3=5)\\n\\n - equation written forward, \\\"=\\\" does coincide with \\\":\\\" -- \u003e add 100 to output (e.g., 2:53, 2=5-3)\\n\\n - equation written backward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 10 to output (e.g., 3:26, 6=2*3)\\n\\n - equation written backward, \\\"=\\\" does coincide with \\\":\\\" --\u003e add 1000 to output (e.g., 4:28, 8/2=4)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNote that some of these combinations are tied to each other due to the commutative nature of + and * and the inverse relation of +,- and ,/. The output should be a 4x2 matrix with 0s or 1s in the first column dependent on whether each operation (+,-,*,/) is applicable to a given time and the totals in the second column. Examples include:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e4:22 | out = [1 1100; 1 1; 1 1100; 1 1]; since 4=2+2, 2+2=4; 4-2=2; 4=2*2, 2*2=4; 4/2=2.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e5:15 | out = [0 0; 0 0; 1 1111; 1 1001]; since 5*1=5, 5=1*5, 5*1=5, 5=1*5; 5/1=5, 5/1=5.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2431\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2433\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2433,"title":"Consecutive Equation Times (of the day)","description":"Many times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\r\n\r\nFor example, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that range.\r\n\r\nThis problem is related to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day Problem 2431\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day  Problem 2432\u003e.","description_html":"\u003cp\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\u003c/p\u003e\u003cp\u003eFor example, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that range.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\"\u003eProblem 2431\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\"\u003eProblem 2432\u003c/a\u003e.\u003c/p\u003e","function_template":"function [t_s,num] = equation_times_run(times)\r\n t_s = '0:00';\r\n num = 0;\r\nend","test_suite":"%%\r\ntimes = {'1:00' '1:59'};\r\ny_correct = ['1:00' 24];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'2:07' '2:29'};\r\ny_correct = ['2:11' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'3:03' '4:04'};\r\ny_correct = ['3:11' 4];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'5:55' '7:11'};\r\ny_correct = ['6:15' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'7:17' '9:00'};\r\ny_correct = ['8:17' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'5:55' '9:00'};\r\ny_correct = ['6:15' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'1:00' '9:59'};\r\ny_correct = ['1:00' 24];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T19:39:50.000Z","updated_at":"2026-01-15T14:27:21.000Z","published_at":"2014-07-15T19:39:50.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that range.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2431\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2432\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2600,"title":"Find out the Gray Code for a Given Binary Number","description":"Find out \u003chttp://en.wikipedia.org/wiki/Gray_code Gray Code\u003e for a given binary number\r\n\r\nExample \r\n\r\n Binary input 1000 \r\n Gray number output 1100. \r\n\r\n","description_html":"\u003cp\u003eFind out \u003ca href = \"http://en.wikipedia.org/wiki/Gray_code\"\u003eGray Code\u003c/a\u003e for a given binary number\u003c/p\u003e\u003cp\u003eExample\u003c/p\u003e\u003cpre\u003e Binary input 1000 \r\n Gray number output 1100. \u003c/pre\u003e","function_template":"function y = binary2gray(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1000;\r\ny_correct = 1100;\r\nassert(isequal(binary2gray(x),y_correct))\r\n%%\r\nx = 0010;\r\ny_correct = 0011;\r\nassert(isequal(binary2gray(x),y_correct))\r\n%%\r\nx = 0011;\r\ny_correct = 0010;\r\nassert(isequal(binary2gray(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":1,"created_by":27760,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":118,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-09-22T14:19:57.000Z","updated_at":"2026-01-15T14:31:40.000Z","published_at":"2014-09-22T14:19:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eFind out\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Gray_code\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGray Code\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e for a given binary number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Binary input 1000 \\n Gray number output 1100.]]\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":2627,"title":"Convert to Binary Coded Decimal","description":"Convert from decimal representation to \u003chttp://en.wikipedia.org/wiki/Binary-coded_decimal Binary Code Decimal\u003e (or BCD) representation.\r\n\r\nExamples\r\n\r\nSo 5 becomes '0101'\r\n\r\n12 is '00010010' (because 1 is '0001' and 2 is '0010')\r\n\r\n156 is '000101010110'\r\n\r\n","description_html":"\u003cp\u003eConvert from decimal representation to \u003ca href = \"http://en.wikipedia.org/wiki/Binary-coded_decimal\"\u003eBinary Code Decimal\u003c/a\u003e (or BCD) representation.\u003c/p\u003e\u003cp\u003eExamples\u003c/p\u003e\u003cp\u003eSo 5 becomes '0101'\u003c/p\u003e\u003cp\u003e12 is '00010010' (because 1 is '0001' and 2 is '0010')\u003c/p\u003e\u003cp\u003e156 is '000101010110'\u003c/p\u003e","function_template":"function y = bin2bcd(x)\r\n  y = 'x';\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = '0001';\r\nassert(isequal(bin2bcd(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = '0101';\r\nassert(isequal(bin2bcd(x),y_correct))\r\n%%\r\nx = 12;\r\ny_correct = '00010010';\r\nassert(isequal(bin2bcd(x),y_correct))\r\n%%\r\nx = 156;\r\ny_correct = '000101010110';\r\nassert(isequal(bin2bcd(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":0,"created_by":27760,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":152,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-10-13T13:38:17.000Z","updated_at":"2026-03-11T18:20:21.000Z","published_at":"2014-10-13T13:38:17.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\u003eConvert from decimal representation to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Binary-coded_decimal\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eBinary Code Decimal\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (or BCD) 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\u003eExamples\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSo 5 becomes '0101'\u003c/w:t\u003e\u003c/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\u003e12 is '00010010' (because 1 is '0001' and 2 is '0010')\u003c/w:t\u003e\u003c/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\u003e156 is '000101010110'\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":2735,"title":"Binary Neighbourhood","description":"Given a natural number reorder its binary form to create another number, closest to the given one.\r\n\r\nExamples:\r\n\r\n* 1 gives 2, ( 1(dec) \u003e 1 \u003e 01 \u003e 10 \u003e 2(dec) )\r\n* 2 gives 1, ( 2(dec) \u003e 10 \u003e 01 \u003e 1(dec) )\r\n* 5 gives 6, ( 5(dec) \u003e 101 \u003e 110 \u003e 6(dec) )","description_html":"\u003cp\u003eGiven a natural number reorder its binary form to create another number, closest to the given one.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cul\u003e\u003cli\u003e1 gives 2, ( 1(dec) \u0026gt; 1 \u0026gt; 01 \u0026gt; 10 \u0026gt; 2(dec) )\u003c/li\u003e\u003cli\u003e2 gives 1, ( 2(dec) \u0026gt; 10 \u0026gt; 01 \u0026gt; 1(dec) )\u003c/li\u003e\u003cli\u003e5 gives 6, ( 5(dec) \u0026gt; 101 \u0026gt; 110 \u0026gt; 6(dec) )\u003c/li\u003e\u003c/ul\u003e","function_template":"function y = binary_neighbour(x)\r\n  bin = dec2bin(x);\r\n  y = bin2dec(bin);\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 2;\r\nassert(isequal(binary_neighbour(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct = 1;\r\nassert(isequal(binary_neighbour(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = 6;\r\nassert(isequal(binary_neighbour(x),y_correct))\r\n%%\r\nx = 3;\r\ny_correct = 5;\r\nassert(isequal(binary_neighbour(x),y_correct))\r\n%%\r\nx = 4;\r\ny_correct = 2;\r\nassert(isequal(binary_neighbour(x),y_correct))\r\n%%\r\nx = 16;\r\ny_correct = 8;\r\nassert(isequal(binary_neighbour(x),y_correct))\r\n%%\r\nx = 17;\r\ny_correct = 18;\r\nassert(isequal(binary_neighbour(x),y_correct))\r\n%%\r\nx = 11;\r\ny_correct = 13;\r\nassert(isequal(binary_neighbour(x),y_correct))\r\n%%\r\nx = 15;\r\ny_correct = 23;\r\nassert(isequal(binary_neighbour(x),y_correct))\r\n%%\r\nx = 92;\r\ny_correct = 90;\r\nassert(isequal(binary_neighbour(x),y_correct))\r\n%%\r\n% DISABLED\r\n% ________'FAIR'_SCORING_SYSTEM______________\r\n%\r\n% This section scores for usage of ans\r\n% and strings, which are common methods \r\n% to reduce cody size of solution.\r\n% Here, strings are threated like vectors.\r\n% Please do not hack it, as this problem\r\n% is not mentioned to be a hacking problem.\r\n% \r\n  try\r\n% \r\n  size_old = feval(@evalin,'caller','score');\r\n%\r\n  all_nodes = mtree('binary_neighbour_disabled.m','-file');\r\n  str_nodes = mtfind(all_nodes,'Kind','STRING');\r\n   eq_nodes = mtfind(all_nodes,'Kind','EQUALS');\r\nprint_nodes = mtfind(all_nodes,'Kind','PRINT');\r\n expr_nodes = mtfind(all_nodes,'Kind','EXPR');\r\n%\r\n       size = count(all_nodes)           ...\r\n              +sum(str_nodes.nodesize-1) ...\r\n              +2*(count(expr_nodes)      ...\r\n                  +count(print_nodes)    ...\r\n                  -count(eq_nodes));\r\n%\r\n  feval(@assignin,'caller','score',size);\r\n%\r\n  fprintf('Size in standard cody scoring is %i.\\n',size_old);\r\n  fprintf('Here it is %i.\\n',size);\r\n  end\r\n%\r\n%_________RESULT_____________________________","published":true,"deleted":false,"likes_count":3,"comments_count":3,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":99,"test_suite_updated_at":"2015-01-19T22:59:13.000Z","rescore_all_solutions":false,"group_id":45,"created_at":"2014-12-07T21:51:56.000Z","updated_at":"2026-01-15T14:34:19.000Z","published_at":"2015-01-19T12:34:52.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a natural number reorder its binary form to create another number, closest to the given one.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1 gives 2, ( 1(dec) \u0026gt; 1 \u0026gt; 01 \u0026gt; 10 \u0026gt; 2(dec) )\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\u003e2 gives 1, ( 2(dec) \u0026gt; 10 \u0026gt; 01 \u0026gt; 1(dec) )\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\u003e5 gives 6, ( 5(dec) \u0026gt; 101 \u0026gt; 110 \u0026gt; 6(dec) )\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":2848,"title":"Digital Neighbourhood","description":"Given a natural number reorder its digits to create another number, closest to the given one.\r\n\r\nExamples:\r\n\r\n* 123 gives 132,\r\n* 1 gives 10,\r\n* 1099 gives 991 ","description_html":"\u003cp\u003eGiven a natural number reorder its digits to create another number, closest to the given one.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cul\u003e\u003cli\u003e123 gives 132,\u003c/li\u003e\u003cli\u003e1 gives 10,\u003c/li\u003e\u003cli\u003e1099 gives 991\u003c/li\u003e\u003c/ul\u003e","function_template":"function y = find_neighbour(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 132;\r\ny_correct = 123;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 182;\r\ny_correct = 218;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 172;\r\ny_correct = [127; 217];\r\n% there are two such numbers, one of them is enough, but you can return both\r\ny = sort(find_neighbour(x));\r\nfprintf('%d founded.\\n',y)\r\ny = y(:);\r\nassert(any(y_correct==y))\r\n%%\r\nx = 1;\r\ny_correct = 10;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 10;\r\ny_correct = 1;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 100;\r\ny_correct = 10;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 99;\r\ny_correct = 909;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 199;\r\ny_correct = 919;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 1099;\r\ny_correct = 991;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 123455;\r\ny_correct = 123545;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 56565656;\r\ny_correct = 56565665;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 8761199;\r\ny_correct = 8761919;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 820199;\r\ny_correct = 819920;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 991;\r\ny_correct = 919;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 911;\r\ny_correct = 1019;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 7001;\r\ny_correct = 7010;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 1192999;\r\ny_correct = 1199299;\r\nassert(isequal(find_neighbour(x),y_correct))\r\n%%\r\nx = 8713222;\r\ny_correct = 8712322;\r\nassert(isequal(find_neighbour(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":79,"test_suite_updated_at":"2015-01-19T23:07:40.000Z","rescore_all_solutions":false,"group_id":45,"created_at":"2015-01-19T12:06:43.000Z","updated_at":"2026-01-15T14:43:05.000Z","published_at":"2015-01-19T12:07:58.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a natural number reorder its digits to create another number, closest to the given one.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e123 gives 132,\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\u003e1 gives 10,\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\u003e1099 gives 991\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":2869,"title":"There are 10 types of people in the world","description":"Those who know binary, and those who don't.\r\n\r\nThe number 2015 is a palindrome in binary (11111011111 to be exact)  Given a year (in base 10 notation) calculate how many more years it will be until the next year that is a binary palindrome.  For example, if you are given the year 1881 (palindrome in base 10! :-), the function should output 30, as the next year that is a binary palindrome is 1911.  You can assume all years are positive integers.\r\n\r\nGood luck!!kcul dooG","description_html":"\u003cp\u003eThose who know binary, and those who don't.\u003c/p\u003e\u003cp\u003eThe number 2015 is a palindrome in binary (11111011111 to be exact)  Given a year (in base 10 notation) calculate how many more years it will be until the next year that is a binary palindrome.  For example, if you are given the year 1881 (palindrome in base 10! :-), the function should output 30, as the next year that is a binary palindrome is 1911.  You can assume all years are positive integers.\u003c/p\u003e\u003cp\u003eGood luck!!kcul dooG\u003c/p\u003e","function_template":"function y = yearraey(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1881;y_correct = 30;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 2014;y_correct = 1;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 2015;y_correct = 0;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 606;y_correct = 27;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 6006;y_correct = 71;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 60006;y_correct = 369;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nk=zeros(1,15);\r\nfor n=1:15\r\n    y=2^n+2;\r\n    k(n)=yearraey(y);\r\nend\r\ny_correct=[1 1 5 3 11 7 23 15 47 31 95 63 191 127 383];\r\nassert(isequal(k,y_correct))","published":true,"deleted":false,"likes_count":32,"comments_count":4,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1288,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2015-01-21T19:54:31.000Z","updated_at":"2026-04-04T09:48:51.000Z","published_at":"2015-01-21T19:54:31.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\u003eThose who know binary, and those who don't.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe number 2015 is a palindrome in binary (11111011111 to be exact) Given a year (in base 10 notation) calculate how many more years it will be until the next year that is a binary palindrome. For example, if you are given the year 1881 (palindrome in base 10! :-), the function should output 30, as the next year that is a binary palindrome is 1911. You can assume all years are positive integers.\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\u003eGood luck!!kcul dooG\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":3077,"title":"Big numbers, least significant digits","description":"Given two numbers, x and n, return the last d digits of the number that is calculated by x^n. In all cases, d will be the number of digits in x. Keep in mind that the n values in the examples are small, however the test suite values may be much larger. Also, any leading zeros in the final answer should be discounted (If d = 2 and the number ends in 01, just report 1) \r\n\r\nExample #1:\r\n\r\n* x = 23 (therefore d = 2)\r\n* n = 2;\r\n* 23^2 = 529;\r\n* function will return 29\r\n\r\nExample #2:\r\n\r\n* x = 123; (therefore d = 3)\r\n* n = 3;\r\n* 123^3 = 1860867;\r\n* function should return 867","description_html":"\u003cp\u003eGiven two numbers, x and n, return the last d digits of the number that is calculated by x^n. In all cases, d will be the number of digits in x. Keep in mind that the n values in the examples are small, however the test suite values may be much larger. Also, any leading zeros in the final answer should be discounted (If d = 2 and the number ends in 01, just report 1)\u003c/p\u003e\u003cp\u003eExample #1:\u003c/p\u003e\u003cul\u003e\u003cli\u003ex = 23 (therefore d = 2)\u003c/li\u003e\u003cli\u003en = 2;\u003c/li\u003e\u003cli\u003e23^2 = 529;\u003c/li\u003e\u003cli\u003efunction will return 29\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eExample #2:\u003c/p\u003e\u003cul\u003e\u003cli\u003ex = 123; (therefore d = 3)\u003c/li\u003e\u003cli\u003en = 3;\u003c/li\u003e\u003cli\u003e123^3 = 1860867;\u003c/li\u003e\u003cli\u003efunction should return 867\u003c/li\u003e\u003c/ul\u003e","function_template":"function y = findLeastInBig(x,n)\r\n  y = x + n;\r\nend","test_suite":"%%\r\nx = 23;\r\nn = 2\r\ny_correct = 29;\r\nassert(isequal(findLeastInBig(x,n),y_correct))\r\n\r\n%%\r\nx = 123;\r\nn = 3;\r\ny_correct = 867;\r\nassert(isequal(findLeastInBig(x,n),y_correct))\r\n\r\n%%\r\nx = 9876;\r\nn = 1024;\r\ny_correct = 1376;\r\nassert(isequal(findLeastInBig(x,n),y_correct))\r\n\r\n%%\r\nx = 1234;\r\nn = 45;\r\ny_correct = 7824;\r\nassert(isequal(findLeastInBig(x,n),y_correct))\r\n\r\n%%\r\nx = 201;\r\nn = 100;\r\ny_correct = 1;\r\nassert(isequal(findLeastInBig(x,n),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":3096,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":106,"test_suite_updated_at":"2015-03-13T13:02:34.000Z","rescore_all_solutions":false,"group_id":45,"created_at":"2015-03-12T15:02:27.000Z","updated_at":"2026-01-15T14:46:42.000Z","published_at":"2015-03-12T15:03:19.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two numbers, x and n, return the last d digits of the number that is calculated by x^n. In all cases, d will be the number of digits in x. Keep in mind that the n values in the examples are small, however the test suite values may be much larger. Also, any leading zeros in the final answer should be discounted (If d = 2 and the number ends in 01, just report 1)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample #1:\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\u003ex = 23 (therefore d = 2)\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\u003en = 2;\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\u003e23^2 = 529;\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\u003efunction will return 29\u003c/w:t\u003e\u003c/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 #2:\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\u003ex = 123; (therefore d = 3)\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\u003en = 3;\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\u003e123^3 = 1860867;\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\u003efunction should return 867\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":3079,"title":"Big numbers, repeated least significant digits","description":"This problem builds off of Problem 3077\r\nGiven an integer x which contains d digits, find the value of (minimum) n (n \u003e 1) such that the last d digits of x^n is equal to x. If the last d digits will never equal x, return inf.\r\nExample 1:\r\nx = 2; (therefore d = 1)\r\n2^2 = 4, 2^3 = 8, 2^4 = 16, 2^5 = 32\r\nn = 5;\r\nExample 2:\r\nx = 10; (therefore d = 2)\r\n10^2 = 100, 10^3 = 1000, etc\r\nn = inf;","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: 285.6px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 142.8px; transform-origin: 407px 142.8px; 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: 79.5px 8px; transform-origin: 79.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis problem builds off 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 = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 3077\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 384px 8px; transform-origin: 384px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"perspective-origin: 186.5px 8px; transform-origin: 186.5px 8px; \"\u003eGiven an integer x which contains d digits, find the value of \u003c/span\u003e\u003cspan style=\"border-block-end-style: solid; border-block-end-width: 1px; border-bottom-style: solid; border-bottom-width: 1px; perspective-origin: 2.5px 8.5px; transform-origin: 2.5px 8.5px; \"\u003e(\u003c/span\u003e\u003cspan style=\"perspective-origin: 27.5px 8px; transform-origin: 27.5px 8px; \"\u003eminimum\u003c/span\u003e\u003cspan style=\"border-block-end-style: solid; border-block-end-width: 1px; border-bottom-style: solid; border-bottom-width: 1px; perspective-origin: 2.5px 8.5px; transform-origin: 2.5px 8.5px; \"\u003e)\u003c/span\u003e\u003cspan style=\"perspective-origin: 165px 8px; transform-origin: 165px 8px; \"\u003e n (n \u0026gt; 1) such that the last d digits of x^n is equal to x. If the last d digits will never equal x, return inf.\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: 34.5px 8px; transform-origin: 34.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample 1:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 61.3px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 391px 30.65px; transform-origin: 391px 30.65px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 71px 8px; transform-origin: 71px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ex = 2; (therefore d = 1)\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 110px 8px; transform-origin: 110px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e2^2 = 4, 2^3 = 8, 2^4 = 16, 2^5 = 32\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 18px 8px; transform-origin: 18px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003en = 5;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\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: 34.5px 8px; transform-origin: 34.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample 2:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 61.3px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 391px 30.65px; transform-origin: 391px 30.65px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 75px 8px; transform-origin: 75px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ex = 10; (therefore d = 2)\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 90.5px 8px; transform-origin: 90.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e10^2 = 100, 10^3 = 1000, etc\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 21.5px 8px; transform-origin: 21.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003en = inf;\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function n = bigNumRepeat(x)\r\n  n = x;\r\nend","test_suite":"%%\r\nx = 2;\r\nn_correct = 5;\r\nassert(isequal(bigNumRepeat(x),n_correct))\r\n\r\n%%\r\nx = 10;\r\nn_correct = inf;\r\nassert(isequal(bigNumRepeat(x),n_correct))\r\n\r\n%%\r\nx = [3 7 33 51 67 192 329 678 680 4731 10016 10081 35197 35199 51783 517839 517842];\r\nn_correct = [5 5 21 3 21 101 51 inf inf 501 626 626 5001 251 2501 12501 inf];\r\nfor ii = 1:numel(x)\r\n   assert(isequal(bigNumRepeat(x(ii)),n_correct(ii)))\r\nend","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":3096,"edited_by":223089,"edited_at":"2022-07-27T07:11:05.000Z","deleted_by":null,"deleted_at":null,"solvers_count":86,"test_suite_updated_at":"2015-03-16T15:16:23.000Z","rescore_all_solutions":false,"group_id":45,"created_at":"2015-03-13T18:49:43.000Z","updated_at":"2026-02-15T15:42:06.000Z","published_at":"2015-03-13T18:49:43.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem builds off 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=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3077\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an integer x which contains d digits, find the value of (minimum) n (n \u0026gt; 1) such that the last d digits of x^n is equal to x. If the last d digits will never equal x, return inf.\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 1:\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ex = 2; (therefore d = 1)\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2^2 = 4, 2^3 = 8, 2^4 = 16, 2^5 = 32\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en = 5;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample 2:\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ex = 10; (therefore d = 2)\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e10^2 = 100, 10^3 = 1000, etc\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en = inf;\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":42317,"title":"De-primed","description":"Write a function that will multiply every prime number in the array or matrix by two, leaving all other numbers the same, and return that de-primed array or matrix. One will be treated as prime in this problem.","description_html":"\u003cp\u003eWrite a function that will multiply every prime number in the array or matrix by two, leaving all other numbers the same, and return that de-primed array or matrix. One will be treated as prime in this problem.\u003c/p\u003e","function_template":"function [M] = de_primed(M)\r\n\r\nM = M;\r\n\r\nend\r\n","test_suite":"%%\r\nM = 1:10;\r\nM_corr = [2,4,6,4,10,6,14,8,9,10];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = 20:3:50;\r\nM_corr = [20,46,26,58,32,35,38,82,44,94,50];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = 2:2:100;\r\nM_corr = [4 M(2:end)];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = 10:10:100;\r\nM_corr = M;\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = 3:3:100;\r\nM_corr = [6,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = eye(4);\r\nM_corr = 2*M;\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nM = magic(6);\r\nM_corr = [35, 2, 6,26,38,24;\r\n           6,32,14,21,46,25;\r\n          62, 9, 4,22,27,20;\r\n           8,28,33,34,10,15;\r\n          30,10,34,12,14,16;\r\n           4,36,58,26,18,22];\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 1:10;\r\n\t\tM_corr = [2,4,6,4,10,6,14,8,9,10];\r\n\tcase 2\r\n\t\tM = eye(4);\r\n\t\tM_corr = 2*M;\r\n\tcase 3\r\n\t\tM = 10:10:100;\r\n\t\tM_corr = M;\r\n\tcase 4\r\n\t\tM = magic(6);\r\n\t\tM_corr = [35, 2, 6,26,38,24;\r\n           6,32,14,21,46,25;\r\n          62, 9, 4,22,27,20;\r\n           8,28,33,34,10,15;\r\n          30,10,34,12,14,16;\r\n           4,36,58,26,18,22];\r\nend\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 3:3:100;\r\n\t\tM_corr = [6,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99];\r\n\tcase 2\r\n\t\tM = 1:10;\r\n\t\tM_corr = [2,4,6,4,10,6,14,8,9,10];\r\n\tcase 3\r\n\t\tM = eye(4);\r\n\t\tM_corr = 2*M;\r\n\tcase 4\r\n\t\tM = 20:3:50;\r\n\t\tM_corr = [20,46,26,58,32,35,38,82,44,94,50];\r\nend\r\nassert(isequal(de_primed(M),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 20:3:50;\r\n\t\tM_corr = [20,46,26,58,32,35,38,82,44,94,50];\r\n\tcase 2\r\n\t\tM = 10:10:100;\r\n\t\tM_corr = M;\r\n\tcase 3\r\n\t\tM = 2:2:100;\r\n\t\tM_corr = [4 M(2:end)];\r\n\tcase 4\r\n\t\tM = 1:10;\r\n\t\tM_corr = [2,4,6,4,10,6,14,8,9,10];\r\nend\r\nassert(isequal(de_primed(M),M_corr))\r\n","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":171,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2015-05-17T01:45:02.000Z","updated_at":"2026-03-11T18:31:28.000Z","published_at":"2015-05-17T01:45:02.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function that will multiply every prime number in the array or matrix by two, leaving all other numbers the same, and return that de-primed array or matrix. One will be treated as prime in this problem.\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":42318,"title":"Evened up (or not)","description":"You will be provided with an array or matrix that contains various numbers, in addition to an evening variable, e, set to 1 or 0. If e==1, then you should return an evened version of the matrix, wherein all odd numbers have one added to them to make them even. For example, \r\n\r\n* if M = 1:10, \r\n* then the evened array is [2,2,4,4,6,6,8,8,10,10].\r\n\r\nOn the other hand, if e==0, then you should return the same matrix with only odd numbers, wherein one has been added to every even number. For example,\r\n\r\n* if M = 1:10, \r\n* then the odd array is [1,3,3,5,5,7,7,9,9,11].","description_html":"\u003cp\u003eYou will be provided with an array or matrix that contains various numbers, in addition to an evening variable, e, set to 1 or 0. If e==1, then you should return an evened version of the matrix, wherein all odd numbers have one added to them to make them even. For example,\u003c/p\u003e\u003cul\u003e\u003cli\u003eif M = 1:10,\u003c/li\u003e\u003cli\u003ethen the evened array is [2,2,4,4,6,6,8,8,10,10].\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eOn the other hand, if e==0, then you should return the same matrix with only odd numbers, wherein one has been added to every even number. For example,\u003c/p\u003e\u003cul\u003e\u003cli\u003eif M = 1:10,\u003c/li\u003e\u003cli\u003ethen the odd array is [1,3,3,5,5,7,7,9,9,11].\u003c/li\u003e\u003c/ul\u003e","function_template":"function [M] = evened_up(M,e)\r\n\r\nM = M;\r\n\r\nend\r\n","test_suite":"%%\r\nM = 1:10;\r\ne = 1;\r\nM_corr = [2,2,4,4,6,6,8,8,10,10];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 1:10;\r\ne = 0;\r\nM_corr = [1,3,3,5,5,7,7,9,9,11];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 20:3:50;\r\ne = 1;\r\nM_corr = [20,24,26,30,32,36,38,42,44,48,50];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 20:3:50;\r\ne = 0;\r\nM_corr = [21,23,27,29,33,35,39,41,45,47,51];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 2:2:100;\r\ne = 1;\r\nM_corr = M;\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 2:2:100;\r\ne = 0;\r\nM_corr = M+1;\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = ones(3);\r\ne = 1;\r\nM_corr = M*2;\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = magic(3);\r\ne = 0;\r\nM_corr = [9,1,7;3,5,7;5,9,3];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = magic(3);\r\ne = 1;\r\nM_corr = [8,2,6;4,6,8;4,10,2];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = eye(4);\r\ne = 1;\r\nM_corr = M*2;\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = eye(4);\r\ne = 0;\r\nM_corr = ones(4);\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 1:10;\r\n\t\te = 1;\r\n\t\tM_corr = [2,2,4,4,6,6,8,8,10,10];\r\n\tcase 2\r\n\t\tM = 20:3:50;\r\n\t\te = 1;\r\n\t\tM_corr = [20,24,26,30,32,36,38,42,44,48,50];\r\n\tcase 3\r\n\t\tM = ones(3);\r\n\t\te = 1;\r\n\t\tM_corr = M*2;\r\n\tcase 4\r\n\t\tM = eye(4);\r\n\t\te = 0;\r\n\t\tM_corr = ones(4);\r\nend\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 2:2:100;\r\n\t\te = 0;\r\n\t\tM_corr = M+1;\r\n\tcase 2\r\n\t\tM = 1:10;\r\n\t\te = 0;\r\n\t\tM_corr = [1,3,3,5,5,7,7,9,9,11];\r\n\tcase 3\r\n\t\tM = 1:10;\r\n\t\te = 1;\r\n\t\tM_corr = [2,2,4,4,6,6,8,8,10,10];\r\n\tcase 4\r\n\t\tM = magic(3);\r\n\t\te = 0;\r\n\t\tM_corr = [9,1,7;3,5,7;5,9,3];\r\nend\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = eye(4);\r\n\t\te = 0;\r\n\t\tM_corr = ones(4);\r\n\tcase 2\r\n\t\tM = ones(3);\r\n\t\te = 1;\r\n\t\tM_corr = M*2;\r\n\tcase 3\r\n\t\tM = 20:3:50;\r\n\t\te = 1;\r\n\t\tM_corr = [20,24,26,30,32,36,38,42,44,48,50];\r\n\tcase 4\r\n\t\tM = 2:2:100;\r\n\t\te = 1;\r\n\t\tM_corr = M;\r\nend\r\nassert(isequal(evened_up(M,e),M_corr))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":175,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2015-05-17T02:32:54.000Z","updated_at":"2026-04-02T10:10:53.000Z","published_at":"2015-05-17T02:32:54.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 will be provided with an array or matrix that contains various numbers, in addition to an evening variable, e, set to 1 or 0. If e==1, then you should return an evened version of the matrix, wherein all odd numbers have one added to them to make them even. For example,\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 M = 1:10,\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\u003ethen the evened array is [2,2,4,4,6,6,8,8,10,10].\u003c/w:t\u003e\u003c/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\u003eOn the other hand, if e==0, then you should return the same matrix with only odd numbers, wherein one has been added to every even number. For example,\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 M = 1:10,\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\u003ethen the odd array is [1,3,3,5,5,7,7,9,9,11].\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":42323,"title":"With apologies to William Blake","description":"\r\n Coder Coder, typing fast\r\n Sitting at your desk, aghast.\r\n What immortal MATLAB script\r\n will solve this problem, nice and quick?\r\n\r\nYou are given a number. Your task is to write a MATLAB script that will calculate the smallest positive number you need to add to your original number so that each digit in your sum will have horizontal symmetry. For this problem, those numbers are [0 1 3 8]\r\n\r\nFor example:\r\n\r\n*     If you are given 27, your script should output 3, as 27+3=30. Both 3 and 0 have horizontal symmetry.\r\n*     If you are given 801, your script should output 0, as 801+0=801. 8, 0 and 1 are all horizontally symmetric.\r\n*     If you are given 900, your answer should be 100, as 900+100=1000, which is the next highest number that is horizontally symmetric.\r\n\r\nGood luck. May you become a poet, and not even know it.\r\n","description_html":"\u003cpre\u003e Coder Coder, typing fast\r\n Sitting at your desk, aghast.\r\n What immortal MATLAB script\r\n will solve this problem, nice and quick?\u003c/pre\u003e\u003cp\u003eYou are given a number. Your task is to write a MATLAB script that will calculate the smallest positive number you need to add to your original number so that each digit in your sum will have horizontal symmetry. For this problem, those numbers are [0 1 3 8]\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cul\u003e\u003cli\u003eIf you are given 27, your script should output 3, as 27+3=30. Both 3 and 0 have horizontal symmetry.\u003c/li\u003e\u003cli\u003eIf you are given 801, your script should output 0, as 801+0=801. 8, 0 and 1 are all horizontally symmetric.\u003c/li\u003e\u003cli\u003eIf you are given 900, your answer should be 100, as 900+100=1000, which is the next highest number that is horizontally symmetric.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eGood luck. May you become a poet, and not even know it.\u003c/p\u003e","function_template":"function y = symmetry(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(symmetry(27),3))\r\n%%\r\nassert(isequal(symmetry(801),0))\r\n%%\r\nassert(isequal(symmetry(900),100))\r\n%%\r\nassert(isequal(symmetry(88887),1))\r\n%%\r\nassert(isequal(symmetry(1234567),65433))\r\n%%\r\nassert(isequal(symmetry(34567890),3432110))\r\n%%\r\nformat long g\r\nx=ceil(1e9*rand);\r\nj=389e9+x\r\nassert(isequal(8e11-symmetry(j),j))\r\n%%\r\nformat long g\r\nx=ceil(1e10*rand);\r\nj=889e10+x\r\nv=symmetry(j);\r\nassert(isequal(1e13-v,j))\r\n%%\r\nx=2^40-1;\r\nassert(isequal(symmetry(symmetry(symmetry(symmetry(x)))),7775))","published":true,"deleted":false,"likes_count":10,"comments_count":6,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":79,"test_suite_updated_at":"2015-05-22T12:38:06.000Z","rescore_all_solutions":false,"group_id":45,"created_at":"2015-05-20T19:03:13.000Z","updated_at":"2026-03-16T03:57:06.000Z","published_at":"2015-05-20T19:09:46.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=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Coder Coder, typing fast\\n Sitting at your desk, aghast.\\n What immortal MATLAB script\\n will solve this problem, nice and quick?]]\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 are given a number. Your task is to write a MATLAB script that will calculate the smallest positive number you need to add to your original number so that each digit in your sum will have horizontal symmetry. For this problem, those numbers are [0 1 3 8]\u003c/w:t\u003e\u003c/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=\\\"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 you are given 27, your script should output 3, as 27+3=30. Both 3 and 0 have horizontal symmetry.\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 you are given 801, your script should output 0, as 801+0=801. 8, 0 and 1 are all horizontally symmetric.\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 you are given 900, your answer should be 100, as 900+100=1000, which is the next highest number that is horizontally symmetric.\u003c/w:t\u003e\u003c/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. May you become a poet, and not even know it.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"no_progress_badge":{"id":53,"name":"Unknown","symbol":"unknown","description":"Partially completed groups","description_html":null,"image_location":"/images/responsive/supporting/matlabcentral/cody/badges/problem_groups_unknown_2.png","bonus":null,"players_count":0,"active":false,"created_by":null,"updated_by":null,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"created_at":"2018-01-10T23:20:29.000Z","updated_at":"2018-01-10T23:20:29.000Z","community_badge_id":null,"award_multiples":false}}