{"group":{"group":{"id":673,"name":"Number Manipulation IV","lockable":false,"created_at":"2019-05-02T15:35:02.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Now, try to not get these out of order while rearranging.","is_default":false,"created_by":26769,"badge_id":62,"featured":false,"trending":false,"solution_count_in_trending_period":17,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":961,"published":true,"community_created":true,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNow, try to not get these out of order while rearranging.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}","description_html":"\u003cdiv style = \"text-align: start; line-height: normal; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; perspective-origin: 289.5px 10.5px; transform-origin: 289.5px 10.5px; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; perspective-origin: 266.5px 10.5px; transform-origin: 266.5px 10.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eNow, try to not get these out of order while rearranging.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","published_at":"2020-06-05T16:34:36.000Z"},"current_player":null},"problems":[{"id":44523,"title":"Pattern Sum","description":"Write a function which receives two single digit positive integers, (k and m) as parameters and calculates the total sum as: \r\nk + kk + kkk + .... (the last number in the sequence should have m digits) \r\nFor example, if the two integers are:\r\n(4, 5).\r\nYour function should return the total sum of: \r\n4 + 44 + 444 + 4444 + 44444.\r\nNotice the last number in this sequence has 5 digits. The return value should be 49380.","description_html":"\u003cp\u003eWrite a function which receives two single digit positive integers, (k and m) as parameters and calculates the total sum as: \r\nk + kk + kkk + .... (the last number in the sequence should have m digits) \r\nFor example, if the two integers are:\r\n(4, 5).\r\nYour function should return the total sum of: \r\n4 + 44 + 444 + 4444 + 44444.\r\nNotice the last number in this sequence has 5 digits. The return value should be 49380.\u003c/p\u003e","function_template":"function y = pattern_sum(a,b)\r\n    \r\nend","test_suite":"%%\r\na = 4;\r\nb = 5;\r\ny_correct = 49380;\r\nassert(isequal(pattern_sum(a,b),y_correct))\r\n\r\n%%\r\na = 7;\r\nb = 4;\r\ny_correct = 8638;\r\nassert(isequal(pattern_sum(a,b),y_correct))\r\n\r\n%%\r\na = 5;\r\nb = 3;\r\ny_correct = 615;\r\nassert(isequal(pattern_sum(a,b),y_correct))\r\n\r\n%%\r\na = 1;\r\nb = 1;\r\ny_correct = 1;\r\nassert(isequal(pattern_sum(a,b),y_correct))\r\n\r\n%%\r\na = 2;\r\nb = 2;\r\ny_correct = 24;\r\nassert(isequal(pattern_sum(a,b),y_correct))\r\n\r\n%%\r\na = 9;\r\nb = 9;\r\ny_correct = 1111111101;\r\nassert(isequal(pattern_sum(a,b),y_correct))\r\n\r\n%%\r\na = 0;\r\nb = 0;\r\ny_correct = 0;\r\nassert(isequal(pattern_sum(a,b),y_correct))\r\n\r\n%%\r\na = 3;\r\nb = 8;\r\ny_correct = 37037034;\r\nassert(isequal(pattern_sum(a,b),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":181342,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":237,"test_suite_updated_at":"2018-07-13T17:24:37.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-02-15T01:05:11.000Z","updated_at":"2026-03-24T20:17:24.000Z","published_at":"2018-02-15T01:18:20.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 which receives two single digit positive integers, (k and m) as parameters and calculates the total sum as: k + kk + kkk + .... (the last number in the sequence should have m digits) For example, if the two integers are: (4, 5). Your function should return the total sum of: 4 + 44 + 444 + 4444 + 44444. Notice the last number in this sequence has 5 digits. The return value should be 49380.\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":44071,"title":"Smallest n, for n! to have m trailing zero digits","description":"For given positive integer n, its factorial often has many trailing zeros, in other words many factors of 10s. In order for n! to have at least \"m\" trailing zeros, what is the smallest \"n\" ?\r\nExample: factorial(10) = 3628800 factorial(9) = 362880 In order to have 2 trailing zeros on factorial, the smallest n is 10.\r\nOptional: Can you make an efficient algorithm for a very large m?","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: 102px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 51px; transform-origin: 407px 51px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 378.5px 8px; transform-origin: 378.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor given positive integer n, its factorial often has many trailing zeros, in other words many factors of 10s. In order for n! to have at least \"m\" trailing zeros, what is the smallest \"n\" ?\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: 376px 8px; transform-origin: 376px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample: factorial(10) = 3628800 factorial(9) = 362880 In order to have 2 trailing zeros on factorial, the smallest n is 10.\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: 205px 8px; transform-origin: 205px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOptional: Can you make an efficient algorithm for a very large m?\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function n = factorialForZeros(m)\r\n  n = 1000;\r\nend","test_suite":"%%\r\nfiletext = fileread('factorialForZeros.m');\r\nillegal = contains(filetext, 'str2num') || contains(filetext, 'regexp') || ...\r\n          contains(filetext, 'switch') || contains(filetext, 'elseif'); \r\nassert(~illegal)\r\n\r\n%%\r\nm = 1;\r\nn_correct = 5;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 2;\r\nn_correct = 10;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 6;\r\nn_correct = 25;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 5;\r\nn_correct = 25;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 4;\r\nn_correct = 20;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n \r\n%%\r\nm = 156;\r\nn_correct = 625;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 155;\r\nn_correct = 625;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n \r\n%%\r\nm = 154;\r\nn_correct = 625;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 153;\r\nn_correct = 625;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 152;\r\nn_correct = 620;\r\nassert(isequal(factorialForZeros(m),n_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":115733,"edited_by":223089,"edited_at":"2023-01-07T09:00:18.000Z","deleted_by":null,"deleted_at":null,"solvers_count":61,"test_suite_updated_at":"2023-01-07T09:00:18.000Z","rescore_all_solutions":false,"group_id":673,"created_at":"2017-02-14T01:10:18.000Z","updated_at":"2026-03-20T13:48:37.000Z","published_at":"2017-02-14T01:10:18.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\u003eFor given positive integer n, its factorial often has many trailing zeros, in other words many factors of 10s. In order for n! to have at least \\\"m\\\" trailing zeros, what is the smallest \\\"n\\\" ?\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample: factorial(10) = 3628800 factorial(9) = 362880 In order to have 2 trailing zeros on factorial, the smallest n is 10.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOptional: Can you make an efficient algorithm for a very large m?\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44637,"title":"Still more miles to go before I sleep","description":"It's time for more odometer fun.  Last problem, my car's odometer hit 56789.  It's coming up on 111111 now, which (barring a major miracle) will be the last binary number to ever show up on the odometer.  You will be given two numbers - an odometer reading, and a number base.  Calculate the number of miles your car will need to travel in order to show the next number that is valid in that base.  If your odometer reading is already a valid number in that base, return 0.\r\n\r\nFor example, your input is an odometer reading of 12341 with a number base of 4.  The next odometer reading that would be valid in base 4 is 13000, so the correct answer would be 13000-12341, or 659.\r\n\r\nYou can assume that the odometer reading is in base 10, the input is numerical and not a string, all numbers will be positive integers, and that your car will last that long without getting read-ended at a stop-light.  Happy driving!","description_html":"\u003cp\u003eIt's time for more odometer fun.  Last problem, my car's odometer hit 56789.  It's coming up on 111111 now, which (barring a major miracle) will be the last binary number to ever show up on the odometer.  You will be given two numbers - an odometer reading, and a number base.  Calculate the number of miles your car will need to travel in order to show the next number that is valid in that base.  If your odometer reading is already a valid number in that base, return 0.\u003c/p\u003e\u003cp\u003eFor example, your input is an odometer reading of 12341 with a number base of 4.  The next odometer reading that would be valid in base 4 is 13000, so the correct answer would be 13000-12341, or 659.\u003c/p\u003e\u003cp\u003eYou can assume that the odometer reading is in base 10, the input is numerical and not a string, all numbers will be positive integers, and that your car will last that long without getting read-ended at a stop-light.  Happy driving!\u003c/p\u003e","function_template":"function y = miles2(r,b)\r\n  y = dec2base(r,b);\r\nend","test_suite":"%%\r\nr=12341;b=4;\r\nassert(isequal(miles2(r,b),659))\r\n%%\r\nr=12341;b=2;\r\nassert(isequal(miles2(r,b),87659))\r\n%%\r\nr=12331;b=4;\r\nassert(isequal(miles2(r,b),0))\r\n%%\r\nr=455555;b=5;\r\nassert(isequal(miles2(r,b),544445))\r\n%%\r\nr=23907515;b=5;\r\nassert(isequal(miles2(r,b),92485))\r\n%%\r\nr=23807515;b=8;\r\nassert(isequal(miles2(r,b),192485))\r\n%%\r\ns=zeros(1,10);\r\nfor b=2:10\r\n    s(b)=miles2(123456789,b);\r\nend\r\nassert(isequal(sum(s),960219488))\r\n%%\r\ns=zeros(200,10);\r\nfor b=2:10\r\n    for r=1:200\r\n        s(r,b)=miles2(r,b);\r\n    end\r\nend\r\nassert(isequal(sum(s(:)),96940))","published":true,"deleted":false,"likes_count":7,"comments_count":0,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":55,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-14T13:42:15.000Z","updated_at":"2026-03-20T13:46:45.000Z","published_at":"2018-05-14T13:42:15.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\u003eIt's time for more odometer fun. Last problem, my car's odometer hit 56789. It's coming up on 111111 now, which (barring a major miracle) will be the last binary number to ever show up on the odometer. You will be given two numbers - an odometer reading, and a number base. Calculate the number of miles your car will need to travel in order to show the next number that is valid in that base. If your odometer reading is already a valid number in that base, return 0.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, your input is an odometer reading of 12341 with a number base of 4. The next odometer reading that would be valid in base 4 is 13000, so the correct answer would be 13000-12341, or 659.\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\u003eYou can assume that the odometer reading is in base 10, the input is numerical and not a string, all numbers will be positive integers, and that your car will last that long without getting read-ended at a stop-light. Happy driving!\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":721,"title":"Convert from Base 10 to base 5","description":"Convert the input number from base 10 into base 5:\r\n\r\nfor example:\r\n\r\nif a(in base 10)= 5\r\n\r\nthen a(in base 5)= 10\r\n\r\n","description_html":"\u003cp\u003eConvert the input number from base 10 into base 5:\u003c/p\u003e\u003cp\u003efor example:\u003c/p\u003e\u003cp\u003eif a(in base 10)= 5\u003c/p\u003e\u003cp\u003ethen a(in base 5)= 10\u003c/p\u003e","function_template":"function y = cbase5(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 5;\r\ny_correct = 10;\r\nassert(isequal(cbase5(x),y_correct))\r\n\r\n\r\n%%\r\nx = 6;\r\ny_correct = 11;\r\nassert(isequal(cbase5(x),y_correct))\r\n\r\n\r\n%%\r\nx = 50;\r\ny_correct = 200;\r\nassert(isequal(cbase5(x),y_correct))\r\n\r\n\r\n%%\r\nx = 2;\r\ny_correct = 2;\r\nassert(isequal(cbase5(x),y_correct))\r\n\r\n%%\r\nx = 0;\r\ny_correct = 0;\r\nassert(isequal(cbase5(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":4320,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":281,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-05-24T13:17:12.000Z","updated_at":"2026-01-30T17:02:17.000Z","published_at":"2012-05-24T13:17:12.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\u003eConvert the input number from base 10 into base 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\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif a(in base 10)= 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\u003ethen a(in base 5)= 10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44682,"title":"Numbers on 7-segment ","description":"This is a 7-segment:\r\n\r\n    _\r\n   |_|\r\n   |_|\r\n\r\nIt's a 3-by-3 char matrix.It has made by 3 characters: '_' , '|' and ' ' (space). \r\nUsing these 3 characters make the input number on the 7-segment. (Input is 0-9).\r\n\r\n\r\nExample:\r\n\r\n  N=0\r\n  ans=\r\n    _\r\n   | |\r\n   |_| \r\n   \r\n  N= 9\r\n  ans=\r\n    _\r\n   |_|\r\n    _| \r\n   ","description_html":"\u003cp\u003eThis is a 7-segment:\u003c/p\u003e\u003cpre\u003e    _\r\n   |_|\r\n   |_|\u003c/pre\u003e\u003cp\u003eIt's a 3-by-3 char matrix.It has made by 3 characters: '_' , '|' and ' ' (space). \r\nUsing these 3 characters make the input number on the 7-segment. (Input is 0-9).\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eN=0\r\nans=\r\n  _\r\n | |\r\n |_| \r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eN= 9\r\nans=\r\n  _\r\n |_|\r\n  _| \r\n\u003c/pre\u003e","function_template":"function y = seven_segment(N)\r\n  y = ...\r\nend","test_suite":"%%\r\nN = 0;\r\ny_correct =...\r\n[' _ '\r\n '| |'\r\n '|_|']\r\nassert(isequal(seven_segment(N),y_correct))\r\n%%\r\nN = 1;\r\ny_correct =...\r\n['   '\r\n '  |'\r\n '  |']\r\nassert(isequal(seven_segment(N),y_correct))\r\n%%\r\nN = 2;\r\ny_correct =...\r\n[' _ '\r\n ' _|'\r\n '|_ ']\r\nassert(isequal(seven_segment(N),y_correct))\r\n%%\r\nN = 3;\r\ny_correct =...\r\n[' _ '\r\n ' _|'\r\n ' _|']\r\nassert(isequal(seven_segment(N),y_correct))\r\n%%\r\nN = 4;\r\ny_correct =...\r\n['   '\r\n '|_|'\r\n '  |']\r\nassert(isequal(seven_segment(N),y_correct))\r\n%%\r\nN = 9;\r\ny_correct =...\r\n[' _ '\r\n '|_|'\r\n ' _|']\r\nassert(isequal(seven_segment(N),y_correct))\r\n%%\r\nN = 8;\r\ny_correct =...\r\n[' _ '\r\n '|_|'\r\n '|_|']\r\nassert(isequal(seven_segment(N),y_correct))\r\n%%\r\nN = 6;\r\ny_correct =...\r\n[' _ '\r\n '|_ '\r\n '|_|']\r\nassert(isequal(seven_segment(N),y_correct))\r\n%%\r\nN = 5;\r\ny_correct =...\r\n[' _ '\r\n '|_ '\r\n ' _|']\r\nassert(isequal(seven_segment(N),y_correct))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":218677,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":87,"test_suite_updated_at":"2018-06-08T17:09:34.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2018-06-08T10:01:09.000Z","updated_at":"2026-03-20T13:40:55.000Z","published_at":"2018-06-08T10:01:09.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis is a 7-segment:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    _\\n   |_|\\n   |_|]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIt's a 3-by-3 char matrix.It has made by 3 characters: '_' , '|' and ' ' (space). Using these 3 characters make the input number on the 7-segment. (Input is 0-9).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/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[N=0\\nans=\\n  _\\n | |\\n |_| \\n\\nN= 9\\nans=\\n  _\\n |_|\\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":44705,"title":"Expand 10^n to Powers of 4","description":"Given an integer n, return the coefficients \r\n\r\n     c = [c_n,c_n-1,...,c_0]\r\n\r\nSuch that\r\n\r\n    10^n = c_n*4^(n) + c_n-1*4^(n-1) +...+ c_0*4^(0)\r\n\r\nWith the constraint that\r\n\r\n   c_n = c_0\r\n\r\nFor example,\r\n\r\n  n = 1\r\n10^n = 10 = 2*4^(1) + 2*4^(0), so c = [2  2] \r\n","description_html":"\u003cp\u003eGiven an integer n, return the coefficients\u003c/p\u003e\u003cpre\u003e     c = [c_n,c_n-1,...,c_0]\u003c/pre\u003e\u003cp\u003eSuch that\u003c/p\u003e\u003cpre\u003e    10^n = c_n*4^(n) + c_n-1*4^(n-1) +...+ c_0*4^(0)\u003c/pre\u003e\u003cp\u003eWith the constraint that\u003c/p\u003e\u003cpre\u003e   c_n = c_0\u003c/pre\u003e\u003cp\u003eFor example,\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 1\r\n10^n = 10 = 2*4^(1) + 2*4^(0), so c = [2  2] \r\n\u003c/pre\u003e","function_template":"function ans = ten2pow4(n)\r\n  \r\nend","test_suite":"%%\r\nn = 0;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end)) \u0026 coeff(1)\u003e0)\r\n\r\n%%\r\nn = 1;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end)) \u0026 coeff(1)\u003e0)\r\n\r\n%%\r\nn = 2;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end)) \u0026 coeff(1)\u003e0)\r\n\r\n%%\r\nn = 3;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end)) \u0026 coeff(1)\u003e0)\r\n\r\n%%\r\nn = 4;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end)) \u0026 coeff(1)\u003e0)\r\n\r\n%%\r\nn = 5;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end)) \u0026 coeff(1)\u003e0)\r\n\r\n%%\r\nn = 6;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n)\u0026 isequal(coeff(1),coeff(end)) \u0026 coeff(1)\u003e0)\r\n\r\n%%\r\nn = 7;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end)) \u0026 coeff(1)\u003e0)\r\n\r\n%%\r\nn = 8;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end)) \u0026 coeff(1)\u003e0)\r\n\r\n%%\r\nn = 9;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end)) \u0026 coeff(1)\u003e0)\r\n\r\n%%\r\nn = 10;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end))\u0026coeff(1)\u003e0)\r\n\r\n%%\r\nn = 11;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end))\u0026coeff(1)\u003e0)\r\n\r\n%%\r\nn = 12;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end))\u0026coeff(1)\u003e0)\r\n\r\n%%\r\nn = 13;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end))\u0026coeff(1)\u003e0)\r\n\r\n%%\r\nn = 14;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end))\u0026coeff(1)\u003e0)\r\n\r\n%%\r\nn = 15;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end))\u0026coeff(1)\u003e0)\r\n\r\n%%\r\nn = 16;\r\ncoeff = ten2pow4(n);\r\nassert(isequal(dot(coeff, 4.^flip(0:n)),10^n) \u0026 isequal(coeff(1),coeff(end)) \u0026 coeff(1)\u003e0)","published":true,"deleted":false,"likes_count":5,"comments_count":3,"created_by":178544,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":48,"test_suite_updated_at":"2018-08-14T12:07:53.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-08-02T21:15:38.000Z","updated_at":"2026-03-31T14:15:54.000Z","published_at":"2018-08-02T21:19:07.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an integer n, return the coefficients\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[     c = [c_n,c_n-1,...,c_0]]]\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\u003eSuch that\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[    10^n = c_n*4^(n) + c_n-1*4^(n-1) +...+ c_0*4^(0)]]\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\u003eWith the constraint that\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[   c_n = c_0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[n = 1\\n10^n = 10 = 2*4^(1) + 2*4^(0), so c = [2  2]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44768,"title":"Muphry's Law of MATLAB","description":"You're running some simple multiplication problems through MATLAB for error checking purposes, but nothing seems to come up with the answer you should be getting.  After hours of going through the codes, you realize that each of your input sets has exactly one digit mistyped, so all of your answers are incorrect.  You need to regenerate the actual input you used to get these numbers.\r\n\r\nFor example, the two numbers you are multiplying together are 67 and 58.  Multiplying these together should result in 3886.  However, the input data you provided came up with an answer of 3596 instead.  Since only one digit is incorrect in your input, you can calculate the input you used was actually [62 58], because 62*58=3596.  Therefore, an input of [67 58 3596] should result in an output of [62 58].  If the input was [58 67 3596] then the output should be [58 62].\r\n\r\nYou can assume that all of the numbers will have the correct number of digits, so 7 will not have to be replaced by 37, for example.  Hood Lock!","description_html":"\u003cp\u003eYou're running some simple multiplication problems through MATLAB for error checking purposes, but nothing seems to come up with the answer you should be getting.  After hours of going through the codes, you realize that each of your input sets has exactly one digit mistyped, so all of your answers are incorrect.  You need to regenerate the actual input you used to get these numbers.\u003c/p\u003e\u003cp\u003eFor example, the two numbers you are multiplying together are 67 and 58.  Multiplying these together should result in 3886.  However, the input data you provided came up with an answer of 3596 instead.  Since only one digit is incorrect in your input, you can calculate the input you used was actually [62 58], because 62*58=3596.  Therefore, an input of [67 58 3596] should result in an output of [62 58].  If the input was [58 67 3596] then the output should be [58 62].\u003c/p\u003e\u003cp\u003eYou can assume that all of the numbers will have the correct number of digits, so 7 will not have to be replaced by 37, for example.  Hood Lock!\u003c/p\u003e","function_template":"function y = muphry(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [67 58 3596];\r\ny_correct = [62 58];\r\nassert(isequal(muphry(x),y_correct))\r\n%%\r\nx = [58 67 3596];\r\ny_correct = [58 62];\r\nassert(isequal(muphry(x),y_correct))\r\n%%\r\nx=[11 13 363];\r\ny_correct = [11 33];\r\nassert(isequal(muphry(x),y_correct))\r\n%%\r\nx=[2 3 4 5 16 3120];\r\ny_correct = [2 3 4 5 26];\r\nassert(isequal(muphry(x),y_correct))\r\n%%\r\nx=[12345 23456 166114320];\r\ny_correct = [12345 13456];\r\nassert(isequal(muphry(x),y_correct))\r\n%%\r\nx=[11 22 132];\r\ny_correct = [11 12];\r\nassert(isequal(muphry(x),y_correct))\r\n%%\r\nx=[12 22 252];\r\ny_correct = [12 21];\r\nassert(isequal(muphry(x),y_correct))\r\n%%\r\nx=[2 3 4 5 16 2688];\r\ny_correct=[2 3 4 7 16];\r\nassert(isequal(muphry(x),y_correct))\r\n%%\r\nfor flag=1:1000\r\n    p1=10;\r\n    p2=10;\r\n    p3=10;\r\n    while or((p1==p3),or((p2==p3),(p1==p2)))\r\n        p1=[ceil(9*rand) floor(10*rand(1,4))];\r\n        p2=[ceil(9*rand) floor(10*rand(1,4))];\r\n        if rand\u003e0.5\r\n            p3=p1;\r\n            changed=1;\r\n        else\r\n            p3=p2;\r\n            changed=2;\r\n        end\r\n        n=ceil(4*rand)+1;\r\n        if p3(n)==9\r\n            p3(n)=0;\r\n        else\r\n            p3(n)=p3(n)+1;\r\n        end\r\n        p1p=polyval(p1,10);\r\n        p2p=polyval(p2,10);\r\n        p3p=polyval(p3,10);\r\n    end\r\n    if changed==1\r\n        x=[p1p p2p p3p*p2p];\r\n    else\r\n        x=[p1p p2p p1p*p3p];\r\n    end\r\n  \r\n    xval=muphry(x);\r\n    if changed==2\r\n        assert(isequal(xval,[p1p p3p]))\r\n    else\r\n        assert(isequal(xval,[p3p p2p]))\r\n    end\r\nend","published":true,"deleted":false,"likes_count":3,"comments_count":3,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":47,"test_suite_updated_at":"2018-11-13T19:30:33.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2018-10-31T17:34:12.000Z","updated_at":"2026-03-20T13:53:22.000Z","published_at":"2018-10-31T19:53:20.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou're running some simple multiplication problems through MATLAB for error checking purposes, but nothing seems to come up with the answer you should be getting. After hours of going through the codes, you realize that each of your input sets has exactly one digit mistyped, so all of your answers are incorrect. You need to regenerate the actual input you used to get these numbers.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, the two numbers you are multiplying together are 67 and 58. Multiplying these together should result in 3886. However, the input data you provided came up with an answer of 3596 instead. Since only one digit is incorrect in your input, you can calculate the input you used was actually [62 58], because 62*58=3596. Therefore, an input of [67 58 3596] should result in an output of [62 58]. If the input was [58 67 3596] then the output should be [58 62].\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\u003eYou can assume that all of the numbers will have the correct number of digits, so 7 will not have to be replaced by 37, for example. Hood Lock!\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":44785,"title":"Lunar Arithmetic (Addition)","description":"\u003chttps://oeis.org/A087061 OEIS link for a description of lunar arithmetic\u003e\r\n\r\nSimply take the larger digit.\r\n\r\nExample 1:\r\n\r\n    5\r\n  + 6\r\n  ____\r\n    6\r\n\r\n\r\nExample 2:\r\n\r\n    456\r\n  + 789\r\n  _____\r\n    789\r\n\r\n\r\nExample 3:\r\n   \r\n        86\r\n   + 12374\r\n    ______\r\n     12386\r\n\r\nExample 4:\r\n\r\n       29\r\n     1652\r\n  + 95412\r\n   ________\r\n    95659\r\n","description_html":"\u003cp\u003e\u003ca href = \"https://oeis.org/A087061\"\u003eOEIS link for a description of lunar arithmetic\u003c/a\u003e\u003c/p\u003e\u003cp\u003eSimply take the larger digit.\u003c/p\u003e\u003cp\u003eExample 1:\u003c/p\u003e\u003cpre\u003e    5\r\n  + 6\r\n  ____\r\n    6\u003c/pre\u003e\u003cp\u003eExample 2:\u003c/p\u003e\u003cpre\u003e    456\r\n  + 789\r\n  _____\r\n    789\u003c/pre\u003e\u003cp\u003eExample 3:\u003c/p\u003e\u003cpre\u003e        86\r\n   + 12374\r\n    ______\r\n     12386\u003c/pre\u003e\u003cp\u003eExample 4:\u003c/p\u003e\u003cpre\u003e       29\r\n     1652\r\n  + 95412\r\n   ________\r\n    95659\u003c/pre\u003e","function_template":"function lunarResult = lunarAddition(varargin)\r\n  \r\nend","test_suite":"%%\r\nx = 5;\r\ny = 6;\r\nassert(isequal(lunarAddition(x,y),6))\r\n\r\n%%\r\nx = 456;\r\ny = 789;\r\nassert(isequal(lunarAddition(x,y),789))\r\n\r\n%%\r\nx = 86;\r\ny = 12374;\r\nassert(isequal(lunarAddition(x,y),12386))\r\n\r\n%%\r\nx = 29;\r\ny = 1652;\r\nz = 95412;\r\nassert(isequal(lunarAddition(x,y,z),95659))\r\n\r\n%%\r\nx = 33;\r\ny = 1111;\r\nz = 4456;\r\na = 38;\r\nassert(isequal(lunarAddition(x,y,z,a),4458))\r\n\r\n%%\r\nx = 85214;\r\ny = 4785;\r\nz = 1;\r\na = 850615;\r\nb = 14702140;\r\nassert(isequal(lunarAddition(x,y,z,a,b),14885785))\r\n\r\n%%\r\nx = 9;\r\ny = 0;\r\nassert(isequal(lunarAddition(x,y),9))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":60,"test_suite_updated_at":"2018-11-10T06:01:31.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-11-09T19:19:42.000Z","updated_at":"2026-03-02T11:51:07.000Z","published_at":"2018-11-10T06:01: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\",\"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:hyperlink w:docLocation=\\\"https://oeis.org/A087061\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOEIS link for a description of lunar arithmetic\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSimply take the larger digit.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/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=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    5\\n  + 6\\n  ____\\n    6]]\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\u003eExample 2:\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[    456\\n  + 789\\n  _____\\n    789]]\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\u003eExample 3:\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[        86\\n   + 12374\\n    ______\\n     12386]]\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\u003eExample 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[       29\\n     1652\\n  + 95412\\n   ________\\n    95659]]\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":44786,"title":"Lunar Arithmetic (Multiplication)","description":"\u003chttps://oeis.org/A087061 OEIS link for a description of lunar arithmetic\u003e\r\n\r\nSimply take the larger digit when adding and take the smaller digit when multiplying. \r\n\r\nExample \r\n\r\n        15866\r\n     X    147\r\n     _________\r\n        15766\r\n       14444\r\n    + 11111\r\n    __________\r\n      1145766","description_html":"\u003cp\u003e\u003ca href = \"https://oeis.org/A087061\"\u003eOEIS link for a description of lunar arithmetic\u003c/a\u003e\u003c/p\u003e\u003cp\u003eSimply take the larger digit when adding and take the smaller digit when multiplying.\u003c/p\u003e\u003cp\u003eExample\u003c/p\u003e\u003cpre\u003e        15866\r\n     X    147\r\n     _________\r\n        15766\r\n       14444\r\n    + 11111\r\n    __________\r\n      1145766\u003c/pre\u003e","function_template":"function lunarMult = lunarMultiplication(x,y)\r\n  lunarMult = x * y\r\nend","test_suite":"\r\n\r\nfiletext = fileread('lunarMultiplication.m');\r\nassert(isempty(strfind(filetext, 'assert')))\r\nassert(isempty(strfind(filetext, 'echo')))\r\n\r\n%%\r\nx = 15866;\r\ny = 147;\r\nassert(isequal(lunarMultiplication(x,y),1145766))\r\n\r\n%%\r\nx = 169;\r\ny = 248;\r\nassert(isequal(lunarMultiplication(x,y),12468))\r\n\r\n%%\r\nx = 7;\r\ny = 4;\r\nassert(isequal(lunarMultiplication(x,y),4))\r\n\r\n\r\n%%\r\nx = 78;\r\ny = 4;\r\nassert(isequal(lunarMultiplication(x,y),44))\r\n\r\n\r\n%%\r\nx = 7799123;\r\ny = 109;\r\nassert(isequal(lunarMultiplication(x,y),117799123))","published":true,"deleted":false,"likes_count":5,"comments_count":0,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":49,"test_suite_updated_at":"2019-04-22T12:02:07.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2018-11-10T06:01:37.000Z","updated_at":"2026-03-20T13:37:48.000Z","published_at":"2018-11-10T06:01:37.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:hyperlink w:docLocation=\\\"https://oeis.org/A087061\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOEIS link for a description of lunar arithmetic\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSimply take the larger digit when adding and take the smaller digit when multiplying.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/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[        15866\\n     X    147\\n     _________\\n        15766\\n       14444\\n    + 11111\\n    __________\\n      1145766]]\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":44856,"title":"Permutation Via Multiplication","description":"Given two numbers a and b, determine if the product ab is a permutation of the digits of a. For example, this is always true for a=0. Less trivially, 125874*2=251748.\r\nIf the product, ab, has more digits than a, append zeros to the front of a so they have the same number of digits. Thus, for example, 015*7=105 is another example.\r\nThis problem was inspired by seeing a student simplify 163/326 to 1/2 by cancelling out the digits in common.","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: 123px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 61.5px; transform-origin: 407px 61.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 384px 8px; transform-origin: 384px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven two numbers a and b, determine if the product ab is a permutation of the digits of a. For example, this is always true for a=0. Less trivially, 125874*2=251748.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 384px 8px; transform-origin: 384px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf the product, ab, has more digits than a, append zeros to the front of a so they have the same number of digits. Thus, for example, 015*7=105 is another example.\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: 342.5px 8px; transform-origin: 342.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis problem was inspired by seeing a student simplify 163/326 to 1/2 by cancelling out the digits in common.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function tf = product_is_perm(a,b)\r\ntf = false;\r\nend","test_suite":"%%\r\na = 0;\r\nb = 2;\r\ntf_correct = true;\r\nassert(isequal(product_is_perm(a,b),tf_correct))\r\n\r\n%%\r\na = 15;\r\nb = 7;\r\ntf_correct = true;\r\nassert(isequal(product_is_perm(a,b),tf_correct))\r\n\r\n%%\r\na = 1035;\r\nb = 3;\r\ntf_correct = true;\r\nassert(isequal(product_is_perm(a,b),tf_correct))\r\n\r\n%%\r\na = 125874;\r\nb = 2;\r\ntf_correct = true;\r\nassert(isequal(product_is_perm(a,b),tf_correct))\r\n\r\n%%\r\na = 10;\r\nb = 2;\r\ntf_correct = false;\r\nassert(isequal(product_is_perm(a,b),tf_correct))\r\n\r\n%%\r\na = 123;\r\nb = 10;\r\ntf_correct = true;\r\nassert(isequal(product_is_perm(a,b),tf_correct))\r\n\r\n%%\r\na = 67;\r\nb = 2;\r\ntf_correct = false;\r\nassert(isequal(product_is_perm(a,b),tf_correct))\r\n\r\n%%\r\na = 1025874;\r\nb = 2;\r\ntf_correct = true;\r\nassert(isequal(product_is_perm(a,b),tf_correct))\r\n\r\n%%\r\na = 459;\r\nb = 11;\r\ntf_correct = true;\r\nassert(isequal(product_is_perm(a,b),tf_correct))\r\n\r\n%%\r\na = 461;\r\nb = 11;\r\ntf_correct = false;\r\nassert(isequal(product_is_perm(a,b),tf_correct))\r\n\r\n%%\r\na = 2;\r\nb = 6;\r\ntf_correct = false;\r\nassert(isequal(product_is_perm(a,b),tf_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":280845,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":56,"test_suite_updated_at":"2021-06-17T09:04:15.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2019-02-21T18:59:27.000Z","updated_at":"2026-03-20T13:33:01.000Z","published_at":"2019-02-21T18:59:27.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two numbers a and b, determine if the product ab is a permutation of the digits of a. For example, this is always true for a=0. Less trivially, 125874*2=251748.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the product, ab, has more digits than a, append zeros to the front of a so they have the same number of digits. Thus, for example, 015*7=105 is another 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem was inspired by seeing a student simplify 163/326 to 1/2 by cancelling out the digits in common.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44067,"title":"The last non-zero digit of a factorial","description":"For given positive integer n, what is the last non-zero digit of n!? \r\n\r\n\r\nExample:  factorial(11) = 39916800\r\n\r\nLast non-zero digit is 8.\r\n\r\n\r\nOptional: Can you make an efficient algorithm for very large n?","description_html":"\u003cp\u003eFor given positive integer n, what is the last non-zero digit of n!?\u003c/p\u003e\u003cp\u003eExample:  factorial(11) = 39916800\u003c/p\u003e\u003cp\u003eLast non-zero digit is 8.\u003c/p\u003e\u003cp\u003eOptional: Can you make an efficient algorithm for very large n?\u003c/p\u003e","function_template":"function d = lastNonZeroDigitFactorial(n)\r\n  d = 0;\r\nend","test_suite":"%%\r\nn = 4;\r\nd_correct = 4;\r\nassert(isequal(lastNonZeroDigitFactorial(n),d_correct))\r\n\r\n%%\r\nn = 5;\r\nd_correct = 2;\r\nassert(isequal(lastNonZeroDigitFactorial(n),d_correct))\r\n \r\n%%\r\nn = 6;\r\nd_correct = 2;\r\nassert(isequal(lastNonZeroDigitFactorial(n),d_correct))\r\n\r\n\r\n%%\r\nn = 7;\r\nd_correct = 4;\r\nassert(isequal(lastNonZeroDigitFactorial(n),d_correct))\r\n\r\n\r\n%%\r\nn = 8;\r\nd_correct = 2;\r\nassert(isequal(lastNonZeroDigitFactorial(n),d_correct))\r\n\r\n\r\n%%\r\nn = 9;\r\nd_correct = 8;\r\nassert(isequal(lastNonZeroDigitFactorial(n),d_correct))\r\n\r\n\r\n%%\r\nn = 10;\r\nd_correct = 8;\r\nassert(isequal(lastNonZeroDigitFactorial(n),d_correct))\r\n ","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":115733,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":77,"test_suite_updated_at":"2017-02-14T00:18:21.000Z","rescore_all_solutions":false,"group_id":673,"created_at":"2017-02-14T00:14:25.000Z","updated_at":"2026-03-11T08:47:48.000Z","published_at":"2017-02-14T00:18:21.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\u003eFor given positive integer n, what is the last non-zero digit of n!?\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample: factorial(11) = 39916800\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\u003eLast non-zero digit is 8.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOptional: Can you make an efficient algorithm for very large n?\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":44068,"title":"The number of trailing zero digit of a factorial","description":"For given positive integer n, take factorial of that number. How many trailing zeros does it have?\r\n\r\nExample: factorial(11) = 39916800\r\n\r\nIts last zero-digit count is 2.\r\n\r\nOptional: Can you make an efficient algorithm for a very large n?","description_html":"\u003cp\u003eFor given positive integer n, take factorial of that number. How many trailing zeros does it have?\u003c/p\u003e\u003cp\u003eExample: factorial(11) = 39916800\u003c/p\u003e\u003cp\u003eIts last zero-digit count is 2.\u003c/p\u003e\u003cp\u003eOptional: Can you make an efficient algorithm for a very large n?\u003c/p\u003e","function_template":"function ct = powerTenInFactorial(n)\r\n  ct = 0;\r\nend","test_suite":"%%\r\nn = 1;\r\nct_correct = 0;\r\nassert(isequal(powerTenInFactorial(n),ct_correct))\r\n\r\n%%\r\nn = 9;\r\nct_correct = 1;\r\nassert(isequal(powerTenInFactorial(n),ct_correct))\r\n\r\n%%\r\nn = 27;\r\nct_correct = 6;\r\nassert(isequal(powerTenInFactorial(n),ct_correct))\r\n\r\n%%\r\nn = 626;\r\nct_correct = 156;\r\nassert(isequal(powerTenInFactorial(n),ct_correct))\r\n\r\n%%\r\nn = 620;\r\nct_correct = 152;\r\nassert(isequal(powerTenInFactorial(n),ct_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":3,"created_by":115733,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":673,"created_at":"2017-02-14T00:24:29.000Z","updated_at":"2026-03-20T13:50:01.000Z","published_at":"2017-02-14T00:24:29.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\u003eFor given positive integer n, take factorial of that number. How many trailing zeros does it have?\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: factorial(11) = 39916800\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\u003eIts last zero-digit count is 2.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOptional: Can you make an efficient algorithm for a very large n?\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":2498,"title":"Whole Number Concatenator","description":"Write a function that concatenates whole numbers.\r\n\r\nFor example:\r\n\r\nnumcat(111,222) should return 111222\r\n\r\nnumcat(1,2,3,4,5) should return 12345\r\n\r\n\r\n","description_html":"\u003cp\u003eWrite a function that concatenates whole numbers.\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cp\u003enumcat(111,222) should return 111222\u003c/p\u003e\u003cp\u003enumcat(1,2,3,4,5) should return 12345\u003c/p\u003e","function_template":"function N = numcat(varargin)\r\n\r\nend","test_suite":"%%\r\na=111;\r\nb=444;\r\nN_correct=111444;\r\nassert(isequal(numcat(a,b),N_correct))\r\n\r\n%%\r\na=1;\r\nb=2;\r\nc=3;\r\nd=4;\r\nf=5;\r\nN_correct=12345;\r\nassert(isequal(numcat(a,b,c,d,f),N_correct))\r\n\r\n%%\r\na=2;\r\nb=3;\r\nc=5;\r\nd=7;\r\nf=11;\r\ng=13;\r\nh=17;\r\nk=19;\r\nl=23;\r\nm=29;\r\nn=31;\r\nN_correct=235711131719232931;\r\nassert(isequal(numcat(a,b,c,d,f,g,h,k,l,m,n),N_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":379,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":83,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":673,"created_at":"2014-08-09T16:02:34.000Z","updated_at":"2026-03-20T13:34:32.000Z","published_at":"2014-08-09T16:02:34.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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 concatenates whole numbers.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003enumcat(111,222) should return 111222\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\u003enumcat(1,2,3,4,5) should return 12345\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":2501,"title":"Whole Number Un-Concatenator","description":"Write a function that accepts an integer and an index digit and returns a vector containing two integers which are the leading and trailing digits of the input integer, split after the index digit.\r\n\r\nFor example:\r\n\r\nuncat(12345,3) should return [123 45]","description_html":"\u003cp\u003eWrite a function that accepts an integer and an index digit and returns a vector containing two integers which are the leading and trailing digits of the input integer, split after the index digit.\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cp\u003euncat(12345,3) should return [123 45]\u003c/p\u003e","function_template":"function ns = uncat(n)\r\n\r\nend","test_suite":"%%\r\nn=12345;\r\ndig=3;\r\nns_correct=[123 45];\r\nassert(isequal(uncat(n,dig),ns_correct))\r\n%%\r\nn=3141592;\r\ndig=1;\r\nns_correct=[3 141592];\r\nassert(isequal(uncat(n,dig),ns_correct))\r\n%%\r\nn=271828;\r\ndig=1;\r\nns_correct=[2 71828];\r\nassert(isequal(uncat(n,dig),ns_correct))\r\n%%\r\nn=1618033988;\r\ndig=6;\r\nns_correct=[161803 3988];\r\nassert(isequal(uncat(n,dig),ns_correct))\r\n%%\r\nn=112358132134;\r\ndig=10;\r\nns_correct=[1123581321 34];\r\nassert(isequal(uncat(n,dig),ns_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":379,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":77,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":673,"created_at":"2014-08-10T03:28:31.000Z","updated_at":"2026-02-04T14:27:00.000Z","published_at":"2014-08-10T03:28: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\u003eWrite a function that accepts an integer and an index digit and returns a vector containing two integers which are the leading and trailing digits of the input integer, split after the index digit.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003euncat(12345,3) should return [123 45]\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":44071,"title":"Smallest n, for n! to have m trailing zero digits","description":"For given positive integer n, its factorial often has many trailing zeros, in other words many factors of 10s. In order for n! to have at least \"m\" trailing zeros, what is the smallest \"n\" ?\r\nExample: factorial(10) = 3628800 factorial(9) = 362880 In order to have 2 trailing zeros on factorial, the smallest n is 10.\r\nOptional: Can you make an efficient algorithm for a very large m?","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: 102px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 51px; transform-origin: 407px 51px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 378.5px 8px; transform-origin: 378.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor given positive integer n, its factorial often has many trailing zeros, in other words many factors of 10s. In order for n! to have at least \"m\" trailing zeros, what is the smallest \"n\" ?\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: 376px 8px; transform-origin: 376px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample: factorial(10) = 3628800 factorial(9) = 362880 In order to have 2 trailing zeros on factorial, the smallest n is 10.\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: 205px 8px; transform-origin: 205px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOptional: Can you make an efficient algorithm for a very large m?\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function n = factorialForZeros(m)\r\n  n = 1000;\r\nend","test_suite":"%%\r\nfiletext = fileread('factorialForZeros.m');\r\nillegal = contains(filetext, 'str2num') || contains(filetext, 'regexp') || ...\r\n          contains(filetext, 'switch') || contains(filetext, 'elseif'); \r\nassert(~illegal)\r\n\r\n%%\r\nm = 1;\r\nn_correct = 5;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 2;\r\nn_correct = 10;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 6;\r\nn_correct = 25;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 5;\r\nn_correct = 25;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 4;\r\nn_correct = 20;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n \r\n%%\r\nm = 156;\r\nn_correct = 625;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 155;\r\nn_correct = 625;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n \r\n%%\r\nm = 154;\r\nn_correct = 625;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 153;\r\nn_correct = 625;\r\nassert(isequal(factorialForZeros(m),n_correct))\r\n\r\n%%\r\nm = 152;\r\nn_correct = 620;\r\nassert(isequal(factorialForZeros(m),n_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":115733,"edited_by":223089,"edited_at":"2023-01-07T09:00:18.000Z","deleted_by":null,"deleted_at":null,"solvers_count":61,"test_suite_updated_at":"2023-01-07T09:00:18.000Z","rescore_all_solutions":false,"group_id":673,"created_at":"2017-02-14T01:10:18.000Z","updated_at":"2026-03-20T13:48:37.000Z","published_at":"2017-02-14T01:10:18.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\u003eFor given positive integer n, its factorial often has many trailing zeros, in other words many factors of 10s. In order for n! to have at least \\\"m\\\" trailing zeros, what is the smallest \\\"n\\\" ?\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample: factorial(10) = 3628800 factorial(9) = 362880 In order to have 2 trailing zeros on factorial, the smallest n is 10.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOptional: Can you make an efficient algorithm for a very large m?\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1951,"title":"Better Index Number ","description":"Let's say you want to save many, many files and append these files with a certain sortable index number. As you probably know, you often get in a situation where your files go like this:\r\n\r\n    file1\r\n    file101\r\n    file2\r\n    etc.\r\n\r\nWhich is not ideal when you want your files to go like this:\r\n\r\n    file1\r\n    file2\r\n    file101\r\n    etc.\r\n\r\nSo let's make a function that given the current index number and the maximum index number, it will return a string with leading 0's so that any computer will know how to sort the files. For example, if I were on index 9 and there were a total of 230 files, my function would return '009' so I could append that to my file. ","description_html":"\u003cp\u003eLet's say you want to save many, many files and append these files with a certain sortable index number. As you probably know, you often get in a situation where your files go like this:\u003c/p\u003e\u003cpre\u003e    file1\r\n    file101\r\n    file2\r\n    etc.\u003c/pre\u003e\u003cp\u003eWhich is not ideal when you want your files to go like this:\u003c/p\u003e\u003cpre\u003e    file1\r\n    file2\r\n    file101\r\n    etc.\u003c/pre\u003e\u003cp\u003eSo let's make a function that given the current index number and the maximum index number, it will return a string with leading 0's so that any computer will know how to sort the files. For example, if I were on index 9 and there were a total of 230 files, my function would return '009' so I could append that to my file.\u003c/p\u003e","function_template":"function n_str = betterIndexNum(n,max_n)\r\n  n_str = str(n);\r\nend","test_suite":"%%\r\nn = 1;\r\nmax_n = 9;\r\nn_str = '1';\r\nassert(isequal(betterIndexNum(n,max_n),n_str))\r\n\r\n%%\r\nn = 1;\r\nmax_n = 28;\r\nn_str = '01';\r\nassert(isequal(betterIndexNum(n,max_n),n_str))\r\n\r\n%%\r\nn = 28;\r\nmax_n = 848984;\r\nn_str = '000028';\r\nassert(isequal(betterIndexNum(n,max_n),n_str))\r\n\r\n%%\r\nn = 10;\r\nmax_n = 100;\r\nn_str = '010';\r\nassert(isequal(betterIndexNum(n,max_n),n_str))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":3743,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":92,"test_suite_updated_at":"2013-10-24T06:58:01.000Z","rescore_all_solutions":false,"group_id":673,"created_at":"2013-10-20T07:52:06.000Z","updated_at":"2026-02-26T15:47:19.000Z","published_at":"2013-10-20T08:03: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\u003eLet's say you want to save many, many files and append these files with a certain sortable index number. As you probably know, you often get in a situation where your files go like this:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    file1\\n    file101\\n    file2\\n    etc.]]\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\u003eWhich is not ideal when you want your files to go like this:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    file1\\n    file2\\n    file101\\n    etc.]]\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\u003eSo let's make a function that given the current index number and the maximum index number, it will return a string with leading 0's so that any computer will know how to sort the files. For example, if I were on index 9 and there were a total of 230 files, my function would return '009' so I could append that to my file.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"no_progress_badge":{"id":53,"name":"Unknown","symbol":"unknown","description":"Partially completed groups","description_html":null,"image_location":"/images/responsive/supporting/matlabcentral/cody/badges/problem_groups_unknown_2.png","bonus":null,"players_count":0,"active":false,"created_by":null,"updated_by":null,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"created_at":"2018-01-10T23:20:29.000Z","updated_at":"2018-01-10T23:20:29.000Z","community_badge_id":null,"award_multiples":false}}