{"group":{"group":{"id":593,"name":"Randomness","lockable":false,"created_at":"2019-04-15T18:03:46.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"A random collection of a few random problems in random order.","is_default":false,"created_by":26769,"badge_id":62,"featured":false,"trending":false,"solution_count_in_trending_period":381,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":437,"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\u003eA random collection of a few random problems in random order.\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=\"\"\u003eA random collection of a few random problems in random order.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","published_at":"2019-05-08T20:21:04.000Z"},"current_player":null},"problems":[{"id":44277,"title":"Given n, create n random numbers such that their standard deviation is also n.","description":"Given n, create n random numbers such that their standard deviation is also n.","description_html":"\u003cp\u003eGiven n, create n random numbers such that their standard deviation is also n.\u003c/p\u003e","function_template":"function y = randpro(n)\r\n  y = n+3;\r\nend","test_suite":"%%\r\nx = 10;\r\nassert(length(randpro(x))==10)\r\nassert(std(randpro(x))\u003e9)\r\nassert(std(randpro(x))\u003c11)\r\n\r\n%%\r\nx = 17;\r\nassert(length(randpro(x))==17)\r\nassert(std(randpro(x))\u003e16)\r\nassert(std(randpro(x))\u003c18)\r\n\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":204,"test_suite_updated_at":"2017-08-06T19:53:33.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-08-06T19:46:05.000Z","updated_at":"2026-02-11T03:12:53.000Z","published_at":"2017-08-06T19:53:33.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven n, create n random numbers such that their standard deviation is also 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":42503,"title":"Generating random matrix with given probability mass function","description":"Inspired by \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2356-simulating-the-selection-of-a-state-with-given-probabilities Problem 2356. Simulating the selection of a state with given probabilities\u003e, let's consider a similar yet more useful problem. Write a function\r\n\r\n                             x = rndsampling(m,n,prob)\r\n\r\nto generate an m-by-n matrix x, whose entries are drawn independently from integer symbols 1:numel(prob) according to the given probability mass function prob. Specifically, symbol k occurs with probability prob(k), k = 1, 2, ..., numel(prob), where all(prob\u003e0) == 1 and sum(prob) == 1.","description_html":"\u003cp\u003eInspired by \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2356-simulating-the-selection-of-a-state-with-given-probabilities\"\u003eProblem 2356. Simulating the selection of a state with given probabilities\u003c/a\u003e, let's consider a similar yet more useful problem. Write a function\u003c/p\u003e\u003cpre\u003e                             x = rndsampling(m,n,prob)\u003c/pre\u003e\u003cp\u003eto generate an m-by-n matrix x, whose entries are drawn independently from integer symbols 1:numel(prob) according to the given probability mass function prob. Specifically, symbol k occurs with probability prob(k), k = 1, 2, ..., numel(prob), where all(prob\u0026gt;0) == 1 and sum(prob) == 1.\u003c/p\u003e","function_template":"function x = rndsampling(m,n,prob);\r\n  x = rand(m,n)\r\nend","test_suite":"%%\r\nrnd = sort(rand(randi([10,20]),1));\r\nprob = vertcat(rnd(1,:),diff(rnd,1,1),1-rnd(end,:));\r\nsz = [1 1e5;1e5 1;1e3 1e2;randi([100 200], 100, 2)];\r\nsz = sz(randi(size(sz,1)),:);\r\nx = rndsampling(sz(1),sz(2),prob);\r\nprob_est = histcounts(x,1:numel(prob)+1,'Normalization','probability').';\r\nerr = mean(abs(prob_est - prob))\r\nassert(err \u003c 0.005 \u0026\u0026 isequal(size(x),sz) \u0026\u0026 all(~isnan(x(:))));\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":12569,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":107,"test_suite_updated_at":"2015-08-13T18:44:59.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-08-11T19:26:49.000Z","updated_at":"2026-02-02T05:18:21.000Z","published_at":"2015-08-11T19:26:49.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\u003eInspired by\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/2356-simulating-the-selection-of-a-state-with-given-probabilities\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2356. Simulating the selection of a state with given probabilities\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, let's consider a similar yet more useful problem. Write a function\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[                             x = rndsampling(m,n,prob)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eto generate an m-by-n matrix x, whose entries are drawn independently from integer symbols 1:numel(prob) according to the given probability mass function prob. Specifically, symbol k occurs with probability prob(k), k = 1, 2, ..., numel(prob), where all(prob\u0026gt;0) == 1 and sum(prob) == 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":174,"title":"Roll the Dice!","description":"Description\r\nReturn two random integers between 1 and 6, inclusive, to simulate rolling 2 dice.\r\nExample\r\n   [x1,x2] = rollDice();\r\n   x1 = 5;\r\n   x2 = 2;","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; 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=\"block-size: 152.312px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407.5px 76.1562px; transform-origin: 407.5px 76.1562px; 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: 384.5px 10.5px; text-align: left; transform-origin: 384.5px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eDescription\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: 384.5px 10.5px; text-align: left; transform-origin: 384.5px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn two random integers between 1 and 6, inclusive, to simulate rolling 2 dice.\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: 384.5px 10.5px; text-align: left; transform-origin: 384.5px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eExample\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 61.3125px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404.5px 30.6562px; transform-origin: 404.5px 30.6562px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.666667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.666667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.666667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.666667px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404.5px 10.2188px; text-wrap: nowrap; transform-origin: 404.5px 10.2188px; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; unicode-bidi: normal; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e   [x1,x2] = rollDice();\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.666667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.666667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.666667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.666667px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404.5px 10.2188px; text-wrap: nowrap; transform-origin: 404.5px 10.2188px; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; unicode-bidi: normal; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e   x1 = 5;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.666667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.666667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.666667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.666667px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404.5px 10.2188px; text-wrap: nowrap; transform-origin: 404.5px 10.2188px; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; unicode-bidi: normal; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e   x2 = 2;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [x1,x2] = rollDice()\r\n  x1 = 1;\r\n  x2 = 1;\r\nend","test_suite":"%%\r\nfiletext = fileread('rollDice.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp');\r\nassert(~illegal)\r\n\r\n%%\r\nx1 = zeros(1,6000);\r\nx2 = zeros(1,6000);\r\nfor ii = 1:6000\r\n    [x1(ii),x2(ii)] = rollDice();\r\nend\r\nnumCt = sum( bsxfun( @eq, x1, (1:6)' ), 2 ) + sum( bsxfun( @eq, x2, (1:6)' ), 2 );\r\nassert(all(round(numCt/200) == 10) \u0026\u0026 sum(numCt) == 12000)\r\n","published":true,"deleted":false,"likes_count":62,"comments_count":21,"created_by":134,"edited_by":427930,"edited_at":"2024-08-01T11:35:52.000Z","deleted_by":null,"deleted_at":null,"solvers_count":10717,"test_suite_updated_at":"2012-01-30T07:51:11.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-01-30T07:38:01.000Z","updated_at":"2026-04-02T13:47:53.000Z","published_at":"2024-08-01T11:35:52.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eDescription\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\u003eReturn two random integers between 1 and 6, inclusive, to simulate rolling 2 dice.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\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[   [x1,x2] = rollDice();\\n   x1 = 5;\\n   x2 = 2;]]\u003e\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":641,"title":"Make a random, non-repeating vector.","description":"This is a basic MATLAB operation. It is for instructional purposes.\r\n\r\n---\r\n\r\nIf you want to get a random permutation of integers \u003chttp://www.mathworks.com/help/techdoc/ref/randperm.html randperm\u003e will help.\r\n\r\nGiven n, put the integers [1 2 3... N] in a random order.\r\n\r\nYes, the test suite is not conclusive, but it is pretty close!","description_html":"\u003cp\u003eThis is a basic MATLAB operation. It is for instructional purposes.\u003c/p\u003e\u003cp\u003e---\u003c/p\u003e\u003cp\u003eIf you want to get a random permutation of integers \u003ca href=\"http://www.mathworks.com/help/techdoc/ref/randperm.html\"\u003erandperm\u003c/a\u003e will help.\u003c/p\u003e\u003cp\u003eGiven n, put the integers [1 2 3... N] in a random order.\u003c/p\u003e\u003cp\u003eYes, the test suite is not conclusive, but it is pretty close!\u003c/p\u003e","function_template":"function vec = makeRandomOrdering(n)\r\n  vec = n;\r\nend","test_suite":"%%\r\nn = 10;\r\n\r\nflagSame    = isequal(makeRandomOrdering(n), makeRandomOrdering(n));\r\nflagAllUsed = isequal([1:n],sort(makeRandomOrdering(n)));\r\nassert(~flagSame \u0026 flagAllUsed)","published":true,"deleted":false,"likes_count":48,"comments_count":2,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11259,"test_suite_updated_at":"2012-04-30T20:15:56.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-04-30T20:13:04.000Z","updated_at":"2026-04-03T02:23:02.000Z","published_at":"2012-04-30T20:15:56.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 basic MATLAB operation. It is for instructional purposes.\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\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\u003eIf you want to get a random permutation of integers\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/help/techdoc/ref/randperm.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erandperm\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e will help.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven n, put the integers [1 2 3... N] in a random order.\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\u003eYes, the test suite is not conclusive, but it is pretty close!\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":1227,"title":"Generate a random matrix A of (1,-1)","description":"Input n: is an positive integer which serves as the dimension of the matrix A;\r\n\r\nOutput: A=(Aij),where each entry Aij is either 1 or -1 which is generated\r\nrandomly. \r\n\r\nFor n\u003c1 the function should deliver an empty matrix.","description_html":"\u003cp\u003eInput n: is an positive integer which serves as the dimension of the matrix A;\u003c/p\u003e\u003cp\u003eOutput: A=(Aij),where each entry Aij is either 1 or -1 which is generated\r\nrandomly.\u003c/p\u003e\u003cp\u003eFor n\u0026lt;1 the function should deliver an empty matrix.\u003c/p\u003e","function_template":"function y = rand_plusminus1(x)\r\n  y = [-1 1; 1 -1];\r\nend","test_suite":"%% positive integers\r\nx = 5;\r\nassert(isequal(unique(rand_plusminus1(x)),[-1;1]))\r\n\r\n%% one element\r\nx = 1;\r\nassert(isequal(abs(rand_plusminus1(x)),1))\r\n\r\n%% zero =\u003e empty matrix\r\nx = 0;\r\nassert(isequal(rand_plusminus1(x),[]))\r\n\r\n%% positive integers\r\nx = 999;\r\nassert(isequal(unique(rand_plusminus1(x)),[-1;1]))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":3105,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":403,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-01-26T12:05:02.000Z","updated_at":"2026-03-10T18:48:48.000Z","published_at":"2013-01-26T12:06: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\u003eInput n: is an positive integer which serves as the dimension of the matrix A;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: A=(Aij),where each entry Aij is either 1 or -1 which is generated randomly.\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 n\u0026lt;1 the function should deliver an empty matrix.\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":1089,"title":"Create a random vector of integers with given sum","description":"Your task today is to write a function that returns a vector of integer numbers, between, and including, 1 and m, of which the sum is equal to s. Therefore, the length of the vector is determined by m and s.\r\n\r\nFor example, to create a sequence of characters 'A'-'Z', with 'character-sum' (A=1, B=2, Z=26) of 25420, use \r\n\r\n  char(random_sequence(26,25420)+'A'-1)\r\n\r\nThis task is related to \u003chttp://www.mathworks.nl/matlabcentral/cody/problems/1090 problem 1090\u003e\r\n\r\nThe \"Test Suite\" will check the sum, the mean, and the distribution.\r\n\r\nNote: Solutions wrapped in eval(c), inline, str2func, regexprep (dynamic regular expressions), etc, are not appreciated.","description_html":"\u003cp\u003eYour task today is to write a function that returns a vector of integer numbers, between, and including, 1 and m, of which the sum is equal to s. Therefore, the length of the vector is determined by m and s.\u003c/p\u003e\u003cp\u003eFor example, to create a sequence of characters 'A'-'Z', with 'character-sum' (A=1, B=2, Z=26) of 25420, use\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003echar(random_sequence(26,25420)+'A'-1)\r\n\u003c/pre\u003e\u003cp\u003eThis task is related to \u003ca href=\"http://www.mathworks.nl/matlabcentral/cody/problems/1090\"\u003eproblem 1090\u003c/a\u003e\u003c/p\u003e\u003cp\u003eThe \"Test Suite\" will check the sum, the mean, and the distribution.\u003c/p\u003e\u003cp\u003eNote: Solutions wrapped in eval(c), inline, str2func, regexprep (dynamic regular expressions), etc, are not appreciated.\u003c/p\u003e","function_template":"function y = random_sequence(m,s)\r\n  y = m*rand(1,s/m);\r\nend","test_suite":"%%\r\nnocheat = isempty(regexp(evalc('type random_sequence'),'([^f]eval|regexprep|inline|str2func)'));\r\nm = 26;\r\ns = 5000;\r\ny = random_sequence(m,s);\r\nassert(isequal(sum(y),s) \u0026\u0026 abs(mean(y)-m/2)\u003cm*sqrt(m/s)+1/2 \u0026\u0026 isequal(y,round(y)) \u0026\u0026 abs(std(y)-m/sqrt(12))*sqrt(s)/m\u003c2.5 \u0026\u0026 nocheat)\r\n\r\n%%\r\nnocheat = isempty(regexp(evalc('type random_sequence'),'([^f]eval|regexprep|inline|str2func)'));\r\nm = 2;\r\ns = 1000;\r\ny = random_sequence(m,s);\r\nassert(isequal(sum(y),s) \u0026\u0026 abs(mean(y)-m/2)\u003cm*sqrt(m/s)+1/2 \u0026\u0026 isequal(y,round(y)) \u0026\u0026 abs(std(y)-m/sqrt(12))*sqrt(s)/m\u003c2.5 \u0026\u0026 nocheat)\r\n\r\n%%\r\nnocheat = isempty(regexp(evalc('type random_sequence'),'([^f]eval|regexprep|inline|str2func)'));\r\nm = 1000;\r\ns = 100000;\r\ny = random_sequence(m,s);\r\nassert(isequal(sum(y),s) \u0026\u0026 abs(mean(y)-m/2)\u003cm*sqrt(m/s)+1/2 \u0026\u0026 isequal(y,round(y)) \u0026\u0026 abs(std(y)-m/sqrt(12))*sqrt(s^1/m^3)\u003c1 \u0026\u0026 nocheat)","published":true,"deleted":false,"likes_count":4,"comments_count":3,"created_by":6556,"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":1,"created_at":"2012-12-04T09:51:50.000Z","updated_at":"2026-02-02T22:47:10.000Z","published_at":"2012-12-04T09:51:50.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour task today is to write a function that returns a vector of integer numbers, between, and including, 1 and m, of which the sum is equal to s. Therefore, the length of the vector is determined by m and s.\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, to create a sequence of characters 'A'-'Z', with 'character-sum' (A=1, B=2, Z=26) of 25420, use\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[char(random_sequence(26,25420)+'A'-1)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis task 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.nl/matlabcentral/cody/problems/1090\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eproblem 1090\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\u003eThe \\\"Test Suite\\\" will check the sum, the mean, and the distribution.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNote: Solutions wrapped in eval(c), inline, str2func, regexprep (dynamic regular expressions), etc, are not appreciated.\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":44630,"title":"Guess the number I'm thinking of (Part 1)","description":"In this game you are competing against two other people to guess the number that I'm thinking of.\r\nI randomly choose an integer between one and ten (inclusive). I don't provide any clues about the number.\r\nYour first opponent tries to guess the number. They guess randomly.\r\nYour second opponent tries to guess the number. They also guess randomly.\r\nYou try to guess the number. But you guess strategically.\r\nThe winner is the person who guesses my chosen number, or the person who guesses closest to my chosen number. This represents a \"win\".\r\nIf two contestants are equally close, they may share the win, with such a result being declared a \"draw\". (It is a loss for the remaining contestant.) A draw is worth half as much as a win.\r\nEach person hears the guesses stated by any preceding competitors, so you will be aware of the two prior guesses (provided to you as the vector guessesOfOpponents). Moreover, each guess must be unique.\r\nIf everyone guessed randomly, each person should have an equal chance of winning.\r\nIt might seem that you're at a disadvantage, having the last opportunity to guess. But actually you have the advantage of extra knowledge.\r\nBy guessing strategically, you should be able to achieve a success rate of 45% or more, in which\r\nsuccess rate = (wins + draws/2) / games\r\n\r\nRELATED PROBLEM:  \r\nProblem 52323. Guess the number I'm thinking of (Part 2)","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; 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=\"block-size: 484px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 242px; transform-origin: 407px 242px; 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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eIn this game you are competing against two other people to guess the number that I'm thinking of.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003col style=\"block-size: 160px; font-family: Helvetica, Arial, sans-serif; list-style-type: decimal; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 391px 80px; transform-origin: 391px 80px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20px; 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 10px; text-align: left; transform-origin: 363px 10px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eI randomly choose an\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003einteger\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e between\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eone\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e and\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eten\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e (inclusive). I don't provide any clues about the number.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20px; 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 10px; text-align: left; transform-origin: 363px 10px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYour first opponent tries to guess the number. They guess randomly.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20px; 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 10px; text-align: left; transform-origin: 363px 10px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYour second opponent tries to guess the number. They also guess randomly.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20px; 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 10px; text-align: left; transform-origin: 363px 10px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYou try to guess the number. But you guess\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003estrategically\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 40px; 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 20px; text-align: left; transform-origin: 363px 20px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eThe winner is the person who guesses my chosen number, or the person who guesses closest to my chosen number. This represents a \"win\".\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 40px; 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 20px; text-align: left; transform-origin: 363px 20px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eIf two contestants are equally close, they may share the win, with such a result being declared a \"draw\". (It is a loss for the remaining contestant.) A draw is worth half as much as a win.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ol\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eEach person hears the guesses stated by any preceding competitors, so you will be aware of the two prior guesses (provided to you as the vector\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eguessesOfOpponents\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e). Moreover, each guess must be unique.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eIf everyone guessed randomly, each person should have an equal chance of winning.\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eIt might seem that you're at a disadvantage, having the last opportunity to guess. But actually you have the advantage of extra knowledge.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eBy guessing strategically, you should be able to\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eachieve a success rate of 45% or more\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e, in which\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003esuccess rate = (wins + draws/2) / games\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eRELATED PROBLEM:  \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 20px; 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 10px; transform-origin: 391px 10px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"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 10px; text-align: left; transform-origin: 363px 10px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/52323\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 52323. Guess the number I'm thinking of (Part 2)\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = myGuess(guessesOfOpponents)\r\n    y = 42;\r\nend","test_suite":"%% Anti-hacking test\r\nassessFunctionAbsence({'rng', 'RandStream'}, 'FileName','myGuess.m')\r\n\r\n%% Ensure unique guesses of integers, which are in-range\r\nfor j = 1 : 1000\r\n    numberToBeGuessed = randi(10);\r\n    gOO = randperm(10, 2);\r\n    mG = myGuess(gOO);\r\n    assert( mG \u003e= 1  \u0026  mG \u003c= 10 , 'Out of requested range.' )\r\n    u = unique( floor([gOO mG]) );\r\n    assert( length(u) == 3 , 'Your guess must not have been already chosen.' )\r\nend;\r\n\r\n%% maxIts: 20000 = Too small; 30000 = Not quite big enough; 35000 = Just big enough (usually!); 50000 = Big enough (usually!); 100000 = Big enough, plus safety margin \u0026 efficiency incentive (but waste of resources)\r\nmaxIts = 100000;    \r\ntic\r\nfor j = 1 : 10\r\n    WDL = [0 0 0];\r\n    for itn = 1 : maxIts\r\n        numberToBeGuessed = randi(10);\r\n        gOO = randperm(10, 2);\r\n        diffs = abs( [gOO myGuess(gOO)] - numberToBeGuessed );\r\n        winningContestant = find( min(diffs)==diffs );\r\n        if any( winningContestant == 3 ),\r\n            if length(winningContestant) == 1,\r\n                % Win\r\n                WDL(1) = WDL(1) + 1;  \r\n            else\r\n                % Draw\r\n                WDL(2) = WDL(2) + 1;  \r\n            end;\r\n        else\r\n            % Loss\r\n            WDL(3) = WDL(3) + 1;  \r\n        end;\r\n    end;\r\n    successRate = (WDL(1) + WDL(2)/2) / maxIts\r\n    assert( successRate \u003e= 0.45 )\r\nend;\r\ntoc","published":true,"deleted":false,"likes_count":13,"comments_count":6,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":69,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-04T14:00:17.000Z","updated_at":"2026-02-06T20:26:39.000Z","published_at":"2018-05-05T12:29:22.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\u003eIn this game you are competing against two other people to guess the number that I'm thinking of.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eI randomly choose an\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003einteger\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e between\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eone\u003c/w:t\u003e\u003c/w:r\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:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eten\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (inclusive). I don't provide any clues about the number.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour first opponent tries to guess the number. They guess randomly.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour second opponent tries to guess the number. They also guess randomly.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou try to guess the number. But you guess\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estrategically\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe winner is the person who guesses my chosen number, or the person who guesses closest to my chosen number. This represents a \\\"win\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf two contestants are equally close, they may share the win, with such a result being declared a \\\"draw\\\". (It is a loss for the remaining contestant.) A draw is worth half as much as a win.\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\u003eEach person hears the guesses stated by any preceding competitors, so you will be aware of the two prior guesses (provided to you as the vector\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eguessesOfOpponents\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e). Moreover, each guess must be unique.\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 everyone guessed randomly, each person should have an equal chance of winning.\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\u003eIt might seem that you're at a disadvantage, having the last opportunity to guess. But actually you have the advantage of extra knowledge.\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\u003eBy guessing strategically, you should be able to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eachieve a success rate of 45% or more\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, in which\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\u003esuccess rate = (wins + draws/2) / games\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRELATED PROBLEM:  \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:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/52323\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 52323. Guess the number I'm thinking of (Part 2)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":42340,"title":"Fibonacci Decomposition","description":"Every positive integer has a unique decomposition into nonconsecutive Fibonacci numbers f1+f2+ ... Given a positive integer n, return these numbers. \r\n\r\nReturn the vector f = [f1, f2, ...] sorted from smallest to largest. sum(f) = n.\r\n\r\nExamples\r\n\r\n n = 3\r\n f = 3\r\n\r\n n = 32\r\n f = [3 8 21]\r\n\r\nReference: \u003chttp://www.johndcook.com/blog/2015/05/17/fibonacci-number-system/\u003e","description_html":"\u003cp\u003eEvery positive integer has a unique decomposition into nonconsecutive Fibonacci numbers f1+f2+ ... Given a positive integer n, return these numbers.\u003c/p\u003e\u003cp\u003eReturn the vector f = [f1, f2, ...] sorted from smallest to largest. sum(f) = n.\u003c/p\u003e\u003cp\u003eExamples\u003c/p\u003e\u003cpre\u003e n = 3\r\n f = 3\u003c/pre\u003e\u003cpre\u003e n = 32\r\n f = [3 8 21]\u003c/pre\u003e\u003cp\u003eReference: \u003ca href = \"http://www.johndcook.com/blog/2015/05/17/fibonacci-number-system/\"\u003ehttp://www.johndcook.com/blog/2015/05/17/fibonacci-number-system/\u003c/a\u003e\u003c/p\u003e","function_template":"function f = fib_decomposition(n)\r\n  f = 1;\r\nend","test_suite":"%%\r\nn = 1;\r\nf_correct = 1;\r\nassert(isequal(fib_decomposition(n),f_correct))\r\n\r\n%%\r\nn = 4;\r\nf_correct = [1 3];\r\nassert(isequal(fib_decomposition(n),f_correct))\r\n\r\n%%\r\nn = 6;\r\nf_correct = [1 5];\r\nassert(isequal(fib_decomposition(n),f_correct))\r\n\r\n%%\r\nn = 2010;\r\nf_correct = [2 34 377 1597];\r\nassert(isequal(fib_decomposition(n),f_correct))\r\n\r\n%%\r\nn = 35601;\r\nf_correct = [1 34 144 6765 28657];\r\nassert(isequal(fib_decomposition(n),f_correct))\r\n\r\n%%\r\nn = 9227467;\r\nf_correct = [2 9227465];\r\nassert(isequal(fib_decomposition(n),f_correct))\r\n\r\n%%\r\nn = 2015;\r\nf_correct = [2 5 34 377 1597];\r\nassert(isequal(fib_decomposition(n),f_correct))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":16,"comments_count":2,"created_by":7,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":925,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-05-28T16:03:19.000Z","updated_at":"2026-03-31T16:36:14.000Z","published_at":"2015-05-28T16:04: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:r\u003e\u003cw:t\u003eEvery positive integer has a unique decomposition into nonconsecutive Fibonacci numbers f1+f2+ ... Given a positive integer n, return 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn the vector f = [f1, f2, ...] sorted from smallest to largest. sum(f) = 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ n = 3\\n f = 3\\n\\n n = 32\\n f = [3 8 21]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReference:\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.johndcook.com/blog/2015/05/17/fibonacci-number-system/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://www.johndcook.com/blog/2015/05/17/fibonacci-number-system/\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":621,"title":"Cryptomath: Addition","description":"    W A I T\r\n  +   A L L\r\n  ---------\r\n  G I F T S\r\n\r\nequals:\r\n\r\n    9 6 0 8\r\n  +   6 7 7\r\n  ---------\r\n  1 0 2 8 5\r\n\r\nGiven strings a,b,c find where a + b = c;  No left hand zeros.  All solutions are believed to be unique.\r\n\r\nBeware, the test machine might time out your entry!\r\n\r\nIf you want some easier problems that build up to this one, \r\n\r\n* \u003chttp://www.mathworks.com/matlabcentral/cody/problems/641-make-a-random-non-repeating-vector random permutations of integers\u003e\r\n* \u003chttp://www.mathworks.com/matlabcentral/cody/problems/640-do-a-binary-comparison-on-a-vector binary comparisons\u003e\r\n* \u003chttp://www.mathworks.com/matlabcentral/cody/problems/639-string-substitution-sub-problem-to-cryptomath string substitution\u003e \r\n* \u003chttp://www.mathworks.com/matlabcentral/cody/problems/642-convert-a-vector-into-a-number convert list of numbers to a scalar\u003e\r\n\r\nWhy are the above building blocks to solving this problem?  Well, let's think about the \u003chttp://c2.com/xp/DoTheSimplestThingThatCouldPossiblyWork.html simplest thing that could possibly work.\u003e\r\n\r\nIf we \r\n\r\n* Made random mapping of the ten or less characters to the ten digits\r\n* Converted the characters to a vector of numbers\r\n* Converted the vector of numbers to a scalar\r\n* Checked the scalars in the summation\r\n* Tried again if it did not work\r\n\r\nEventually, we would find the correct answer.  Worst case scenario, we have a one in 10! (1/3,600,000) chance of stumbling upon the answer.  For the eight character case, it is 8! (1/40,320).  I like those odds enough that it is worth trying.\r\n\r\nA \u003chttp://www.mathworks.com/matlabcentral/cody/problems/648-cumulative-probability-of-finding-an-unlikely-combination supplemental problem\u003e finds out which technique, methodical or random is better.","description_html":"\u003cpre\u003e    W A I T\r\n  +   A L L\r\n  ---------\r\n  G I F T S\u003c/pre\u003e\u003cp\u003eequals:\u003c/p\u003e\u003cpre\u003e    9 6 0 8\r\n  +   6 7 7\r\n  ---------\r\n  1 0 2 8 5\u003c/pre\u003e\u003cp\u003eGiven strings a,b,c find where a + b = c;  No left hand zeros.  All solutions are believed to be unique.\u003c/p\u003e\u003cp\u003eBeware, the test machine might time out your entry!\u003c/p\u003e\u003cp\u003eIf you want some easier problems that build up to this one,\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ca href=\"http://www.mathworks.com/matlabcentral/cody/problems/641-make-a-random-non-repeating-vector\"\u003erandom permutations of integers\u003c/a\u003e\u003c/li\u003e\u003cli\u003e\u003ca href=\"http://www.mathworks.com/matlabcentral/cody/problems/640-do-a-binary-comparison-on-a-vector\"\u003ebinary comparisons\u003c/a\u003e\u003c/li\u003e\u003cli\u003e\u003ca href=\"http://www.mathworks.com/matlabcentral/cody/problems/639-string-substitution-sub-problem-to-cryptomath\"\u003estring substitution\u003c/a\u003e\u003c/li\u003e\u003cli\u003e\u003ca href=\"http://www.mathworks.com/matlabcentral/cody/problems/642-convert-a-vector-into-a-number\"\u003econvert list of numbers to a scalar\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eWhy are the above building blocks to solving this problem?  Well, let's think about the \u003ca href=\"http://c2.com/xp/DoTheSimplestThingThatCouldPossiblyWork.html\"\u003esimplest thing that could possibly work.\u003c/a\u003e\u003c/p\u003e\u003cp\u003eIf we\u003c/p\u003e\u003cul\u003e\u003cli\u003eMade random mapping of the ten or less characters to the ten digits\u003c/li\u003e\u003cli\u003eConverted the characters to a vector of numbers\u003c/li\u003e\u003cli\u003eConverted the vector of numbers to a scalar\u003c/li\u003e\u003cli\u003eChecked the scalars in the summation\u003c/li\u003e\u003cli\u003eTried again if it did not work\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eEventually, we would find the correct answer.  Worst case scenario, we have a one in 10! (1/3,600,000) chance of stumbling upon the answer.  For the eight character case, it is 8! (1/40,320).  I like those odds enough that it is worth trying.\u003c/p\u003e\u003cp\u003eA \u003ca href=\"http://www.mathworks.com/matlabcentral/cody/problems/648-cumulative-probability-of-finding-an-unlikely-combination\"\u003esupplemental problem\u003c/a\u003e finds out which technique, methodical or random is better.\u003c/p\u003e","function_template":"function out = cryptoAdd(aStr,bStr,cStr)\r\n  aNum = 1;\r\n  bNum = 1;\r\n  cNum = 2;\r\n\r\nout = [aNum, bNum, cNum];\r\nend","test_suite":"%%\r\naStr = 'dan';\r\nbStr = 'nan';\r\ncStr = 'nora';\r\n\r\nout = [921 121 1042];\r\n\r\nassert(isequal(cryptoAdd(aStr,bStr,cStr),out))\r\n\r\n%%\r\naStr = 'wait';\r\nbStr = 'all';\r\ncStr = 'gifts';\r\n\r\nout = [9608 677 10285];\r\n\r\nassert(isequal(cryptoAdd(aStr,bStr,cStr),out))\r\n%%\r\naStr = 'memo';\r\nbStr = 'from';\r\ncStr = 'homer';\r\n\r\nout = [8485 7358 15843];\r\n\r\nassert(isequal(cryptoAdd(aStr,bStr,cStr),out))\r\n%%\r\n%aStr = 'coca';\r\n%bStr = 'cola';\r\n%cStr = 'oasis';\r\n\r\n%out = [8186 8106 16292];\r\n\r\n%assert(isequal(cryptoAdd(aStr,bStr,cStr),out))","published":true,"deleted":false,"likes_count":2,"comments_count":9,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":44,"test_suite_updated_at":"2012-04-25T19:43:33.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-04-25T16:00:11.000Z","updated_at":"2026-04-03T20:11:56.000Z","published_at":"2012-04-25T18:37:25.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    W A I T\\n  +   A L L\\n  ---------\\n  G I F T S]]\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\u003eequals:\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[    9 6 0 8\\n  +   6 7 7\\n  ---------\\n  1 0 2 8 5]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven strings a,b,c find where a + b = c; No left hand zeros. All solutions are believed to be unique.\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\u003eBeware, the test machine might time out your entry!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf you want some easier problems that build up to this one,\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:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/641-make-a-random-non-repeating-vector\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erandom permutations of integers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/640-do-a-binary-comparison-on-a-vector\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ebinary comparisons\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/639-string-substitution-sub-problem-to-cryptomath\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estring substitution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/642-convert-a-vector-into-a-number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003econvert list of numbers to a scalar\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\u003eWhy are the above building blocks to solving this problem? Well, let's think about the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://c2.com/xp/DoTheSimplestThingThatCouldPossiblyWork.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esimplest thing that could possibly work.\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\u003eIf we\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\u003eMade random mapping of the ten or less characters to the ten digits\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\u003eConverted the characters to a vector of numbers\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\u003eConverted the vector of numbers to a scalar\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\u003eChecked the scalars in the summation\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\u003eTried again if it did not work\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\u003eEventually, we would find the correct answer. Worst case scenario, we have a one in 10! (1/3,600,000) chance of stumbling upon the answer. For the eight character case, it is 8! (1/40,320). I like those odds enough that it is worth trying.\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\u003eA\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/648-cumulative-probability-of-finding-an-unlikely-combination\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esupplemental problem\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e finds out which technique, methodical or random is better.\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":1873,"title":"Break it up!  Break it up!","description":"You have N pennies.  Write a Matlab script that will reveal how many different ways you can break up those pennies.  For example, with 5 pennies, there are seven different ways you can divide them:\r\n\r\n* (1,1,1,1,1)\r\n* (2,1,1,1)\r\n* (2,2,1)\r\n* (3,2)\r\n* (3,1,1)\r\n* (4,1)\r\n* (5)\r\n\r\nThe order of the coins does not matter, so (2,2,1) is considered the same combination as (2,1,2).  You can assume that N will always be a positive integer.","description_html":"\u003cp\u003eYou have N pennies.  Write a Matlab script that will reveal how many different ways you can break up those pennies.  For example, with 5 pennies, there are seven different ways you can divide them:\u003c/p\u003e\u003cul\u003e\u003cli\u003e(1,1,1,1,1)\u003c/li\u003e\u003cli\u003e(2,1,1,1)\u003c/li\u003e\u003cli\u003e(2,2,1)\u003c/li\u003e\u003cli\u003e(3,2)\u003c/li\u003e\u003cli\u003e(3,1,1)\u003c/li\u003e\u003cli\u003e(4,1)\u003c/li\u003e\u003cli\u003e(5)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe order of the coins does not matter, so (2,2,1) is considered the same combination as (2,1,2).  You can assume that N will always be a positive integer.\u003c/p\u003e","function_template":"function y = partitions(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;y_correct = 1;assert(isequal(partitions(x),y_correct))\r\n%%\r\nx = 5;y_correct = 7;assert(isequal(partitions(x),y_correct))\r\n%%\r\nx = 50;y_correct = 204226;assert(isequal(partitions(x),y_correct))\r\n%%\r\nassert(isequal(partitions(partitions(partitions(partitions(5)))),476715857290));\r\n%%\r\nassert(isequal(partitions(partitions(partitions(6))),526823));\r\n%%\r\nassert(isequal(partitions(partitions(12)),10619863));\r\n%%\r\nassert(isequal(partitions(199),3646072432125))\r\n%%\r\nP=arrayfun(@(x) partitions(x),10:10:100);\r\ny_correct=[42 627 5604 37338 204226 966467 4087968 15796476 56634173 190569292];\r\nassert(all(isequal(P,y_correct)))","published":true,"deleted":false,"likes_count":4,"comments_count":4,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":81,"test_suite_updated_at":"2016-08-19T11:36:33.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-13T18:34:19.000Z","updated_at":"2026-04-03T20:00:35.000Z","published_at":"2013-09-13T18:34: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\u003eYou have N pennies. Write a Matlab script that will reveal how many different ways you can break up those pennies. For example, with 5 pennies, there are seven different ways you can divide them:\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\u003e(1,1,1,1,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\u003e(2,1,1,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\u003e(2,2,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\u003e(3,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\u003e(3,1,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\u003e(4,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\u003e(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\u003eThe order of the coins does not matter, so (2,2,1) is considered the same combination as (2,1,2). You can assume that N will always be a positive integer.\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":1288,"title":"Balanced Ternary Numbers: Easy as |, |-, |o","description":"This problem concerns the so-called \u003chttp://en.wikipedia.org/wiki/Balanced_ternary balanced ternary\u003e system for representing numbers. It is a Base 3 system in which the digits can be 1, 0, or -1. \r\n\r\nIn balanced ternary, the number 8 would be represented as 9 (or 3^2) minus 1 (or 3^0). Typographically we will use \"|\" for one, \"o\" for zero (that's a lower-case O), and \"-\" for negative one. So if the decimal input d is the number 8, the balanced ternary output is the string \"|o-\". Thus\r\n \r\n dec 8  =\u003e bt \"|o-\"\r\n\r\nHere are some more examples.\r\n\r\n dec 3  =\u003e bt \"|o\"\r\n dec 15 =\u003e bt \"|--o\"\r\n dec 52 =\u003e bt \"|-o-|\"\r\n \r\nGiven an integer d, return the string bt. Leading zeros should always be suppressed.","description_html":"\u003cp\u003eThis problem concerns the so-called \u003ca href = \"http://en.wikipedia.org/wiki/Balanced_ternary\"\u003ebalanced ternary\u003c/a\u003e system for representing numbers. It is a Base 3 system in which the digits can be 1, 0, or -1.\u003c/p\u003e\u003cp\u003eIn balanced ternary, the number 8 would be represented as 9 (or 3^2) minus 1 (or 3^0). Typographically we will use \"|\" for one, \"o\" for zero (that's a lower-case O), and \"-\" for negative one. So if the decimal input d is the number 8, the balanced ternary output is the string \"|o-\". Thus\u003c/p\u003e\u003cpre\u003e dec 8  =\u003e bt \"|o-\"\u003c/pre\u003e\u003cp\u003eHere are some more examples.\u003c/p\u003e\u003cpre\u003e dec 3  =\u003e bt \"|o\"\r\n dec 15 =\u003e bt \"|--o\"\r\n dec 52 =\u003e bt \"|-o-|\"\u003c/pre\u003e\u003cp\u003eGiven an integer d, return the string bt. Leading zeros should always be suppressed.\u003c/p\u003e","function_template":"function bt = balanced_ternary(d)\r\n  bt = 'o';\r\nend","test_suite":"%%\r\nd = 3;\r\nbt_correct = '|o';\r\nbt = balanced_ternary(d);\r\nassert(isequal(bt,bt_correct))\r\n\r\n%%\r\nd = 52;\r\nbt_correct = '|-o-|';\r\nbt = balanced_ternary(d);\r\nassert(isequal(bt,bt_correct))\r\n\r\n%%\r\nd = 182;\r\nbt_correct = '|-|-|-';\r\nbt = balanced_ternary(d);\r\nassert(isequal(bt,bt_correct))\r\n\r\n%%\r\nd = 26;\r\nbt_correct = '|oo-';\r\nbt = balanced_ternary(d);\r\nassert(isequal(bt,bt_correct))\r\n\r\n%%\r\nd = -5;\r\nbt_correct = '-||';\r\nbt = balanced_ternary(d);\r\nassert(isequal(bt,bt_correct))\r\n\r\n%%\r\nd = -164;\r\nbt_correct = '-|oo-|';\r\nbt = balanced_ternary(d);\r\nassert(isequal(bt,bt_correct))\r\n\r\n%%\r\nd = 512;\r\nbt_correct = '|-o|oo-';\r\nbt = balanced_ternary(d);\r\nassert(isequal(bt,bt_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":7,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":74,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-02-21T23:26:14.000Z","updated_at":"2026-04-03T19:20:00.000Z","published_at":"2013-02-21T23:36:53.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem concerns the so-called\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/Balanced_ternary\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ebalanced ternary\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e system for representing numbers. It is a Base 3 system in which the digits can be 1, 0, or -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\u003eIn balanced ternary, the number 8 would be represented as 9 (or 3^2) minus 1 (or 3^0). Typographically we will use \\\"|\\\" for one, \\\"o\\\" for zero (that's a lower-case O), and \\\"-\\\" for negative one. So if the decimal input d is the number 8, the balanced ternary output is the string \\\"|o-\\\". Thus\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[ dec 8  =\u003e bt \\\"|o-\\\"]]\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\u003eHere are some more examples.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ dec 3  =\u003e bt \\\"|o\\\"\\n dec 15 =\u003e bt \\\"|--o\\\"\\n dec 52 =\u003e bt \\\"|-o-|\\\"]]\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\u003eGiven an integer d, return the string bt. Leading zeros should always be suppressed.\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}}