{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-05-16T00:20:21.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-05-16T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":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":174,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2015-05-17T01:45:02.000Z","updated_at":"2026-05-04T03:41:42.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":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":327,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-02-18T11:03:52.000Z","updated_at":"2026-05-22T19:51:13.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":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":247,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-04-08T07:33:36.000Z","updated_at":"2026-05-22T19:55:12.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":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":154,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-10-13T13:38:17.000Z","updated_at":"2026-05-04T03:36:36.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":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":99,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T18:00:06.000Z","updated_at":"2026-05-22T20:01:50.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":80,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T18:39:02.000Z","updated_at":"2026-05-04T03:33:06.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":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":120,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-09-22T14:19:57.000Z","updated_at":"2026-05-04T03:35:49.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":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":108,"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-05-04T03:40:57.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":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":81,"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-05-04T03:39:42.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":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":101,"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-05-04T03:37:38.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":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":1376,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2015-01-21T19:54:31.000Z","updated_at":"2026-05-22T19:05:44.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":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":88,"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-05-04T03:27:55.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\"}]}"}],"problem_search":{"errors":[],"problems":[{"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":174,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2015-05-17T01:45:02.000Z","updated_at":"2026-05-04T03:41:42.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":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":327,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-02-18T11:03:52.000Z","updated_at":"2026-05-22T19:51:13.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":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":247,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-04-08T07:33:36.000Z","updated_at":"2026-05-22T19:55:12.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":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":154,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-10-13T13:38:17.000Z","updated_at":"2026-05-04T03:36:36.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":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":99,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T18:00:06.000Z","updated_at":"2026-05-22T20:01:50.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":80,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T18:39:02.000Z","updated_at":"2026-05-04T03:33:06.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":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":120,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-09-22T14:19:57.000Z","updated_at":"2026-05-04T03:35:49.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":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":108,"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-05-04T03:40:57.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":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":81,"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-05-04T03:39:42.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":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":101,"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-05-04T03:37:38.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":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":1376,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2015-01-21T19:54:31.000Z","updated_at":"2026-05-22T19:05:44.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":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":88,"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-05-04T03:27:55.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\"}]}"}],"term":"group:\"Number Manipulation II\" difficulty_rating_bin:medium","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"group:\"Number Manipulation II\" difficulty_rating_bin:medium","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"group":[["group:\"Number Manipulation II\"","","\"","Number Manipulation II","\""]],"difficulty_rating_bin":[["difficulty_rating_bin:medium","","","medium",""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f32703fbcc8\u003e":["Number Manipulation II"],"#\u003cMathWorks::Search::Field:0x00007f32703fbc28\u003e":["medium"]},"filters":{"#\u003cMathWorks::Search::Field:0x00007f32703fae68\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f32703fbf48\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f32703fbea8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f32703fbe08\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f32703fbd68\u003e":"group:\"Number Manipulation II\" difficulty_rating_bin:medium"},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f32703fbd68\u003e":"group:\"Number Manipulation II\" difficulty_rating_bin:medium"},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007f32703fbcc8\u003e":["Number Manipulation II"],"#\u003cMathWorks::Search::Field:0x00007f32703fbc28\u003e":["medium"]}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"cody-search","password":"78X075ddcV44","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"group:\"Number Manipulation II\" difficulty_rating_bin:medium","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"group":[["group:\"Number Manipulation II\"","","\"","Number Manipulation II","\""]],"difficulty_rating_bin":[["difficulty_rating_bin:medium","","","medium",""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f32703fbcc8\u003e":["Number Manipulation II"],"#\u003cMathWorks::Search::Field:0x00007f32703fbc28\u003e":["medium"]},"filters":{"#\u003cMathWorks::Search::Field:0x00007f32703fae68\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f32703fbf48\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f32703fbea8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f32703fbe08\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f32703fbd68\u003e":"group:\"Number Manipulation II\" difficulty_rating_bin:medium"},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f32703fbd68\u003e":"group:\"Number Manipulation II\" difficulty_rating_bin:medium"},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007f32703fbcc8\u003e":["Number Manipulation II"],"#\u003cMathWorks::Search::Field:0x00007f32703fbc28\u003e":["medium"]}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":42317,"difficulty_rating":"easy-medium"},{"id":2193,"difficulty_rating":"easy-medium"},{"id":2270,"difficulty_rating":"easy-medium"},{"id":2627,"difficulty_rating":"easy-medium"},{"id":2431,"difficulty_rating":"easy-medium"},{"id":2432,"difficulty_rating":"easy-medium"},{"id":2600,"difficulty_rating":"easy-medium"},{"id":3077,"difficulty_rating":"medium"},{"id":2848,"difficulty_rating":"medium"},{"id":2735,"difficulty_rating":"medium"},{"id":2869,"difficulty_rating":"medium"},{"id":3079,"difficulty_rating":"medium"}]}}