{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-06T14:01:22.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-04-06T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":44031,"title":"Matrix Manipulation","description":"Given an m*n matrix, see if a matrix contains any 0s in any row. if it contains 0 anywhere in any particular row, delete that row and fill that row with random integer values between 3 to 15. \r\nFor example: mat = [3 2 1 3; 3 0 0 1; 0 4 3 1];\r\nanswer = [3 2 1 3; 4 7 5 12; 4 9 10 14]","description_html":"\u003cp\u003eGiven an m*n matrix, see if a matrix contains any 0s in any row. if it contains 0 anywhere in any particular row, delete that row and fill that row with random integer values between 3 to 15. \r\nFor example: mat = [3 2 1 3; 3 0 0 1; 0 4 3 1];\r\nanswer = [3 2 1 3; 4 7 5 12; 4 9 10 14]\u003c/p\u003e","function_template":"function y = matrixManipulation(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [3 2 1 3; 3 0 0 1; 0 4 3 1];\r\ny = matrixManipulation(x);\r\n\r\nv = 3:15;\r\nassert(isequal(x(1,:),y(1,:)))\r\nassert(isempty(setdiff(y(2,:),v)))\r\nassert(isempty(setdiff(y(3,:),v)))\r\n\r\n%%\r\nx = eye(4);\r\ny = matrixManipulation(x);\r\n\r\nv = 3:15;\r\nfor i = 1:4\r\n assert(isempty(setdiff(y(i,:),v)))\r\nend\r\n\r\n%%\r\nx = ones(4);\r\ny = matrixManipulation(x);\r\nassert(isequal(x,y))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":111192,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":39,"test_suite_updated_at":"2017-01-25T20:25:39.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2017-01-21T05:38:31.000Z","updated_at":"2026-03-02T13:57:32.000Z","published_at":"2017-01-21T05:38:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an m*n matrix, see if a matrix contains any 0s in any row. if it contains 0 anywhere in any particular row, delete that row and fill that row with random integer values between 3 to 15. For example: mat = [3 2 1 3; 3 0 0 1; 0 4 3 1]; answer = [3 2 1 3; 4 7 5 12; 4 9 10 14]\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":44272,"title":"Generate one sample of uniform random numbers between -pi and +pi","description":"Generate one sample of uniform random numbers between -pi and +pi.","description_html":"\u003cp\u003eGenerate one sample of uniform random numbers between -pi and +pi.\u003c/p\u003e","function_template":"function y = rndpi(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nw=0;\r\nfor k=1:10^3\r\n    w=w+rndpi(1);\r\nend\r\n    \r\nassert(w\u003c1000)\r\n\r\n%%\r\nw=0;\r\nfor k=1:10^3\r\n    w=w+rndpi(1)^2;\r\nend\r\n    \r\nassert(w\u003e10^3)\r\n\r\n%% \r\nw=0;\r\nfor k=1:10^3\r\n    w=min(w,rndpi(1));\r\nend\r\n\r\nassert(w\u003c-pi*0.9)\r\nassert(w\u003e-pi*1.1)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":43,"test_suite_updated_at":"2017-08-02T00:03:53.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-08-01T23:59:01.000Z","updated_at":"2026-04-03T06:50:32.000Z","published_at":"2017-08-01T23:59:07.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eGenerate one sample of uniform random numbers between -pi and +pi.\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":2289,"title":"サイコロを作ろう","description":"1から6までの独立かつランダムな数値を返すような関数を作成しましょう。\r\n\r\n例：\r\n\r\n  \u003e\u003e [x1,x2] = rollDice();\r\n\r\nと入力すると\r\n\r\n  x1 = 5\r\n  x2 = 2\r\n\r\nのような解を返します。","description_html":"\u003cp\u003e1から6までの独立かつランダムな数値を返すような関数を作成しましょう。\u003c/p\u003e\u003cp\u003e例：\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u0026gt;\u0026gt; [x1,x2] = rollDice();\r\n\u003c/pre\u003e\u003cp\u003eと入力すると\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ex1 = 5\r\nx2 = 2\r\n\u003c/pre\u003e\u003cp\u003eのような解を返します。\u003c/p\u003e","function_template":"function [x1 x2] = rollDice(x)\r\n  x1 = x;\r\n  x2 = x;\r\nend","test_suite":"%%\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)","published":true,"deleted":false,"likes_count":6,"comments_count":4,"created_by":11824,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":404,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":36,"created_at":"2014-04-16T07:43:57.000Z","updated_at":"2026-03-16T19:03:50.000Z","published_at":"2014-04-16T07:48:39.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\u003e1から6までの独立かつランダムな数値を返すような関数を作成しましょう。\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=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[\u003e\u003e [x1,x2] = rollDice();]]\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\u003eと入力すると\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[x1 = 5\\nx2 = 2]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eのような解を返します。\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2793,"title":"Guess","description":"A random number between 1 and 10 is created for the variable y. Guess what its value is.","description_html":"\u003cp\u003eA random number between 1 and 10 is created for the variable y. Guess what its value is.\u003c/p\u003e","function_template":"function y = guess(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 10;\r\ny_correct = randi(x);\r\nassert(isequal(guess(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":33304,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":90,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-17T14:28:15.000Z","updated_at":"2026-02-18T16:36:34.000Z","published_at":"2014-12-17T14:28:15.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA random number between 1 and 10 is created for the variable y. Guess what its value is.\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":44477,"title":"Find left eigenvector of row stochastic matrix","description":"Find the left eigenvector of the given stochastic matrix P that has eigenvalue 1. \r\nNormalize the vector so the sum of the entries is 1 (called a probability vector). \r\nThe output vector should be a row vector.\r\n\r\n(This can be thought of as a stationary distribution for a Markov chain.\r\n\u003chttps://en.wikipedia.org/wiki/Markov_chain#Finite_state_space\u003e )\r\n\r\nE.g:\r\nFor P = [ .7 .3 ;\r\n          .6 .4 ]\r\nreturn [ .6666666 .3333333 ] (or any vector close to this would be accepted).\r\n\r\nThe left eigenvector v of a matrix P (with eigenvalue 1) is a row vector such that v=v*P. ","description_html":"\u003cp\u003eFind the left eigenvector of the given stochastic matrix P that has eigenvalue 1. \r\nNormalize the vector so the sum of the entries is 1 (called a probability vector). \r\nThe output vector should be a row vector.\u003c/p\u003e\u003cp\u003e(This can be thought of as a stationary distribution for a Markov chain. \u003ca href = \"https://en.wikipedia.org/wiki/Markov_chain#Finite_state_space\"\u003ehttps://en.wikipedia.org/wiki/Markov_chain#Finite_state_space\u003c/a\u003e )\u003c/p\u003e\u003cp\u003eE.g:\r\nFor P = [ .7 .3 ;\r\n          .6 .4 ]\r\nreturn [ .6666666 .3333333 ] (or any vector close to this would be accepted).\u003c/p\u003e\u003cp\u003eThe left eigenvector v of a matrix P (with eigenvalue 1) is a row vector such that v=v*P.\u003c/p\u003e","function_template":"function v = find_left_evector(P)\r\n  v = [ .2 .3 .5];\r\nend","test_suite":"%%\r\nP = [  0.536668396674091   0.463331603325909;\r\n   0.628171641615730   0.371828358384270]\r\npc = [  0.575510558055411   0.424489441944469]\r\nassert(  sum(abs(pc - find_left_evector(P))) \u003c .001 )\r\n\r\n%%\r\nP =[   0.490126287130221   0.063810857836059   0.446062855033720;\r\n   0.351100472099344   0.522156819868217   0.126742708032439;\r\n   0.016119408853126   0.459671543012232   0.524209048134642]\r\npc =  [0.270232959896393   0.376204159405191   0.353562880698251]\r\nassert(  sum(abs(pc - find_left_evector(P))) \u003c .001 )\r\n\r\n%%\r\nP= [   0.000295973934872   0.298979544879362   0.282216466268297   0.418508014917470;\r\n   0.305614143800419   0.169335098209289   0.318119927666875   0.206930830323418;\r\n   0.274040969162178   0.358495094643379   0.257083476284641   0.110380459909802;\r\n   0.362700492263105   0.083477678435433   0.309658548481881   0.244163280819581]\r\npc = [   0.237529575372038   0.234524560057871   0.289883972779590   0.238061891790800]\r\nassert(  sum(abs(pc - find_left_evector(P))) \u003c .001 )\r\n\r\n%%\r\nP =[   0.206900154678670   0.148378489932199   0.322150635982830   0.314216412936451   0.008354306469849;\r\n   0.260256141508665   0.099217372921749   0.160593109350477   0.261083704996893   0.218849671222215;\r\n   0.239143386227262   0.208748199654121   0.157570271848609   0.243411982213855   0.151126160056153;\r\n   0.278091600172443   0.098346886570860   0.258034757795764   0.264131640312126   0.101395115148807;\r\n   0.332707101127035   0.028439807716601   0.229818689497991   0.282967894831867   0.126066506826505]\r\npc = [  0.254374450013656   0.129637934241022   0.235068662146163   0.273627230656508   0.107291722942842]\r\nassert(  sum(abs(pc - find_left_evector(P))) \u003c .001 )\r\n\r\n%% \r\nP = [   0.132301071463971   0.118964494040826   0.133724887078453   0.164995061775188   0.040846954071962   0.145500258220330   0.063426378618235   0.129644361564668   0.066729252864125   0.003867280302243;\r\n   0.132078324816755   0.158842681592186   0.021345097287269   0.116096463338978   0.011399564178502   0.140138687399582   0.177066809582189   0.065776052252923   0.015539976826641   0.161716342724976;\r\n   0.017067043037843   0.083233444933711   0.084600955134299   0.150272784632142   0.123640429188190   0.137325974960960   0.036120936255903   0.135601262483591   0.103142500899762   0.128994668473599;\r\n   0.127071623799322   0.131013361691360   0.060749137485579   0.030485605165969   0.125140409826980   0.094272001681351   0.121644411243946   0.136891396463886   0.033674609302846   0.139057443338763;\r\n   0.084699633418611   0.028081492787019   0.099909358534447   0.168407595038166   0.130764931483391   0.116220306891560   0.110612661554048   0.104402758049448   0.008236859479167   0.148664402764143;\r\n   0.037733369184740   0.169572983103210   0.070941210905428   0.141330441010770   0.114190951485877   0.169117213270117   0.068871861233898   0.031453791309126   0.128616891142078   0.068171287354757;\r\n   0.021608820428507   0.118635979900457   0.091045405806744   0.126644005048004   0.091912863890716   0.097377838242980   0.031186928136198   0.209989895433764   0.076205987507149   0.135392275605482;\r\n   0.200801721742751   0.165730897943703   0.044066996479387   0.107288300031138   0.095274563967673   0.014633627838425   0.006128344875136   0.064690108023551   0.161069824250084   0.140315614848152;\r\n   0.037498791878979   0.007834244109932   0.054720922238198   0.055198093789809   0.174871800390143   0.185715803502670   0.090230412306462   0.198107071552124   0.082250330729007   0.113572529502674;\r\n   0.040849998758864   0.202090814652096   0.005128610576370   0.187791319910819   0.079274530709314   0.157633265466675   0.045977261982389   0.055884488572257   0.156673705328071   0.068696004043146]\r\npc = [ 0.088341588996646   0.125827616221029   0.062738581066497   0.123052908662097   0.095658900658645   0.125218780388122   0.080036509221240   0.105209734515629   0.082635110452906   0.111280269817457]\r\nassert(  sum(abs(pc - find_left_evector(P))) \u003c .001 )\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":65480,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":15,"test_suite_updated_at":"2018-01-03T20:26:54.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-01-03T20:25:00.000Z","updated_at":"2026-03-11T09:48:37.000Z","published_at":"2018-01-03T20:26:54.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the left eigenvector of the given stochastic matrix P that has eigenvalue 1. Normalize the vector so the sum of the entries is 1 (called a probability vector). The output vector should be a row vector.\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(This can be thought of as a stationary distribution for a Markov chain.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Markov_chain#Finite_state_space\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/Markov_chain#Finite_state_space\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt; )\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eE.g: For P = [ .7 .3 ; .6 .4 ] return [ .6666666 .3333333 ] (or any vector close to this would be accepted).\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 left eigenvector v of a matrix P (with eigenvalue 1) is a row vector such that v=v*P.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44315,"title":"Predicting life and death of a memory-less light bulb","description":"*\u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161* \r\n\r\nYou have a light bulb that can fail any moment according to the exponential probability distribution. \r\n\r\nAt any moment, the probability that it will survive just N hours = exp(-N*P), where P is a constant. \r\n\r\nNotice that this probability is very small if N is very large. \r\n\r\nNow suppose, the bulb has already survived N hours. \r\n\r\nPlease calculate the probability of its surviving M more hours.\r\n","description_html":"\u003cp\u003e\u003cb\u003e\u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161\u003c/b\u003e\u003c/p\u003e\u003cp\u003eYou have a light bulb that can fail any moment according to the exponential probability distribution.\u003c/p\u003e\u003cp\u003eAt any moment, the probability that it will survive just N hours = exp(-N*P), where P is a constant.\u003c/p\u003e\u003cp\u003eNotice that this probability is very small if N is very large.\u003c/p\u003e\u003cp\u003eNow suppose, the bulb has already survived N hours.\u003c/p\u003e\u003cp\u003ePlease calculate the probability of its surviving M more hours.\u003c/p\u003e","function_template":"function hope = fate(N,P,M)\r\n  hope=exp(-(N+M)*P);\r\nend","test_suite":"%%\r\nN = 1;\r\nP=1;\r\nM=0;\r\nhope_correct = 1;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN = 1;\r\nP=0;\r\nM=1;\r\nhope_correct = 1;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN=1;\r\nP=1;\r\nM=1;\r\nhope_correct = 0.3679;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN=2;\r\nP=1;\r\nM=1;\r\nhope_correct = 0.3679;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN=2;\r\nP=1;\r\nM=2;\r\nhope_correct = 0.1353;\r\nassert(fate(N,P,M)\u003chope_correct*1.1)\r\n%%\r\nN=2;\r\nP=2;\r\nM=2;\r\nhope_correct = 0.0183;\r\nassert(fate(N,P,M)\u003chope_correct*1.1)\r\n%%","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":336,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-12T02:53:45.000Z","updated_at":"2026-03-25T02:55:11.000Z","published_at":"2017-10-16T01:45:07.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou have a light bulb that can fail any moment according to the exponential probability distribution.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAt any moment, the probability that it will survive just N hours = exp(-N*P), where P is a constant.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNotice that this probability is very small if N is very large.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNow suppose, the bulb has already survived N hours.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePlease calculate the probability of its surviving M more hours.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":43592,"title":"Sample from random roulette","description":"Given a list of values and their probabilities sample 10,000 values.\r\nExample:\r\nx = [1 2 3 4 5];\r\nprob = [0.2 0.1 0.4 0.1 0.2]\r\nNote that sum(prob)=1. Function output should look like this:\r\noutput = [1 4 3 1 4 1 2 3 1 1 1 ... 3 4 2] % a vector of length 10,000\r\nAll vectors are meant to be row vectors.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 194.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 97.15px; transform-origin: 407px 97.15px; 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: 208.5px 8px; transform-origin: 208.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a list of values and their probabilities sample 10,000 values.\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: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 64px 8.5px; tab-size: 4; transform-origin: 64px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ex = [1 2 3 4 5];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 112px 8.5px; tab-size: 4; transform-origin: 112px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eprob = [0.2 0.1 0.4 0.1 0.2]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 190px 8px; transform-origin: 190px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNote that sum(prob)=1. Function output should look like this:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 280px 8.5px; tab-size: 4; transform-origin: 280px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 128px 8.5px; transform-origin: 128px 8.5px; \"\u003eoutput = [1 4 3 1 4 1 2 3 1 1 1 \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); perspective-origin: 12px 8.5px; text-decoration: none; text-decoration-color: rgb(14, 0, 255); text-emphasis-color: rgb(14, 0, 255); transform-origin: 12px 8.5px; \"\u003e...\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); perspective-origin: 140px 8.5px; text-decoration: none; text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); transform-origin: 140px 8.5px; \"\u003e 3 4 2] % a vector of length 10,000\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 124.5px 8px; transform-origin: 124.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAll vectors are meant to be row vectors.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function output = RandomRoulette(x,prob)\r\n    draws = 10000; % Do not change the # of draws\r\n    output = ?;\r\nend","test_suite":"%%\r\nx = 1:3;\r\nprob = [0.3 0.2 0.5];\r\nassert( numel(RandomRoulette(x,prob))==1e4 \u0026\u0026 (sum(RandomRoulette(x,prob))\u003c1.5*22*1e3) \u0026\u0026 (sum(RandomRoulette(x,prob))\u003e0.5*22*1e3) \u0026\u0026 all(ismember(RandomRoulette(x,prob),x)) )\r\n\r\n%%\r\nx = 1:4;\r\nprob = [0.1 0.2 0.3 0.4];\r\nassert( numel(RandomRoulette(x,prob))==1e4 \u0026\u0026 (sum(RandomRoulette(x,prob))\u003c1.5*30*1e3) \u0026\u0026 (sum(RandomRoulette(x,prob))\u003e0.5*30*1e3) \u0026\u0026 all(ismember(RandomRoulette(x,prob),x)) \u0026\u0026 any(RandomRoulette(x,prob)~=RandomRoulette(x,prob)))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":8,"created_by":29461,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":22,"test_suite_updated_at":"2021-11-14T11:00:46.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-22T21:06:06.000Z","updated_at":"2026-01-20T13:29:43.000Z","published_at":"2016-10-22T21:06:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a list of values and their probabilities sample 10,000 values.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[x = [1 2 3 4 5];\\nprob = [0.2 0.1 0.4 0.1 0.2]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNote that sum(prob)=1. Function output should look like this:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[output = [1 4 3 1 4 1 2 3 1 1 1 ... 3 4 2] % a vector of length 10,000]]\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\u003eAll vectors are meant to be row vectors.\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":596,"title":"More luck than brains ","description":"Give a random function that guess and return numbers from 1 to 6 exactly like the test suite .","description_html":"\u003cp\u003eGive a random function that guess and return numbers from 1 to 6 exactly like the test suite .\u003c/p\u003e","function_template":"function y = More_luck_then_brains()\r\n  y = 1 ;\r\nend","test_suite":"%%\r\nassert(isequal(More_luck_then_brains(),randi(6)));\r\n%%\r\nassert(isequal(More_luck_then_brains(),randi(6)));\r\n%%\r\nassert(isequal(More_luck_then_brains(),randi(6)));\r\n;","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":3077,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":69,"test_suite_updated_at":"2012-04-18T10:33:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-04-18T05:12:54.000Z","updated_at":"2025-06-13T07:05:05.000Z","published_at":"2012-04-18T05:14: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\",\"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\u003eGive a random function that guess and return numbers from 1 to 6 exactly like the test suite .\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":51970,"title":"Determine the average number of rounds for the following game.","description":"Each round a uniformly distributed random number is picked between 0 and 1. The game ends when the sum of the random numbers is greater than 1. Find the average number of rounds the game will end in. Note: Use 100,000 trials of the game.\r\n","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: 72px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 36px; transform-origin: 407px 36px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eEach round a uniformly distributed random number is picked between 0 and 1. The game ends when the sum of the random numbers is greater than 1. Find the average number of rounds the game will end in. Note: Use 100,000 trials of the game.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [val] = playgame()\r\n  \r\nend","test_suite":"%%\r\nsol=exp(1);\r\ny_correct = playgame();\r\nassessVariableEqual('y_correct',sol);\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":342621,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":12,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2021-06-04T15:56:32.000Z","updated_at":"2021-06-08T16:49:58.000Z","published_at":"2021-06-04T15:56:32.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\u003eEach round a uniformly distributed random number is picked between 0 and 1. The game ends when the sum of the random numbers is greater than 1. Find the average number of rounds the game will end in. Note: Use 100,000 trials of the game.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\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":699,"title":"Reading Web Binary Files (jpg,pdf,tiff,png)","description":"The Challenge is to access a Web binary file, a PDF in this case, and provide the value of a specific byte.\r\n\r\n.\r\n\r\nAccessing files on the web provide multiple challenges due to the data structures being text or binary.\r\n\r\nThe functions urlread and urlwrite both access web files but provide different results for binary files. (jpg, pdf, tiff, png, ppt)\r\n\r\n\r\n\r\nInput:\r\n\r\nfname 'http://some valid location/file.pdf'\r\n\r\nn      The byte for which the value is being requested.\r\n\r\nOutput: Value of the byte, an integer ranging from 0 to 255\r\n\r\n.\r\n\r\n\r\nA solution exists in the test suite to show the different data created by urlread and urlwrite for binary data.\r\n\r\nA urlreadbin can be readily created to directly push the file to an array.","description_html":"\u003cp\u003eThe Challenge is to access a Web binary file, a PDF in this case, and provide the value of a specific byte.\u003c/p\u003e\u003cp\u003e.\u003c/p\u003e\u003cp\u003eAccessing files on the web provide multiple challenges due to the data structures being text or binary.\u003c/p\u003e\u003cp\u003eThe functions urlread and urlwrite both access web files but provide different results for binary files. (jpg, pdf, tiff, png, ppt)\u003c/p\u003e\u003cp\u003eInput:\u003c/p\u003e\u003cp\u003efname 'http://some valid location/file.pdf'\u003c/p\u003e\u003cp\u003en      The byte for which the value is being requested.\u003c/p\u003e\u003cp\u003eOutput: Value of the byte, an integer ranging from 0 to 255\u003c/p\u003e\u003cp\u003e.\u003c/p\u003e\u003cp\u003eA solution exists in the test suite to show the different data created by urlread and urlwrite for binary data.\u003c/p\u003e\u003cp\u003eA urlreadbin can be readily created to directly push the file to an array.\u003c/p\u003e","function_template":"function y = access_web_pdf(fname,n)\r\n  y = 0;\r\nend","test_suite":"%%\r\n% Cody External accessibility\r\n\r\n% This file may need to change in the future\r\nin_f='http://www.pvplc.org/_volunteer/docs/PVPLC%20Trail%20Crew%20Training%20Jan-Jun%202012.pdf';\r\n\r\nout_f='PVPLC.pdf';\r\n\r\nurlwrite(in_f,out_f);\r\n\r\nfid=fopen(out_f);\r\nurlwrite_out=fread(fid,128,'*uint8'); \r\n% Display Correct Binary Data\r\nurlwrite_out(1:16)'\r\n\r\n\r\nblock=urlread(in_f);\r\n% Display invalid binary data\r\nurlread_out=block(1:16)-char(0)\r\n% unicode urlread conversion affects bytes 12 thru 15\r\n\r\nn=12\r\nbyte_val = access_web_pdf(in_f,n)\r\n\r\nbyte_correct=181;\r\n\r\nassert(isequal(byte_val,byte_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-05-18T04:26:21.000Z","updated_at":"2012-05-21T05:35:07.000Z","published_at":"2012-05-21T05:35:07.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eThe Challenge is to access a Web binary file, a PDF in this case, and provide the value of a specific byte.\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\u003eAccessing files on the web provide multiple challenges due to the data structures being text or binary.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe functions urlread and urlwrite both access web files but provide different results for binary files. (jpg, pdf, tiff, png, ppt)\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\u003eInput:\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\u003efname 'http://some valid location/file.pdf'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en The byte for which the value is being requested.\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: Value of the byte, an integer ranging from 0 to 255\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\u003eA solution exists in the test suite to show the different data created by urlread and urlwrite for binary data.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA urlreadbin can be readily created to directly push the file to an array.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":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":10719,"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-06T20:28:48.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":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":1729,"title":"Can you beat the lottery again (for hardcore coder) ?","description":"Inspired by the Problem 1713 by Chris E.\r\n\r\nHere is the code that generates the first lottery number:\r\n\r\n rng('shuffle');\r\n number1=randi([10,20]);\r\n for j=1:number1\r\n   round(rand(1,1));\r\n end\r\n\r\nCan you find the number even with the rng('shuffle')?\r\n\r\nAs everybody knows hacking methods, I prefer a logical solution.\r\n\r\nGood luck!","description_html":"\u003cp\u003eInspired by the Problem 1713 by Chris E.\u003c/p\u003e\u003cp\u003eHere is the code that generates the first lottery number:\u003c/p\u003e\u003cpre\u003e rng('shuffle');\r\n number1=randi([10,20]);\r\n for j=1:number1\r\n   round(rand(1,1));\r\n end\u003c/pre\u003e\u003cp\u003eCan you find the number even with the rng('shuffle')?\u003c/p\u003e\u003cp\u003eAs everybody knows hacking methods, I prefer a logical solution.\u003c/p\u003e\u003cp\u003eGood luck!\u003c/p\u003e","function_template":"function y = big_lottery()\r\n  y = 0;\r\nend","test_suite":"%%\r\nrng('shuffle');\r\nnumber1=randi([10,20]);\r\nfor j=1:number1\r\n    round(rand(1,1));\r\nend\r\nassert(isequal(big_lottery(),number1))\r\n\r\n%%\r\nrng('shuffle');\r\nnumber2=randi([10,20]);\r\nfor j=1:number2\r\n    round(rand(1,1));\r\nend\r\nassert(isequal(big_lottery(),number2))\r\n\r\n\r\n%%\r\nrng('shuffle');\r\nnumber3=randi([10,20]);\r\nfor j=1:number3\r\n    round(rand(1,1));\r\nend\r\nassert(isequal(big_lottery(),number3))\r\n\r\n","published":true,"deleted":false,"likes_count":7,"comments_count":0,"created_by":5390,"edited_by":427930,"edited_at":"2022-10-11T14:42:55.000Z","deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2013-07-20T19:03:59.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-20T18:08:18.000Z","updated_at":"2022-10-11T14:42:56.000Z","published_at":"2013-07-20T18:08:33.000Z","restored_at":null,"restored_by":null,"spam":null,"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 the Problem 1713 by Chris E.\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 is the code that generates the first lottery number:\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[ rng('shuffle');\\n number1=randi([10,20]);\\n for j=1:number1\\n   round(rand(1,1));\\n end]]\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\u003eCan you find the number even with the rng('shuffle')?\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\u003eAs everybody knows hacking methods, I prefer a logical solution.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGood luck!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":1713,"title":"Can you beat the lottery?","description":"Well this one you may not get every time, but it is a lottery! Here is the code that generates the lottery numbers (you can try to use it to your advantage if you can):\r\n\r\n    check = 1;\r\n    while check == 1\r\n        D1 = round(rand(1,1)*5+1);\r\n        D2 = round(rand(1,1)*5+1);\r\n        D3 = round(rand(1,1)*5+1);\r\n        draw = sort([D1 D2 D3]);\r\n        if size(unique(fn), 2) == 3\r\n            check = 0;\r\n        end\r\n    end\r\n\r\nSo \"draw\" is the draw that is made. It is made up of 3 numbers between 1 and 5.  Note that the numbers do not repeat.  SO an example of an input is:\r\n\r\nlottery = [4 3 5];\r\n\r\nNow the odds are 1 in 10 (or at least that is the total combinations that can occur), so if you get it exactly you win! (you win the correct answer...) \r\n\r\nGood luck, and please play responsibly...","description_html":"\u003cp\u003eWell this one you may not get every time, but it is a lottery! Here is the code that generates the lottery numbers (you can try to use it to your advantage if you can):\u003c/p\u003e\u003cpre\u003e    check = 1;\r\n    while check == 1\r\n        D1 = round(rand(1,1)*5+1);\r\n        D2 = round(rand(1,1)*5+1);\r\n        D3 = round(rand(1,1)*5+1);\r\n        draw = sort([D1 D2 D3]);\r\n        if size(unique(fn), 2) == 3\r\n            check = 0;\r\n        end\r\n    end\u003c/pre\u003e\u003cp\u003eSo \"draw\" is the draw that is made. It is made up of 3 numbers between 1 and 5.  Note that the numbers do not repeat.  SO an example of an input is:\u003c/p\u003e\u003cp\u003elottery = [4 3 5];\u003c/p\u003e\u003cp\u003eNow the odds are 1 in 10 (or at least that is the total combinations that can occur), so if you get it exactly you win! (you win the correct answer...)\u003c/p\u003e\u003cp\u003eGood luck, and please play responsibly...\u003c/p\u003e","function_template":"function draw = lottery()\r\n  draw = [x x x];\r\nend","test_suite":"%%\r\ncheck = 1;\r\nwhile check == 1\r\n     D1 = round(rand(1,1)*4+1);\r\n     D2 = round(rand(1,1)*4+1);\r\n     D3 = round(rand(1,1)*4+1);\r\n     draw = sort([D1 D2 D3]);\r\n        if size(unique(draw), 2) == 3\r\n            check = 0;\r\n        end\r\nend\r\nassert(isequal(sort(lottery()),draw))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":15013,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":48,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-12T21:15:43.000Z","updated_at":"2025-11-17T20:59:24.000Z","published_at":"2013-07-12T22:07:45.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\u003eWell this one you may not get every time, but it is a lottery! Here is the code that generates the lottery numbers (you can try to use it to your advantage if you can):\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[    check = 1;\\n    while check == 1\\n        D1 = round(rand(1,1)*5+1);\\n        D2 = round(rand(1,1)*5+1);\\n        D3 = round(rand(1,1)*5+1);\\n        draw = sort([D1 D2 D3]);\\n        if size(unique(fn), 2) == 3\\n            check = 0;\\n        end\\n    end]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSo \\\"draw\\\" is the draw that is made. It is made up of 3 numbers between 1 and 5. Note that the numbers do not repeat. SO an example of an input is:\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\u003elottery = [4 3 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\u003eNow the odds are 1 in 10 (or at least that is the total combinations that can occur), so if you get it exactly you win! (you win the correct answer...)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGood luck, and please play responsibly...\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":2356,"title":"Simulating the selection of a state with given probabilities","description":"Lets say we have 3 different states [1,2,3] with the probabilities of occurrences of each state is given as [0.5 0.2 0.3]. Which means 50% state 1 will be selected among others. Generate randomly selected states with the probabilities given\r\n\r\nOutput array will be consisting of state numbers based on the probabilities given as input. \r\n\r\nExample:\r\n(Quick tip: The higher simulation sampling sizes the more robust results)","description_html":"\u003cp\u003eLets say we have 3 different states [1,2,3] with the probabilities of occurrences of each state is given as [0.5 0.2 0.3]. Which means 50% state 1 will be selected among others. Generate randomly selected states with the probabilities given\u003c/p\u003e\u003cp\u003eOutput array will be consisting of state numbers based on the probabilities given as input.\u003c/p\u003e\u003cp\u003eExample:\r\n(Quick tip: The higher simulation sampling sizes the more robust results)\u003c/p\u003e","function_template":"function states = select_state(probs)\r\n  states = 0;\r\nend","test_suite":"%%\r\nprobs = rand;\r\nwhile sum(probs) \u003c 1\r\n    a = rand;\r\n    if a + sum(probs) \u003e 1\r\n        probs = [probs 1-sum(probs)];\r\n        break;\r\n    else\r\n        probs = [probs a];\r\n    end\r\nend\r\n\r\nstates = 1:length(probs);\r\nfor i = 1:100\r\n    y{i,1} = select_state(probs);\r\n    [nelements,centers] = hist(y{i},states);\r\n    probs_result{i} = nelements/length(y{i});\r\n    error(i,1) = sum(abs(probs-probs_result{i}));\r\nend\r\n\r\nassert(mean(error) \u003c= 0.05 \u0026 mean(error) \u003e 0);","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":27005,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":29,"test_suite_updated_at":"2014-06-11T14:25:30.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2014-06-11T00:57:51.000Z","updated_at":"2025-11-21T18:44:38.000Z","published_at":"2014-06-11T01:00:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eLets say we have 3 different states [1,2,3] with the probabilities of occurrences of each state is given as [0.5 0.2 0.3]. Which means 50% state 1 will be selected among others. Generate randomly selected states with the probabilities given\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 array will be consisting of state numbers based on the probabilities given as input.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample: (Quick tip: The higher simulation sampling sizes the more robust results)\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":46568,"title":"Beat the RNG - EASY","description":null,"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: 110.71px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.989px 55.3551px; transform-origin: 406.996px 55.3551px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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=\"\"\u003eGenerate random n-by-m matrices.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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=\"font-style: italic; \"\u003eBut\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 generate the same matrices as in the Test Suite.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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=\"\"\u003eRead the manual. \u0026gt;:)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20px; border-bottom-left-radius: 4px; border-bottom-right-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: 403.991px 10px; transform-origin: 403.999px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ehelp \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003erandi\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = cheeseRNG(m, n)\r\n  y = randi(m, n)\r\nend","test_suite":"%%\r\nm = 1;\r\nn = 1;\r\nassert(isequal(cheeseRNG(m,n),randi(m,n)))\r\n\r\n%%\r\nm = 5;\r\nn = 4;\r\nassert(isequal(cheeseRNG(m,n),randi(m,n)))\r\n\r\n%%\r\nm = 10;\r\nn = 15;\r\nassert(isequal(cheeseRNG(m,n),randi(m,n)))\r\n\r\n%%\r\nm = 1337;\r\nn = 42;\r\nassert(isequal(cheeseRNG(m,n),randi(m,n)))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":543257,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-08-28T23:56:07.000Z","updated_at":"2025-11-19T17:08:00.000Z","published_at":"2020-08-29T00:32:14.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\u003eGenerate random n-by-m matrices.\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eBut\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e generate the same matrices as in the Test Suite.\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\u003eRead the manual. \u0026gt;:)\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[help randi]]\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":52323,"title":"Guess the number I'm thinking of (Part 2)","description":"Have you tried the original \"Guess the number I'm thinking of\" (Problem 44630)?  This problem is just like that, except that the range of possible numbers can change, and pre-calculated answers are explicitly disallowed.  Computing all possible permutations on the fly is not disallowed per se, but it is discouraged due to the high computational load involved.  \r\nIn 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 N (inclusive).  N is an integer between 4 and 1000 (inclusive) that will be specified in each test as upperLimit.  I don't provide any other clues about the number that is to be guessed.\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 substantially better than 33.3%.  The success rate is defined as follows.  \r\nsuccess rate = (wins + draws/2) / games\r\nThe precise value of the expected success rate (when guessing with the optimal strategy) depends upon the value of N:  when N = 4 you should be able to achieve a success rate of 17/48 ≈ 35.4% on average, increasing monotonically to above 50% for N ≥ 24, eventually approaching an asymptote of 19/36 ≈ 52.8%.  (See the Test Suite for details of the thresholds applied.) \r\n\r\nRELATED PROBLEM:  \r\nProblem 44630. Guess the number I'm thinking of (Part 1)","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: 691px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 345.5px; transform-origin: 407px 345.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; 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 31.5px; text-align: left; transform-origin: 384px 31.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=\"font-style: italic; \"\u003eHave you tried the original \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://au.mathworks.com/matlabcentral/cody/problems/44630-guess-the-number-i-m-thinking-of\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"font-style: italic; \"\u003e\"Guess the number I'm thinking of\" (Problem 44630)\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e?  This problem is just like that, except that the range of possible numbers can change, and pre-calculated answers are explicitly disallowed.  Computing all possible permutations on the fly is not disallowed per se, but it is discouraged due to the high computational load involved.  \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=\"\"\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: 181px; 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 90.5px; transform-origin: 391px 90.5px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 41px; 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 20.5px; text-align: left; transform-origin: 363px 20.5px; 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-style: italic; font-weight: 700; \"\u003eN\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).  \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; font-weight: 700; \"\u003eN\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 is an integer between 4 and 1000 (inclusive) that will be specified in each test as \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-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eupperLimit\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.  I don't provide any other clues about the number that is to be guessed.\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: 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=\"\"\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 substantially better than 33.3%\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.  The success rate is defined as follows.  \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: 84px; 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 42px; text-align: left; transform-origin: 384px 42px; 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=\"\"\u003eThe precise value of the expected success rate (when guessing with the optimal strategy) depends upon the value of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eN\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:  when \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-style: italic; \"\u003eN\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 = 4 you should be able to achieve a success rate of 17/48 ≈ 35.4% on average, increasing monotonically to above 50% for \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-style: italic; \"\u003eN\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 ≥ 24, eventually approaching an asymptote of 19/36 ≈ 52.8%.  (See the Test Suite for details of the thresholds applied.) \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/44630\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 44630. Guess the number I'm thinking of (Part 1)\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(upperLimit, guessesOfOpponents)\r\n    y = 42;\r\nend","test_suite":"%% Anti-hacking test.\r\nassessFunctionAbsence({'rng', 'RandStream'}, 'FileName','myGuess.m')\r\n\r\n%% Anti-precalculation test.\r\n% Do not try to get evade the test.  Just follow the clear rule:  DO NOT PRECALCULATE.\r\nassessFunctionAbsence({'sub2ind', 'str2num'}, 'FileName','myGuess.m')\r\n\r\n% And while we're at it, I dislike the practice of using \"ans\" in a script.  \r\nassessFunctionAbsence({'ans'}, 'FileName','myGuess.m')\r\n\r\n% And you don't really need regexp or regexpi eithr.\r\nassessFunctionAbsence({'regexp', 'regexpi'}, 'FileName','myGuess.m')\r\n\r\n%% Ensure unique guesses of integers, which are in-range.\r\nfor j = 1 : 1000\r\n    upperLim = randi([4, 1000]);\r\n    numberToBeGuessed = randi(upperLim);\r\n    gOO = randperm(upperLim, 2);\r\n    mG = myGuess(upperLim, gOO);\r\n    assert( mG \u003e= 1  \u0026  mG \u003c= upperLim , '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%% Check the success rate several times for various values of N.\r\nmaxIts = 50000;    % 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\ntic\r\nfor j = 1 : 12\r\n%for j = 5 : 20 : 1000\r\n    %upperLim = 3 + j;\r\n    if j \u003c= 4,\r\n        % Focus on smaller N.\r\n        upperLim = randi([4, 10]);\r\n    elseif j \u003c= 8,\r\n        % Focus on intermediate N.\r\n        upperLim = randi([11, 40]);\r\n    else\r\n        % Focus on larger N.\r\n        upperLim = randi([41, 1000]);\r\n    end;\r\n    WDL = [0 0 0];\r\n    for itn = 1 : maxIts\r\n        numberToBeGuessed = randi(upperLim);\r\n        gOO = randperm(upperLim, 2);\r\n        diffs = abs( [gOO myGuess(upperLim, 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    minAcceptableSuccessRate = getCutoff(upperLim);\r\n    %[upperLim minAcceptableSuccessRate successRate]\r\n    fprintf('N = %u, Threshold = %5.2f %c, Success rate = %5.2f %c.\\r\\n', upperLim, minAcceptableSuccessRate*100, '%', successRate*100, '%');\r\n    assert( successRate \u003e= minAcceptableSuccessRate )\r\nend;\r\ntoc\r\n\r\n% Define the minimum success rate that must be achieved.  \r\n% Note:  functions must be defined at the end of a script.  See https://au.mathworks.com/help/matlab/ref/function.html?s_tid=doc_ta#description\r\nfunction threshold = getCutoff(N)\r\n    % The success rate as a function of N is fit quite well \r\n    % by an equation of the form  s = sInf – A / N^k\r\n    expectedSuccessRate = 0.527353226 - 0.740005 / N^1.050420528;   \r\n    % (From fitting 310 points recorded to four decimal places.  \r\n    % The coefficients appear to be accurate to at least 3 significant figures.)  \r\n\r\n    % However, practically speaking we need to include a safety margin\r\n    % to avoid failing correct solutions on account of stochastic fluctuations.  \r\n    % A safety margin of 1 percentage point is almost always enough.  \r\n    % (1.5 percentage points would allow even more natural fluctuation, but would also risk passing incorrect 'solutions'.)  \r\n    threshold = expectedSuccessRate - 0.010;\r\nend","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":"2021-07-19T10:43:08.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2021-07-18T11:23:40.000Z","updated_at":"2021-07-25T08:12:28.000Z","published_at":"2021-07-18T15:01:47.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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eHave you tried the original \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://au.mathworks.com/matlabcentral/cody/problems/44630-guess-the-number-i-m-thinking-of\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Guess the number I'm thinking of\\\" (Problem 44630)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e?  This problem is just like that, except that the range of possible numbers can change, and pre-calculated answers are explicitly disallowed.  Computing all possible permutations on the fly is not disallowed per se, but it is discouraged due to the high computational load involved.  \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\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\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (inclusive).  \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is an integer between 4 and 1000 (inclusive) that will be specified in each test as \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\u003eupperLimit\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.  I don't provide any other clues about the number that is to be guessed.\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 substantially better than 33.3%\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.  The success rate is defined as follows.  \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\u003eThe precise value of the expected success rate (when guessing with the optimal strategy) depends upon the value of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:  when \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e = 4 you should be able to achieve a success rate of 17/48 ≈ 35.4% on average, increasing monotonically to above 50% for \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ≥ 24, eventually approaching an asymptote of 19/36 ≈ 52.8%.  (See the Test Suite for details of the thresholds applied.) \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/44630\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44630. Guess the number I'm thinking of (Part 1)\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":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":46585,"title":"Beat the RNG - Passwords","description":null,"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: 301.52px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.989px 150.753px; transform-origin: 406.996px 150.76px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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=\"\"\u003eThe Test Suite randomly generates a list of 1024 passwords.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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=\"\"\u003eGiven the source code and one generated password, return the complete list of all passwords.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 100px; border-bottom-left-radius: 4px; border-bottom-right-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: 403.991px 50px; transform-origin: 403.999px 50px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e% Password generator source code\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003erng(\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'shuffle'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ealphanum = [\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'a'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e:\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'z' 'A'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e:\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'Z' '0'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e:\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'9'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003epasswords = string(alphanum(randi([1 length(alphanum)], [1024 6])));\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003erng(\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'shuffle'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.9091px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eContinuation of \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/46568-beat-the-rng-easy\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 46568\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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=\"\"\u003eRead the manual. \u0026gt;:)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40px; border-bottom-left-radius: 4px; border-bottom-right-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: 403.991px 20px; transform-origin: 403.999px 20px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ehelp \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003erandi\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ehelp \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003erng\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":" function y = get_all_passwords(x)\r\n    alphanum = ['a':'z' 'A':'Z' '0':'9'];\r\n    y = string(alphanum(randi([1 length(alphanum)], [1024 6])));\r\n end","test_suite":"%%\r\n\r\n% Randomly generate 1024 alphanumeric strings\r\nrng('shuffle')\r\nalphanum = ['a':'z' 'A':'Z' '0':'9'];\r\npasswords = string(alphanum(randi([1 length(alphanum)], [1024 6])));\r\nrng('shuffle')\r\n\r\n%\r\nx = passwords(8);\r\ny = get_all_passwords(x);\r\n\r\nassert(isequal(passwords,y))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":543257,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":6,"test_suite_updated_at":"2020-09-18T03:34:59.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-09-15T00:14:36.000Z","updated_at":"2020-09-18T03:45:47.000Z","published_at":"2020-09-15T00:45:31.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\u003eThe Test Suite randomly generates a list of 1024 passwords.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven the source code and one generated password, return the complete list of all passwords.\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[% Password generator source code\\nrng('shuffle')\\nalphanum = ['a':'z' 'A':'Z' '0':'9'];\\npasswords = string(alphanum(randi([1 length(alphanum)], [1024 6])));\\nrng('shuffle')]]\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\u003eContinuation of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/46568-beat-the-rng-easy\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 46568\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\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\u003eRead the manual. \u0026gt;:)\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[help randi\\nhelp rng]]\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":44694,"title":"Monte Carlo integration:  area of a polygon","description":"The area of a polygon (or any plane shape) can be evaluated by \u003chttps://www.mathworks.com/matlabcentral/cody/problems/179 Monte Carlo integration\u003e.  The process involves 'random' sampling of (x,y) points in the xy plane, and testing whether they fall inside or outside the shape.  That is illustrated schematically below for a circle.  \r\n\r\n\u003c\u003chttps://upload.wikimedia.org/wikipedia/commons/thumb/2/20/MonteCarloIntegrationCircle.svg/247px-MonteCarloIntegrationCircle.svg.png\u003e\u003e\r\n\r\n^\r\n\r\n*Steps:*\r\n\r\n# Define a 2D region within which to sample points.  In the present problem you must choose the rectangular box (aligned to the axes) that bounds the specified polygon.  \r\n# By a 'random' process generate coordinates of a point within the bounding box.  In the present problem a basic scheme using the uniform pseudorandom distribution available in MATLAB must be employed.  _Other schemes in use include quasi-random sampling (for greater uniformity of coverage) and stratified sampling (with more attention near the edges of the polygon)._\r\n# Determine \u003chttps://www.mathworks.com/matlabcentral/cody/problems/198 whether the sampled point is inside or outside the polygon\u003e.  _Due to working in double precision, it is extremely unlikely to sample a point falling exactly on the edge of the polygon, and consequently if it does happen it doesn't really matter whether it's counted as inside or outside or null._  \r\n# Repeat steps 2–3 |N| times.  \r\n# Based upon the proportion of sampled points falling within the polygon, report the approximate area of the polygon.  \r\n\r\nInputs to your function will be |N|, the number of points to sample, and |polygonX| \u0026 |polygonY|, which together constitute \u003chttps://www.mathworks.com/matlabcentral/cody/problems/194 an ordered list of polygon vertices\u003e.  |N| will always be a positive integer.  |polygonX| \u0026 |polygonY| will always describe a single, continuous outline;  however, the polygon may be self-intersecting.  \r\n\r\nFor polygons that are self-intersecting, you must find the area of the enclosed point set. In the case of the cross-quadrilateral, it is treated as two simple triangles (cf. three triangles in the first figure below), and the clockwise/counterclockwise ordering of points is irrelevant.  A self-intersecting pentagram (left \u0026 middle of the second figure below) will therefore have the same area as a concave decagon (right).\r\n\r\n\u003c\u003chttps://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Complex_polygon.svg/288px-Complex_polygon.svg.png\u003e\u003e\r\n\r\n\u003c\u003chttps://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Pentagram_interpretations.svg/320px-Pentagram_interpretations.svg.png\u003e\u003e\r\n\r\n^\r\n\r\nEXAMPLE\r\n\r\n % Input\r\n N = 1000\r\n polygonX = [1 0 -1  0]\r\n polygonY = [0 1  0 -1]\r\n % Output\r\n A = 2.036\r\n\r\nExplanation:  the above polygon is a square of side-length √2 centred on the origin, but rotated by 45°.  The exact area is hence 2.  As the value of |N| is moderate, the estimate by Monte Carlo integration is moderately accurate (an error of 0.036 in this example, corresponding to 509 of the 1000 sampled points falling within the polygon).  \r\nOf course, if the code were run again then a slightly different value of |A| would probably be returned, such as |A|=1.992 (corresponding to 498 of the 1000 sampled points falling within the polygon), due to the random qualities of the technique.  ","description_html":"\u003cp\u003eThe area of a polygon (or any plane shape) can be evaluated by \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/179\"\u003eMonte Carlo integration\u003c/a\u003e.  The process involves 'random' sampling of (x,y) points in the xy plane, and testing whether they fall inside or outside the shape.  That is illustrated schematically below for a circle.\u003c/p\u003e\u003cimg src = \"https://upload.wikimedia.org/wikipedia/commons/thumb/2/20/MonteCarloIntegrationCircle.svg/247px-MonteCarloIntegrationCircle.svg.png\"\u003e\u003cp\u003e^\u003c/p\u003e\u003cp\u003e\u003cb\u003eSteps:\u003c/b\u003e\u003c/p\u003e\u003col\u003e\u003cli\u003eDefine a 2D region within which to sample points.  In the present problem you must choose the rectangular box (aligned to the axes) that bounds the specified polygon.\u003c/li\u003e\u003cli\u003eBy a 'random' process generate coordinates of a point within the bounding box.  In the present problem a basic scheme using the uniform pseudorandom distribution available in MATLAB must be employed.  \u003ci\u003eOther schemes in use include quasi-random sampling (for greater uniformity of coverage) and stratified sampling (with more attention near the edges of the polygon).\u003c/i\u003e\u003c/li\u003e\u003cli\u003eDetermine \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/198\"\u003ewhether the sampled point is inside or outside the polygon\u003c/a\u003e.  \u003ci\u003eDue to working in double precision, it is extremely unlikely to sample a point falling exactly on the edge of the polygon, and consequently if it does happen it doesn't really matter whether it's counted as inside or outside or null.\u003c/i\u003e\u003c/li\u003e\u003cli\u003eRepeat steps 2–3 \u003ctt\u003eN\u003c/tt\u003e times.\u003c/li\u003e\u003cli\u003eBased upon the proportion of sampled points falling within the polygon, report the approximate area of the polygon.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eInputs to your function will be \u003ctt\u003eN\u003c/tt\u003e, the number of points to sample, and \u003ctt\u003epolygonX\u003c/tt\u003e \u0026 \u003ctt\u003epolygonY\u003c/tt\u003e, which together constitute \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/194\"\u003ean ordered list of polygon vertices\u003c/a\u003e.  \u003ctt\u003eN\u003c/tt\u003e will always be a positive integer.  \u003ctt\u003epolygonX\u003c/tt\u003e \u0026 \u003ctt\u003epolygonY\u003c/tt\u003e will always describe a single, continuous outline;  however, the polygon may be self-intersecting.\u003c/p\u003e\u003cp\u003eFor polygons that are self-intersecting, you must find the area of the enclosed point set. In the case of the cross-quadrilateral, it is treated as two simple triangles (cf. three triangles in the first figure below), and the clockwise/counterclockwise ordering of points is irrelevant.  A self-intersecting pentagram (left \u0026 middle of the second figure below) will therefore have the same area as a concave decagon (right).\u003c/p\u003e\u003cimg src = \"https://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Complex_polygon.svg/288px-Complex_polygon.svg.png\"\u003e\u003cimg src = \"https://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Pentagram_interpretations.svg/320px-Pentagram_interpretations.svg.png\"\u003e\u003cp\u003e^\u003c/p\u003e\u003cp\u003eEXAMPLE\u003c/p\u003e\u003cpre\u003e % Input\r\n N = 1000\r\n polygonX = [1 0 -1  0]\r\n polygonY = [0 1  0 -1]\r\n % Output\r\n A = 2.036\u003c/pre\u003e\u003cp\u003eExplanation:  the above polygon is a square of side-length √2 centred on the origin, but rotated by 45°.  The exact area is hence 2.  As the value of \u003ctt\u003eN\u003c/tt\u003e is moderate, the estimate by Monte Carlo integration is moderately accurate (an error of 0.036 in this example, corresponding to 509 of the 1000 sampled points falling within the polygon).  \r\nOf course, if the code were run again then a slightly different value of \u003ctt\u003eA\u003c/tt\u003e would probably be returned, such as \u003ctt\u003eA\u003c/tt\u003e=1.992 (corresponding to 498 of the 1000 sampled points falling within the polygon), due to the random qualities of the technique.\u003c/p\u003e","function_template":"function A = monteCarloArea(N, polygonX, polygonY)\r\n    % Fun starts here\r\nend\r\n\r\n\r\n% Note:  the Test Suite has been designed to account for variability in outputs. \r\n%        Nevertheless, it is possible that on rare occasions a valid submission \r\n%        might fail the Test Suite in one instance.  \r\n%        If your submission has narrowly failed only one of the test cases, \r\n%        then please try resubmitting it, in case it was just due to 'bad luck'.  ","test_suite":"%% No silly stuff\r\n% This Test Suite can be updated if inappropriate 'hacks' are discovered \r\n% in any submitted solutions, so your submission's status may therefore change over time.  \r\n\r\n% BEGIN EDIT (2019-06-29).  \r\n% Ensure only builtin functions will be called.  \r\n! rm -v fileread.m\r\n! rm -v assert.m\r\n% END OF EDIT (2019-06-29).  \r\n\r\nassessFunctionAbsence({'regexp', 'regexpi', 'str2num'}, 'FileName','monteCarloArea.m')\r\n\r\nRE = regexp(fileread('monteCarloArea.m'), '\\w+', 'match');\r\ntabooWords = {'ans', 'area', 'polyarea'};\r\ntestResult = cellfun( @(z) ismember(z, tabooWords), RE );\r\nmsg = ['Please do not do that in your code!' char([10 13]) ...\r\n    'Found: ' strjoin(RE(testResult)) '.' char([10 13]) ...\r\n    'Banned word.' char([10 13])];\r\nassert(~any( testResult ), msg)\r\n\r\n\r\n%% Unit square, in first quadrant\r\nNvec = 1 : 7 : 200;\r\npolygonX = [0 1 1 0];\r\npolygonY = [0 0 1 1];\r\nareaVec = arrayfun(@(N) monteCarloArea(N, polygonX, polygonY), Nvec);\r\narea_correct = 1;\r\nassert( all(areaVec==area_correct) )\r\n\r\n%% 3×3 square, offset from origin, in all four quadrants\r\nNvec = 1 : 19 : 500;\r\npolygonX = [ 1 1 -2 -2];\r\npolygonY = [-1 2  2 -1];\r\nareaVec = arrayfun(@(N) monteCarloArea(N, polygonX, polygonY), Nvec);\r\narea_correct = 9;\r\nassert( all(areaVec==area_correct) )\r\n\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  small N (1)\r\nN = 1;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_valid = [0 4];\r\nareaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:1000);\r\nassert( all( ismember(areaVec, area_valid) ) , 'Invalid areas reported' )\r\nassert( all( ismember(area_valid, areaVec) ) , 'Not all valid areas accessible in your sampling scheme')\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  small N (2)\r\nN = 2;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_valid = [0 2 4];\r\nareaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:1000);\r\nassert( all( ismember(areaVec, area_valid) ) , 'Invalid areas reported' )\r\nassert( all( ismember(area_valid, areaVec) ) , 'Not all valid areas accessible in your sampling scheme')\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  small N (3)\r\nN = 4;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_valid = [0:4];\r\nareaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:1000);\r\nassert( all( ismember(areaVec, area_valid) ) , 'Invalid areas reported' )\r\nassert( all( ismember(area_valid, areaVec) ) , 'Not all valid areas accessible in your sampling scheme')\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  moderate N (1)\r\nN = 100;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_exact = 2;\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 4 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    assert( worstErrorFraction \u003e 0.05 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.40 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  moderate N (2)\r\nN = 1000;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_exact = 2;\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 5 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    assert( worstErrorFraction \u003e 0.02 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.15 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  moderate N (3)\r\nN = 10000;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_exact = 2;\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 6 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    assert( worstErrorFraction \u003e 0.004 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.049 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  large N\r\nN = 100000;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_exact = 2;\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 7 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    assert( worstErrorFraction \u003e 0.0016 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.016 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n\r\n%% Cross-quadrilateral, centred on origin, in all four quadrants:  moderate N (1)\r\nN = 100;\r\npolygonX = [ 1 -1  1 -1];\r\npolygonY = [-1  1  1 -1];\r\narea_exact = 2;\r\n\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 4 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    assert( worstErrorFraction \u003e 0.05 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.40 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n%% Cross-quadrilateral, centred on origin, in all four quadrants:  moderate N (2)\r\nN = 10000;\r\nfor j = 1 : 10,\r\n    rVec = 100 * rand(2);\r\n    polygonX = [ 1 -1  1 -1] * rVec(1,1) + rVec(1,2);\r\n    polygonY = [-1  1  1 -1] * rVec(2,1) + rVec(2,2);\r\n    area_exact = 2 * rVec(1,1) * rVec(2,1);\r\n\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 6 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    assert( worstErrorFraction \u003e 0.004 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.049 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n\r\n%% 12-cornered polygon of unit 'circumradius' centred on origin:  moderate N\r\nN = 1000;\r\npoints = 12;\r\ncentre = [0 0];\r\ncircumradius = 1;\r\npolygonX = circumradius * cos(2 * pi * [0:points-1]/points) + centre(1);\r\npolygonY = circumradius * sin(2 * pi * [0:points-1]/points) + centre(2);\r\narea_exact = polyarea(polygonX, polygonY);\r\n\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 5 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    %assert( worstErrorFraction \u003e 0.02 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003e 0.01 , 'Implausibly accurate' )\r\n    %assert( worstErrorFraction \u003c 0.15 , 'Implausibly inaccurate' )\r\n    assert( worstErrorFraction \u003c 0.08 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n%% P-cornered polygon of arbitrary 'circumradius', with centre offset from  the origin:  moderate N\r\nN = 1000;\r\nfor j = 1 : 10,\r\n    points = randi([5 100]);\r\n    centre = randi([2 100], [1 2]);\r\n    circumradius = randi([2 100]);\r\n    r = rand();\r\n    polygonX = circumradius * cos(2 * pi * (r+[0:points-1])/points) + centre(1);\r\n    polygonY = circumradius * sin(2 * pi * (r+[0:points-1])/points) + centre(2);\r\n    area_exact = polyarea(polygonX, polygonY);\r\n\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 5 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    %assert( worstErrorFraction \u003e 0.02 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003e 0.01 , 'Implausibly accurate' )\r\n    %assert( worstErrorFraction \u003c 0.15 , 'Implausibly inaccurate' )\r\n    assert( worstErrorFraction \u003c 0.08 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n\r\n%% 5-pointed star of unit 'circumradius' centred on origin:  moderate N\r\nN = 1000;\r\npoints = 5;\r\ncentre = [0 0];\r\ncircumradius = 1;\r\nx = circumradius * cos(2 * pi * [0:points-1]/points) + centre(1);\r\ny = circumradius * sin(2 * pi * [0:points-1]/points) + centre(2);\r\npolygonX = x([1:2:end, 2:2:end]);\r\npolygonY = y([1:2:end, 2:2:end]);\r\narea_exact = sqrt(650 - 290* sqrt(5))/4  * ( circumradius / sqrt((5 - sqrt(5))/10) )^2;\r\n% http://mathworld.wolfram.com/Pentagram.html\r\n\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 5 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    %assert( worstErrorFraction \u003e 0.02 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003e 0.03 , 'Implausibly accurate' )\r\n    %assert( worstErrorFraction \u003c 0.15 , 'Implausibly inaccurate' )\r\n    assert( worstErrorFraction \u003c 0.25 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n%% 5-pointed star of arbitrary 'circumradius', with centre offset from  the origin:  moderate N\r\nN = 1000;\r\npoints = 5;\r\nfor j = 1 : 10,\r\n    centre = randi([2 100], [1 2]);\r\n    circumradius = randi([2 100]);\r\n    r = rand();\r\n    x = circumradius * cos(2 * pi * (r+[0:points-1])/points) + centre(1);\r\n    y = circumradius * sin(2 * pi * (r+[0:points-1])/points) + centre(2);\r\n    polygonX = x([1:2:end, 2:2:end]);\r\n    polygonY = y([1:2:end, 2:2:end]);\r\n    area_exact = sqrt(650 - 290* sqrt(5))/4  * ( circumradius / sqrt((5 - sqrt(5))/10) )^2;\r\n    % http://mathworld.wolfram.com/Pentagram.html\r\n\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 5 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    %assert( worstErrorFraction \u003e 0.02 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003e 0.03 , 'Implausibly accurate' )\r\n    %assert( worstErrorFraction \u003c 0.15 , 'Implausibly inaccurate' )\r\n    assert( worstErrorFraction \u003c 0.25 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n\r\n%% P-pointed star of arbitrary 'circumradius', with centre offset from  the origin:  moderate N\r\nN = 1000;\r\nfor j = 1 : 20,\r\n    points = 3 * randi([3 10]) - 1;\r\n    centre = randi([2 100], [1 2]);\r\n    circumradius = randi([2 30]);\r\n    r = rand();\r\n    x = circumradius * cos(2 * pi * (r+[0:points-1])/points) + centre(1);\r\n    y = circumradius * sin(2 * pi * (r+[0:points-1])/points) + centre(2);\r\n    polygonX = x([1:3:end, 2:3:end, 3:3:end]);\r\n    polygonY = y([1:3:end, 2:3:end, 3:3:end]);\r\n    \r\n    area_polyarea = polyarea(polygonX, polygonY);                % Incorrect value\r\n    warning('off', 'MATLAB:polyshape:repairedBySimplify')\r\n    area_polyshapeArea1 = area( polyshape(polygonX, polygonY) ); % Incorrect value\r\n    area_polyshapeArea2 = area( polyshape(polygonX, polygonY, 'Simplify',false) );  % Incorrect value\r\n    \r\n    % REFERENCE:  http://web.sonoma.edu/users/w/wilsonst/papers/stars/a-p/default.html\r\n    % Here: a {points/3} star\r\n    k = 3;\r\n    sideLength = circumradius * sind(180/points) * secd(180*(k-1)/points);\r\n    apothem = circumradius * cosd(180*k/points);\r\n    area_exact = points * sideLength * apothem;                  % Correct value\r\n    fprintf('Area estimates from different methods:  \\r\\npolyarea = %4.1f;  polyshape.area = %4.1f or %4.1f;  geometrical analysis = %4.1f\\r\\n', ...\r\n        area_polyarea, area_polyshapeArea1, area_polyshapeArea2, area_exact);\r\n    \r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 5 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    %assert( worstErrorFraction \u003e 0.02 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003e 0.01 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.15 , 'Implausibly inaccurate' )\r\nend;\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":7,"test_suite_updated_at":"2019-06-29T13:06:05.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2018-07-02T02:19:05.000Z","updated_at":"2025-09-14T14:22:43.000Z","published_at":"2018-07-02T08:55:01.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/media/image1.png\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/media/image2.png\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"targetMode\":\"\",\"relationshipId\":\"rId3\",\"target\":\"/media/image3.png\"}],\"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\u003eThe area of a polygon (or any plane shape) can be evaluated 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=\\\"https://www.mathworks.com/matlabcentral/cody/problems/179\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMonte Carlo integration\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. The process involves 'random' sampling of (x,y) points in the xy plane, and testing whether they fall inside or outside the shape. That is illustrated schematically below for a circle.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e^\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSteps:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDefine a 2D region within which to sample points. In the present problem you must choose the rectangular box (aligned to the axes) that bounds the specified polygon.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBy a 'random' process generate coordinates of a point within the bounding box. In the present problem a basic scheme using the uniform pseudorandom distribution available in MATLAB must be employed. \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\u003eOther schemes in use include quasi-random sampling (for greater uniformity of coverage) and stratified sampling (with more attention near the edges of the polygon).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDetermine\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/198\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ewhether the sampled point is inside or outside the polygon\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. \u003c/w:t\u003e\u003c/w:r\u003e\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\u003eDue to working in double precision, it is extremely unlikely to sample a point falling exactly on the edge of the polygon, and consequently if it does happen it doesn't really matter whether it's counted as inside or outside or null.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRepeat steps 2–3\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e times.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBased upon the proportion of sampled points falling within the polygon, report the approximate area of the polygon.\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\u003eInputs to your function will be\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, the number of points to sample, 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:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003epolygonX\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u0026amp;\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\u003epolygonY\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, which together constitute\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/194\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ean ordered list of polygon vertices\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. \u003c/w:t\u003e\u003c/w:r\u003e\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e will always be a positive integer. \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\u003epolygonX\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u0026amp;\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\u003epolygonY\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e will always describe a single, continuous outline; however, the polygon may be self-intersecting.\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 polygons that are self-intersecting, you must find the area of the enclosed point set. In the case of the cross-quadrilateral, it is treated as two simple triangles (cf. three triangles in the first figure below), and the clockwise/counterclockwise ordering of points is irrelevant. A self-intersecting pentagram (left \u0026amp; middle of the second figure below) will therefore have the same area as a concave decagon (right).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId2\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId3\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e^\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ % Input\\n N = 1000\\n polygonX = [1 0 -1  0]\\n polygonY = [0 1  0 -1]\\n % Output\\n A = 2.036]]\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\u003eExplanation: the above polygon is a square of side-length √2 centred on the origin, but rotated by 45°. The exact area is hence 2. As the value of\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is moderate, the estimate by Monte Carlo integration is moderately accurate (an error of 0.036 in this example, corresponding to 509 of the 1000 sampled points falling within the polygon). Of course, if the code were run again then a slightly different value of\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\u003eA\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e would probably be returned, such as\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\u003eA\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e=1.992 (corresponding to 498 of the 1000 sampled points falling within the polygon), due to the random qualities of the technique.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"},{\"partUri\":\"/media/image1.png\",\"contentType\":\"image/png\",\"content\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPcAAADwCAYAAADcifLrAAAjU0lEQVR42u1dB5gV1dn+7tBdK01AsFIEESKIERULttgNiAZ77GBAorFrRESj2DU2NJYoEDF2fzuCigYj2FEjIghSpHdEYOf/3nvO6t3Zmd25e6edme99nvdhmb17p5zzzjnnO18hEggEAoFAIBAIBAKBQCAQCAQCgUAQPjozP2b+II9CIEgPTmLOYY4RcQsE6cJpzFbM00XcAkE6UZO4t2F2F8bOXswDNI924cH6d/vLs0oEO5kg7huZS5jThaHwO+Zs5jzmIuYy5irmGuY65npmOdMu4EYXOj+zgfkzc63+vuXMxcz5ur1nyrMPjXi+n5gi7mtkglMy6jA7MI9n3sB8SYv6J+bXzFeY9zIvZv6BeSCzK7M1s1GR56rLbMHchbkv8/fMPzFvZT6jjah4iSxlTmDexTxTjzgNpalKxm9F3OnG5sxDmEOZrzNXML9nPs8cxjyOuRMzF+ZF8BC+m53LPc2cZFvWffz/pgW/bqGv8RLmKOYXeqT/gHkHs59elglE3JkfmfdiDmdO0dPq9/Vo2Uc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cn6HrgEYctow/0S2emXs+uZP7MLGeuJeXVtUQTGT/n6/tYq18Sc/WxxfozeGmsYW7QXK1/B3/6r5iTmW+TykWWlGcB+8GHKelnb0YlbgRJ2AXcuUhxo65xP2EsRCaSs/WUGdP5YZq3ufCGgt9fTCoC7WR5hrHx4CjEDc+gzgWsX6S4BQKBoRBxCwQpA0IuEZnzZ71ua63ZUB6NQGA25jvW4hU8Vh6NQCAQCAQCgUAgEAgEAoFAUBr8RI8lBYjIgpcQDIbIi/YUVR+lBc8wp1Hxi5Tdo7SL6MUVfqPHkgL4bcNvehdSftevM9+o5vPYBkRtsdYF3Dpl9yjtInpxhd/osSRgB/2GLwym6KiPtfX4m59IRXCZgtrco7SL6KVamHCx8Old6nIcx/q7HC/THWwk81NSgRujdeOk5R6lXUQvqbjYgaQyhTiBY4NcjrfUa8D7mF1JJURE+ONnpLKgpuEepV1ELyVHjyXhegd4dKLpRXT8Nvr79ktopwniHk285qS3S6LFbVr0mNv19iVVe8qJFXpq6Bcr9MsjiQjqHk285iS3i0zLQ8a2+u3eqeAYkiKWk3ulC0z5HnBM9Sq+o2dK7lHaRfTiCdOix5DdZJzuSNh2mcB8tuD359GvpXRRSQSZS+4nlcQQMwAkBERGkCSXkq3pHqVdRC++YFr0GDJ3jtZTOKQnepwql7J5TrMCu+uOVvF57E8mfT+1pnuUdhG9CAQCgUAgEAgEAoFAIBAIBOnB/wNopWkMeaxRlQAAAABJRU5ErkJggg==\"},{\"partUri\":\"/media/image2.png\",\"contentType\":\"image/png\",\"content\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAADwCAYAAACgyrkbAAAXbElEQVR42u2dB7hU1fHAx4ogGgREUBFs2KKoaBKNBRVFYyxR/McSaxSNBVsM9kBiAf1bMPYWbLHFqEETW2zYe+9SooioCCigaIy5457jnbdv777dt7t3b/n9vm++T9nde8+dOWfeuWfOmREBAAAAAAAAAACAvNAxkAVRAwDETfdAPgzk5UB6oA4AiJNdAvnWyVjUAQ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biNoAoF5oXXef5L5cpY273XfuRGUAUE/2da9WvtJGzxLfec99fgbqAoB6M0zCReYXpWWlDRsB2wdVAUAjOElKV9rYQIiAAUAMnC6tK20QAQOA2DhLWlbauMD99yRUAwCNpjjJvQ/V/xPVAEAcaGmfW40T+tbNjAAAYkGLHN5lHNB+qAQA4kQTj10VyAPSMjQPAAAAAAAAAAAAAAAA9eR/oeqV3auxALsAAAAASUVORK5CYII=\"},{\"partUri\":\"/media/image3.png\",\"contentType\":\"image/png\",\"content\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUAAAACWCAYAAACvgFEsAAA0/klEQVR42u1dB3wUxfffcne5Sy69kt5IJUB6CIQmvRNqaCJVQAQBRUEEAcVKVaQJigXsBQsIP3sXAbErCgoooNj/CneXm/+8u1nYLNfr5m6+n8/7QG53p7y38503u2/fMAwFBQUFBQUFBQUFBQUFBQUFBQUFRfPDbCx/YEFY4vxQ/14sB7Cw1BSy1Ucxlo+wvINlP5bO1EwUzQVfYnmdSCMhuvfJ32ewRGE55EcCPIzlOBbewfNPYTHIUM+utMvSNc7qwxd4ltwfuVjKsbQOEP1TBAH2if7/D7mRM8nfO2VAgCos6gC40T1FgM7qwxc46Mf7gxIghVvgbBCgcEwgwFuxHMHyE5be5Ng2LHpyfD45doocG06WRA8Qz2WkqC5bxwRMw/K7aHAtxfIf+XsxuV7cloXkuJGQ9zg7dVlr+yPEGz6HZQOWk0QHNS722Vq7orG8gWULWdqC511roy9SfQD6k/qgzR9iWYZF6YCuYrHswvI2lk2kHQOs3CPW6gBcLWrT06T/YtjqoxT29G5Nv67cF460ay5pw3tYNpPyz2L514r97ZW5RnQdjKUfiDffh/T9H2KPWEpL/oGUABkJAQ7Fkkz+/7GF4wvJwICbpZTczA+Sc54kxi+yc4yxUnec5O9e5EaRtkU609ury1LbAcJzzzZYssjg+VE08J3tsyUPJAJLPfk/T875zo7XItZHCSl/Nzk2hRy7yQFdXUf+HkT+7oClwYL+7dXB2Fkh2OujFL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LP9GW8e5nP3K2kacflgeCvXxpX1f078o14nGWRCZKhjyvbY46bwJlMyW/xcRDDAb9ydVGUk+hOUAZQG1yRf/OXiMdZ+DNrSIe65AA5xgKCgoKCgoKCgoKCgoKCgoKCgoKGeH/AS8924+Oc1GZAAAAAElFTkSuQmCC\"}]}"},{"id":44393,"title":"Testing for randomness:  uniform distribution of integers","description":"On Cody several problems have been set up asking players to generate one or more 'random' numbers.  Usually they are asking for numbers from a uniform distribution function (UDF).  However, Test Suites do not always test very carefully to see how 'random' the sequences generated by the submitted codes are.  Indeed, rigorous testing of randomness is a sophisticated field of endeavour.  (See e.g. \u003chttps://en.wikipedia.org/wiki/TestU01 TestU01\u003e and the \u003chttps://en.wikipedia.org/wiki/Diehard_tests Diehard tests\u003e.)  \r\n\r\nMATLAB provides access to several very good pseudo-random number generators.  Even these do not generate truly random number sequences — however, they are good enough for most purposes.  \r\n\r\nHere we will be considering only integer sequences.  Your task will be to distinguish those that are 'practically' random — in this case being uniformly distributed — from those that aren't.  \r\n\r\nYou must return:\r\n\r\n* the probability of the given sequence being generated (a scalar float);  and  \r\n* your assessment of whether the sequence could 'plausibly' have been produced by a true random number generator (a scalar Boolean).  \r\n\r\nInput sequences will be vectors of various lengths containing only the integers 1, 2, 3 and 4.  \r\n\r\nHere are a few cases to consider:\r\n\r\nEXAMPLE ONE — Random sequence (UDF)\r\n\r\n Input = [3 4 3 3 4 2 2 2 1 3 2 2 1 3 3 2 4 3 1 2 3 2 1 4 2 1 4 4 4 2 3 1 2 1 2 2 1]\r\n prob ~ 5.29E-23\r\n isRandom = true\r\n\r\nEXAMPLE TWO — Non-uniform distribution\r\n\r\n Input = [1 3 3 1 1 1 1 3 1 1 4 1 2 1 1 1 1 1 3 1 3]\r\n % Notice that there are far too many ones, and too few twos and fours.\r\n prob ~ 9.09E-13\r\n isRandom = false\r\n\r\nEXAMPLE THREE — \u003chttp://www.spirit-statement.org/sequence-generation/ Blocked randomisation\u003e (or 'permuted block randomisation') \r\n\r\n Input = [1 3 2 4, 1 4 2 3, 3 1 4 2, 2 1 3 4, 1 4 3 2, 3 2 4 1, 4 1 3]\r\n % Notice that each of the four digits appears in groups of four.  In such cases the identity of neighbouring digits is often biased too, although it isn't apparent in the short sequence above.  \r\n prob ~ 5.55E-17\r\n isRandom = false\r\n\r\nEXAMPLE FOUR — Repeated pattern\r\n\r\n Input = [1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2]\r\n % Notice the pattern of eight digits that is repeated.  Notice also that the identity of neighbouring digits is biased, as e.g. 4 is only ever followed by 2, and 3 is only ever followed by 1.  \r\n prob ~ 5.29E-23\r\n isRandom = false\r\n\r\nEXAMPLE FIVE — Partial repeated sequence, too few runs\r\n\r\n Input = [1 2 3 4 2 3 4 1 3 4 1 2 4 1 2 3 1 2 3 1 2 4 1 3 4 2 3 4 1 2 3 4]\r\n % Notice that the sequence \"1 2 3 4\" is repeated in part or in full.  Notice also that the neighbouring digits are biased — e.g. 2 most commonly follows 1, but 2 is never followed by 1 or 2.  And finally notice that there are no runs (repeated occurrences of the same numeral).  \r\n prob ~ 5.42E-20\r\n isRandom = false\r\n\r\nEXAMPLE SIX — Partially segregated sequence, runs too long\r\n\r\n Input = [1 1 4 1 1 1 1 1 1 3 3 3 3 1 3 3 3 3 4 4 4 4 2 4 4 4 4 2 2 2 2 2 2 3 2 2]\r\n % Notice that the sequence unfolds as mostly 1, then mostly 3, then mostly 4, and mostly 2 at the end.  Notice also that the neighbouring digits are biased — each number most commonly follows itself.  And finally notice that the runs are longer than we would expect from a truly random (UDF) sequence.  \r\n prob ~ 2.12E-22\r\n isRandom = false\r\n\r\nAs will be apparent, there are various tests that _could_ be applied:  inspecting occurrence of numerals, pairs of neighbouring numerals, runs of numerals (length of runs, number of runs), repeated sequences, etc.  Your job is just to return the correct outputs.  You are *not* necessarily required to implement every test.  \r\n\r\n|Note:  the sequences in the examples above were for illustrative purposes;  most sequences in the Test Suite are considerably longer.|\r\n\r\nSee also:\r\n\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44435 Problem 44435: \"Testing for randomness: uniform distribution of real numbers (distribution checking)\"\u003e (easier)","description_html":"\u003cp\u003eOn Cody several problems have been set up asking players to generate one or more 'random' numbers.  Usually they are asking for numbers from a uniform distribution function (UDF).  However, Test Suites do not always test very carefully to see how 'random' the sequences generated by the submitted codes are.  Indeed, rigorous testing of randomness is a sophisticated field of endeavour.  (See e.g. \u003ca href = \"https://en.wikipedia.org/wiki/TestU01\"\u003eTestU01\u003c/a\u003e and the \u003ca href = \"https://en.wikipedia.org/wiki/Diehard_tests\"\u003eDiehard tests\u003c/a\u003e.)\u003c/p\u003e\u003cp\u003eMATLAB provides access to several very good pseudo-random number generators.  Even these do not generate truly random number sequences — however, they are good enough for most purposes.\u003c/p\u003e\u003cp\u003eHere we will be considering only integer sequences.  Your task will be to distinguish those that are 'practically' random — in this case being uniformly distributed — from those that aren't.\u003c/p\u003e\u003cp\u003eYou must return:\u003c/p\u003e\u003cul\u003e\u003cli\u003ethe probability of the given sequence being generated (a scalar float);  and\u003c/li\u003e\u003cli\u003eyour assessment of whether the sequence could 'plausibly' have been produced by a true random number generator (a scalar Boolean).\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eInput sequences will be vectors of various lengths containing only the integers 1, 2, 3 and 4.\u003c/p\u003e\u003cp\u003eHere are a few cases to consider:\u003c/p\u003e\u003cp\u003eEXAMPLE ONE — Random sequence (UDF)\u003c/p\u003e\u003cpre\u003e Input = [3 4 3 3 4 2 2 2 1 3 2 2 1 3 3 2 4 3 1 2 3 2 1 4 2 1 4 4 4 2 3 1 2 1 2 2 1]\r\n prob ~ 5.29E-23\r\n isRandom = true\u003c/pre\u003e\u003cp\u003eEXAMPLE TWO — Non-uniform distribution\u003c/p\u003e\u003cpre\u003e Input = [1 3 3 1 1 1 1 3 1 1 4 1 2 1 1 1 1 1 3 1 3]\r\n % Notice that there are far too many ones, and too few twos and fours.\r\n prob ~ 9.09E-13\r\n isRandom = false\u003c/pre\u003e\u003cp\u003eEXAMPLE THREE — \u003ca href = \"http://www.spirit-statement.org/sequence-generation/\"\u003eBlocked randomisation\u003c/a\u003e (or 'permuted block randomisation')\u003c/p\u003e\u003cpre\u003e Input = [1 3 2 4, 1 4 2 3, 3 1 4 2, 2 1 3 4, 1 4 3 2, 3 2 4 1, 4 1 3]\r\n % Notice that each of the four digits appears in groups of four.  In such cases the identity of neighbouring digits is often biased too, although it isn't apparent in the short sequence above.  \r\n prob ~ 5.55E-17\r\n isRandom = false\u003c/pre\u003e\u003cp\u003eEXAMPLE FOUR — Repeated pattern\u003c/p\u003e\u003cpre\u003e Input = [1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2]\r\n % Notice the pattern of eight digits that is repeated.  Notice also that the identity of neighbouring digits is biased, as e.g. 4 is only ever followed by 2, and 3 is only ever followed by 1.  \r\n prob ~ 5.29E-23\r\n isRandom = false\u003c/pre\u003e\u003cp\u003eEXAMPLE FIVE — Partial repeated sequence, too few runs\u003c/p\u003e\u003cpre\u003e Input = [1 2 3 4 2 3 4 1 3 4 1 2 4 1 2 3 1 2 3 1 2 4 1 3 4 2 3 4 1 2 3 4]\r\n % Notice that the sequence \"1 2 3 4\" is repeated in part or in full.  Notice also that the neighbouring digits are biased — e.g. 2 most commonly follows 1, but 2 is never followed by 1 or 2.  And finally notice that there are no runs (repeated occurrences of the same numeral).  \r\n prob ~ 5.42E-20\r\n isRandom = false\u003c/pre\u003e\u003cp\u003eEXAMPLE SIX — Partially segregated sequence, runs too long\u003c/p\u003e\u003cpre\u003e Input = [1 1 4 1 1 1 1 1 1 3 3 3 3 1 3 3 3 3 4 4 4 4 2 4 4 4 4 2 2 2 2 2 2 3 2 2]\r\n % Notice that the sequence unfolds as mostly 1, then mostly 3, then mostly 4, and mostly 2 at the end.  Notice also that the neighbouring digits are biased — each number most commonly follows itself.  And finally notice that the runs are longer than we would expect from a truly random (UDF) sequence.  \r\n prob ~ 2.12E-22\r\n isRandom = false\u003c/pre\u003e\u003cp\u003eAs will be apparent, there are various tests that \u003ci\u003ecould\u003c/i\u003e be applied:  inspecting occurrence of numerals, pairs of neighbouring numerals, runs of numerals (length of runs, number of runs), repeated sequences, etc.  Your job is just to return the correct outputs.  You are \u003cb\u003enot\u003c/b\u003e necessarily required to implement every test.\u003c/p\u003e\u003cp\u003e\u003ctt\u003eNote:  the sequences in the examples above were for illustrative purposes;  most sequences in the Test Suite are considerably longer.\u003c/tt\u003e\u003c/p\u003e\u003cp\u003eSee also:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44435\"\u003eProblem 44435: \"Testing for randomness: uniform distribution of real numbers (distribution checking)\"\u003c/a\u003e (easier)\u003c/li\u003e\u003c/ul\u003e","function_template":"function [prob, isRandom] = testRandomness(x)\r\n    % Your code goes here!\r\nend","test_suite":"%%\r\n% It is possible that even a genuine random number generator could produce \r\n% a sequence that does not have the characteristics of a random number stream, \r\n% so a couple of incorrect assessments are allowed as 'leeway' in each test.  \r\n\r\n\r\n%% \r\n% Random, very short\r\nfaults = 0;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = randi(4, [1, randi(8)]);\r\n    [prob, isRandom] = testRandomness(x);\r\n%    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%% \r\n% Random, short\r\nfaults = 0;\r\nprob_C = 1.121038771459854E-44;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = randi(4, [1,73]);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%% \r\n% Random, medium\r\nfaults = 0;\r\nprob_C = 1.785917798878555E-102;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = randi(4, [1,169]);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%% \r\n% Random, long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = randi(4, [1,500]);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%% \r\n% Too many of some number, short\r\nfaults = 0;\r\nprob_C = 1.121038771459854E-44;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = randi(4, [1,73]);\r\n    x( randi(3, [1,73]) \u003c 3 ) = randi(4);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%% \r\n% Too many of some number, medium\r\nfaults = 0;\r\nprob_C = 1.785917798878555E-102;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = randi(4, [1,169]);\r\n    x( randi(3, [1,169]) == 1 ) = randi(4);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Too few of some number, long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = randi(4, [1,500]);\r\n    els = find(x == randi(4));\r\n    new = randi(4, [1,length(els)]);\r\n    x(els) = new;\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Repeated patterns, long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = repmat( randi(4, [1, randi([4, 12])]) , [1,150] );\r\n    x = x(1:500);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Blocked randomisation (i.e. permuted block randomisation), medium\r\nfaults = 0;\r\nprob_C = 1.785917798878555E-102;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = [];\r\n    for j = 1 : 50,  x = [x randperm(4)];  end;\r\n    x = x(1:169);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Blocked randomisation (i.e. permuted block randomisation), long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = [];\r\n    for j = 1 : 125,  x = [x randperm(4)];  end;\r\n    %x = x(1:500);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Partially repeated 4-digit sequence, long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    pattern = randperm(4);\r\n    x = [];\r\n    for j = 1 : 300,  \r\n        d = randi(6, [1,4]);\r\n        p = pattern;\r\n        p(d==1) = [];\r\n        x = [x p];  \r\n    end;\r\n    x = x(1:500);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Partially repeated 8-digit sequence, long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    pattern = [randperm(4) randperm(4)];\r\n    x = [];\r\n    for j = 1 : 150,  \r\n        d = randi(6, [1,8]);\r\n        p = pattern;\r\n        p(d==1) = [];\r\n        x = [x p];  \r\n    end;\r\n    x = x(1:500);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Partially segregated sequence, long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    pattern = [randperm(4) randperm(4)];\r\n    x = [];\r\n    for j = 1 : 50,  \r\n        p = randi(12, [1,10]);\r\n        p(p\u003e4) = randi(4);\r\n        x = [x p];  \r\n    end;\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-10-30T13:25:51.000Z","updated_at":"2017-12-03T13:23:19.000Z","published_at":"2017-11-01T13:29: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=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOn Cody several problems have been set up asking players to generate one or more 'random' numbers. Usually they are asking for numbers from a uniform distribution function (UDF). However, Test Suites do not always test very carefully to see how 'random' the sequences generated by the submitted codes are. Indeed, rigorous testing of randomness is a sophisticated field of endeavour. (See e.g.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/TestU01\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eTestU01\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Diehard_tests\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDiehard tests\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMATLAB provides access to several very good pseudo-random number generators. Even these do not generate truly random number sequences — however, they are good enough for most 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\u003eHere we will be considering only integer sequences. Your task will be to distinguish those that are 'practically' random — in this case being uniformly distributed — from those that aren't.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou must return:\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\u003ethe probability of the given sequence being generated (a scalar float); and\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\u003eyour assessment of whether the sequence could 'plausibly' have been produced by a true random number generator (a scalar Boolean).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInput sequences will be vectors of various lengths containing only the integers 1, 2, 3 and 4.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHere are a few cases to consider:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE ONE — Random sequence (UDF)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input = [3 4 3 3 4 2 2 2 1 3 2 2 1 3 3 2 4 3 1 2 3 2 1 4 2 1 4 4 4 2 3 1 2 1 2 2 1]\\n prob ~ 5.29E-23\\n isRandom = true]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE TWO — Non-uniform distribution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input = [1 3 3 1 1 1 1 3 1 1 4 1 2 1 1 1 1 1 3 1 3]\\n % Notice that there are far too many ones, and too few twos and fours.\\n prob ~ 9.09E-13\\n isRandom = false]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE THREE —\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.spirit-statement.org/sequence-generation/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eBlocked randomisation\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (or 'permuted block randomisation')\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input = [1 3 2 4, 1 4 2 3, 3 1 4 2, 2 1 3 4, 1 4 3 2, 3 2 4 1, 4 1 3]\\n % Notice that each of the four digits appears in groups of four.  In such cases the identity of neighbouring digits is often biased too, although it isn't apparent in the short sequence above.  \\n prob ~ 5.55E-17\\n isRandom = false]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE FOUR — Repeated pattern\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input = [1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2]\\n % Notice the pattern of eight digits that is repeated.  Notice also that the identity of neighbouring digits is biased, as e.g. 4 is only ever followed by 2, and 3 is only ever followed by 1.  \\n prob ~ 5.29E-23\\n isRandom = false]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE FIVE — Partial repeated sequence, too few runs\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input = [1 2 3 4 2 3 4 1 3 4 1 2 4 1 2 3 1 2 3 1 2 4 1 3 4 2 3 4 1 2 3 4]\\n % Notice that the sequence \\\"1 2 3 4\\\" is repeated in part or in full.  Notice also that the neighbouring digits are biased — e.g. 2 most commonly follows 1, but 2 is never followed by 1 or 2.  And finally notice that there are no runs (repeated occurrences of the same numeral).  \\n prob ~ 5.42E-20\\n isRandom = false]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE SIX — Partially segregated sequence, runs too long\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input = [1 1 4 1 1 1 1 1 1 3 3 3 3 1 3 3 3 3 4 4 4 4 2 4 4 4 4 2 2 2 2 2 2 3 2 2]\\n % Notice that the sequence unfolds as mostly 1, then mostly 3, then mostly 4, and mostly 2 at the end.  Notice also that the neighbouring digits are biased — each number most commonly follows itself.  And finally notice that the runs are longer than we would expect from a truly random (UDF) sequence.  \\n prob ~ 2.12E-22\\n isRandom = false]]\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\u003eAs will be apparent, there are various tests that\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecould\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e be applied: inspecting occurrence of numerals, pairs of neighbouring numerals, runs of numerals (length of runs, number of runs), repeated sequences, etc. Your job is just to return the correct outputs. You are\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\u003enot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e necessarily required to implement every test.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote: the sequences in the examples above were for illustrative purposes; most sequences in the Test Suite are considerably longer.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee also:\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=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44435\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44435: \\\"Testing for randomness: uniform distribution of real numbers (distribution checking)\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (easier)\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":797,"title":"Genome Sequence 003R: Sequence DNA of random positioned and flipped segments","description":"This is Challenge 003R in the series on Genome DNA Sequencing. Challenge 3R includes flipped segments. DNA Sequencing is naively simplified into Cody Challenges. Genome sizes is another interesting wiki page.\r\nDNA is represented by symbols ACGT, which for Matlab will be encoded as 0123. The basic goal is to reconstruct the original serial string of ACGT given multiple short segments.\r\nExample: Genome = ACGTCGGCCATGGACATTACG\r\nGiven three overlapping pieces, ACGTCGGCCA, GCCATGGACATC, and GACATTACG these can be readily seen to overlap and create the original if the middle is recognized as being reversed with asymetric overlaps to its adjacent segments.\r\nACGTCGGCCATGGACATTACG\r\nACGTCGGCCAsssssssssss\r\nssssGCCATGGACATCsssss Middle Rev\r\nssssCTACAGGTACCGsssss Middle flipped\r\nssssssssssssGACATTACG\r\nGenome_003R Challenge is to reconstruct a genome under near ideal error free segment creation conditions. Segments may be reversed. The segments start at random locations.\r\nSegments may be reversed (Change from 003)\r\nSegments start at random positions\r\nGenome length is unconstrained\r\nLength of each segment - 48\r\nAll segments may overlap by 16 to 47 characters\r\nNo errors in the segments\r\nGenome is random (No duplicate starts or ends for 16 symbols of segments)\r\nSegment order is scrambled\r\nInput: segs, Array of M rows of 48 value segments. Values are [0, 1, 2, 3].\r\nOutput: Gout, Genome vector of values [0,1,2,3]\r\nExample: [0 1 2 3 2;1 1 2 2 3 2 ; 2 2 1 1 2] creates [0 1 2 3 2 2 1 1 2] W=5, Overlap=varies, Reverses may occur\r\nFuture: Flipped segments(002), Random Position of Segment start locations(003),Random Segment Positions with Flips (003R), Parrot Sequence with Gen3 Long Segments, Extra Segments, Phage Phi X174, Parallel Processing Simulation(Shot Gun Approach), Haemophilus Influenza, Sequence with Segment Errors, and Chromosome 20 with its 59M length using 100K 4K-segments","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 726.633px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 363.317px; transform-origin: 407px 363.317px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 341px 8px; transform-origin: 341px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis is Challenge 003R in the series on Genome DNA Sequencing. Challenge 3R includes flipped segments.\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eDNA Sequencing\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 133.5px 8px; transform-origin: 133.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is naively simplified into Cody Challenges.\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eGenome sizes\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 101.5px 8px; transform-origin: 101.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is another interesting wiki page.\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: 369px 8px; transform-origin: 369px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eDNA is represented by symbols ACGT, which for Matlab will be encoded as 0123. The basic goal is to reconstruct the original serial string of ACGT given multiple short segments.\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: 31.5px 8px; transform-origin: 31.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eExample:\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: 139px 8px; transform-origin: 139px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e Genome = ACGTCGGCCATGGACATTACG\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; 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 31.5px; text-align: left; transform-origin: 384px 31.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: 368.5px 8px; transform-origin: 368.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven three overlapping pieces, ACGTCGGCCA, GCCATGGACATC, and GACATTACG these can be readily seen to overlap and create the original if the middle is recognized as being reversed with asymetric overlaps to its adjacent segments.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 102.167px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 51.0833px; transform-origin: 404px 51.0833px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 84px 8.5px; transform-origin: 84px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eACGTCGGCCATGGACATTACG\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 84px 8.5px; transform-origin: 84px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eACGTCGGCCAsssssssssss\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 128px 8.5px; transform-origin: 128px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 88px 8.5px; transform-origin: 88px 8.5px; \"\u003essssGCCATGGACATCsssss \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 40px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 40px 8.5px; \"\u003eMiddle Rev\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 144px 8.5px; transform-origin: 144px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 88px 8.5px; transform-origin: 88px 8.5px; \"\u003essssCTACAGGTACCGsssss \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 56px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 56px 8.5px; \"\u003eMiddle flipped\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 84px 8.5px; transform-origin: 84px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003essssssssssssGACATTACG\u003c/span\u003e\u003c/span\u003e\u003c/div\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: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 382px 8px; transform-origin: 382px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGenome_003R Challenge is to reconstruct a genome under near ideal error free segment creation conditions. Segments may be reversed. The segments start at random locations.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003col style=\"block-size: 163.467px; counter-reset: list-item 0; 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 81.7333px; transform-origin: 391px 81.7333px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 148.5px 8px; transform-origin: 148.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSegments may be reversed (Change from 003)\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 111.5px 8px; transform-origin: 111.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSegments start at random positions\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 102.5px 8px; transform-origin: 102.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGenome length is unconstrained\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 91px 8px; transform-origin: 91px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eLength of each segment - 48\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 153.5px 8px; transform-origin: 153.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAll segments may overlap by 16 to 47 characters\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 81.5px 8px; transform-origin: 81.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNo errors in the segments\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 240px 8px; transform-origin: 240px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGenome is random (No duplicate starts or ends for 16 symbols of segments)\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 88.5px 8px; transform-origin: 88.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSegment order is scrambled\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ol\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: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eInput:\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: 213px 8px; transform-origin: 213px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e segs, Array of M rows of 48 value segments. Values are [0, 1, 2, 3].\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: 26px 8px; transform-origin: 26px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eOutput:\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: 128.5px 8px; transform-origin: 128.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e Gout, Genome vector of values [0,1,2,3]\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: 31.5px 8px; transform-origin: 31.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eExample:\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: 324.5px 8px; transform-origin: 324.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e [0 1 2 3 2;1 1 2 2 3 2 ; 2 2 1 1 2] creates [0 1 2 3 2 2 1 1 2] W=5, Overlap=varies, Reverses may occur\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 84px; 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 42px; text-align: left; transform-origin: 384px 42px; 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: 25.5px 8px; transform-origin: 25.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eFuture:\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: 355.5px 8px; transform-origin: 355.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e Flipped segments(002), Random Position of Segment start locations(003),Random Segment Positions with Flips (003R), Parrot Sequence with Gen3 Long Segments, Extra Segments, Phage Phi X174, Parallel Processing Simulation(Shot Gun Approach), Haemophilus Influenza, Sequence with Segment Errors, and Chromosome 20 with its 59M length using 100K 4K-segments\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function Gout = Genome_003R(segs)\r\n% segs is an array of N segments of length 48\r\n% Construct the unique Gout sequence\r\n% Guaranteed 16 long blocks are unique\r\n  Gout=[];\r\nend","test_suite":"%%\r\ntic\r\nL=563*17;\r\nwhile 1 % Loop until create a Gtruth with no repeated 16 segments\r\n Gtruth=randi(4,1,L,'uint8')-1;\r\n \r\n Gseg=zeros(L-15,16,'uint8');\r\n GtruthR=fliplr(Gtruth);\r\n for j=1:L-15\r\n  Gseg(j,:)=Gtruth(j:j+15);\r\n  Gseg(j+L-15,:)=GtruthR(j:j+15);\r\n end\r\n Gsegv=uint32(Gseg(:,1));\r\n for j=2:16\r\n  Gsegv=4*Gsegv+uint32(Gseg(:,j));\r\n end\r\n if size(unique(Gsegv),1)==(L-15)*2\r\n  break\r\n end\r\nend % while create valid Gtruth\r\n\r\nsegs=Gtruth(1:48); % First segment is a required\r\nsegs=[segs;Gtruth(L-47:end)]; % Last Segment is required\r\nptr=1;\r\nwhile 1\r\n ptr=ptr+randi(32);\r\n if ptr+48\u003eL,break;end\r\n segs=[segs;Gtruth(ptr:ptr+47)];\r\nend\r\n\r\nv=randperm(size(segs,1)); % Segs Scrambled Over Easy\r\nsegs(:,:)=segs(v,:);\r\n\r\nf=logical(randi(2,size(segs,1),1)-1);\r\nsegs_orig=segs;\r\n\r\nsegs(f,:)=fliplr(segs(f,:));\r\n\r\n\r\n\r\nGout = Genome_003R(segs);\r\ntoc\r\n\r\nassert(isequal(Gout,Gtruth)||isequal(Gout,fliplr(Gtruth)))\r\n%assert( isequal(Gout,Gtruth) )\r\n%%\r\ntic\r\nL=2000+randi(200);\r\nwhile 1 % Loop until create a Gtruth with no repeated 16 segments\r\n Gtruth=randi(4,1,L,'uint8')-1;\r\n \r\n Gseg=zeros(L-15,16,'uint8');\r\n GtruthR=fliplr(Gtruth);\r\n for j=1:L-15\r\n  Gseg(j,:)=Gtruth(j:j+15);\r\n  Gseg(j+L-15,:)=GtruthR(j:j+15);\r\n end\r\n Gsegv=uint32(Gseg(:,1));\r\n for j=2:16\r\n  Gsegv=4*Gsegv+uint32(Gseg(:,j));\r\n end\r\n if size(unique(Gsegv),1)==(L-15)*2\r\n  break\r\n end\r\nend % while create valid Gtruth\r\n\r\nsegs=Gtruth(1:48); % First segment is a required\r\nsegs=[segs;Gtruth(L-47:end)]; % Last Segment is required\r\nptr=1;\r\nwhile 1\r\n ptr=ptr+randi(32);\r\n if ptr+48\u003eL,break;end\r\n segs=[segs;Gtruth(ptr:ptr+47)];\r\nend\r\n\r\nv=randperm(size(segs,1)); % Segs Scrambled Over Easy\r\nsegs(:,:)=segs(v,:);\r\n\r\nf=logical(randi(2,size(segs,1),1)-1);\r\nsegs_orig=segs;\r\n\r\nsegs(f,:)=fliplr(segs(f,:));\r\n\r\n\r\n\r\nGout = Genome_003R(segs);\r\ntoc\r\n\r\nassert(isequal(Gout,Gtruth)||isequal(Gout,fliplr(Gtruth)))\r\n%assert( isequal(Gout,Gtruth) )\r\n%%\r\ntic\r\nL=4000+randi(200);\r\nwhile 1 % Loop until create a Gtruth with no repeated 16 segments\r\n Gtruth=randi(4,1,L,'uint8')-1;\r\n \r\n Gseg=zeros(L-15,16,'uint8');\r\n GtruthR=fliplr(Gtruth);\r\n for j=1:L-15\r\n  Gseg(j,:)=Gtruth(j:j+15);\r\n  Gseg(j+L-15,:)=GtruthR(j:j+15);\r\n end\r\n Gsegv=uint32(Gseg(:,1));\r\n for j=2:16\r\n  Gsegv=4*Gsegv+uint32(Gseg(:,j));\r\n end\r\n if size(unique(Gsegv),1)==(L-15)*2\r\n  break\r\n end\r\nend % while create valid Gtruth\r\n\r\nsegs=Gtruth(1:48); % First segment is a required\r\nsegs=[segs;Gtruth(L-47:end)]; % Last Segment is required\r\nptr=1;\r\nwhile 1\r\n ptr=ptr+randi(32);\r\n if ptr+48\u003eL,break;end\r\n segs=[segs;Gtruth(ptr:ptr+47)];\r\nend\r\n\r\nv=randperm(size(segs,1)); % Segs Scrambled Over Easy\r\nsegs(:,:)=segs(v,:);\r\n\r\nf=logical(randi(2,size(segs,1),1)-1);\r\nsegs_orig=segs;\r\n\r\nsegs(f,:)=fliplr(segs(f,:));\r\n\r\n\r\n\r\nGout = Genome_003R(segs);\r\ntoc\r\n\r\nassert(isequal(Gout,Gtruth)||isequal(Gout,fliplr(Gtruth)))\r\n%assert( isequal(Gout,Gtruth) )\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":3,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2,"test_suite_updated_at":"2021-07-16T14:52:10.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-06-27T17:37:02.000Z","updated_at":"2021-07-16T14:52:10.000Z","published_at":"2012-10-07T22:51:12.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\u003eThis is Challenge 003R in the series on Genome DNA Sequencing. Challenge 3R includes flipped segments.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDNA Sequencing\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is naively simplified into Cody Challenges.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGenome sizes\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is another interesting wiki page.\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\u003eDNA is represented by symbols ACGT, which for Matlab will be encoded as 0123. The basic goal is to reconstruct the original serial string of ACGT given multiple short segments.\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\u003cw:r\u003e\u003cw:t\u003e Genome = ACGTCGGCCATGGACATTACG\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven three overlapping pieces, ACGTCGGCCA, GCCATGGACATC, and GACATTACG these can be readily seen to overlap and create the original if the middle is recognized as being reversed with asymetric overlaps to its adjacent segments.\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[ACGTCGGCCATGGACATTACG\\nACGTCGGCCAsssssssssss\\nssssGCCATGGACATCsssss Middle Rev\\nssssCTACAGGTACCGsssss Middle flipped\\nssssssssssssGACATTACG]]\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\u003eGenome_003R Challenge is to reconstruct a genome under near ideal error free segment creation conditions. Segments may be reversed. The segments start at random locations.\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\u003eSegments may be reversed (Change from 003)\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\u003eSegments start at random positions\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\u003eGenome length is unconstrained\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\u003eLength of each segment - 48\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\u003eAll segments may overlap by 16 to 47 characters\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNo errors in the segments\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\u003eGenome is random (No duplicate starts or ends for 16 symbols of segments)\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\u003eSegment order is scrambled\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\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e segs, Array of M rows of 48 value segments. Values are [0, 1, 2, 3].\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\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Gout, Genome vector of values [0,1,2,3]\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\u003cw:r\u003e\u003cw:t\u003e [0 1 2 3 2;1 1 2 2 3 2 ; 2 2 1 1 2] creates [0 1 2 3 2 2 1 1 2] W=5, Overlap=varies, Reverses may occur\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\u003eFuture:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Flipped segments(002), Random Position of Segment start locations(003),Random Segment Positions with Flips (003R), Parrot Sequence with Gen3 Long Segments, Extra Segments, Phage Phi X174, Parallel Processing Simulation(Shot Gun Approach), Haemophilus Influenza, Sequence with Segment Errors, and Chromosome 20 with its 59M length using 100K 4K-segments\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":44435,"title":"Testing for randomness: uniform distribution of real numbers (distribution checking)","description":"You will be presented with a variety of sequences of real numbers.  Your job is to answer the question:  \"Is this a uniformly distributed sequence of random numbers?\"\r\n\r\n*Only the distribution needs to be examined in this problem.*  (You do not need to check for autocorrelation.)  \r\n\r\n Input:   x, a row vector of real numbers.  \r\n Output:  y, a Boolean scalar.  \r\n\r\nSome sequences have been generated by MATLAB's (pseudo)random number generator, such as:\r\n\r\n  x = 0.062    0.945    0.006    0.301    0.638    0.920    0.043    0.533    0.539    0.292    0.218    0.465    0.826    0.172    0.686    0.040    0.489    0.3950    0.761    0.038\r\n\r\nOn average these will have a uniform distribution.  Thus, by splitting up the sequence into 'bins' we find for the example above there are twelve numbers falling into the 0.0-to-0.5 bin, and a further eight numbers falling into the 0.5-to-1.0 bin.  For this length of sequence (a total of twenty numbers), that would be a sufficiently even division to *retain* the hypothesis that the underlying distribution from which the numbers were sampled was indeed a random, uniform distribution function (UDF).  \r\nHowever, please note that it may be necessary to divide the data into more than just two bins.  \r\n\r\nOther sequences will have been constructed so as to weight unevenly.  For example:  \r\n\r\n  x = 7.004    1.002    1.984    3.868    2.048    1.014    1.066    1.337    1.074   60.266    1.008    1.783    2.196    1.065    1.0613    1.049    1.236    1.235    1.394    1.107\r\n\r\nhas fifteen numbers in the 1.0-to-2.0 bin, but then there are some weird 'outliers' in the remaining five numbers, which reach up to more than 60.  It does *not* seem likely that this would have been generated from a UDF.  \r\n\r\n|Note: the sequences in the examples above were for illustrative purposes; most sequences in the Test Suite are considerably longer.|\r\n\r\nSee also:\r\n\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44393 Problem 44393: \"Testing for randomness: uniform distribution of integers\"\u003e (harder)","description_html":"\u003cp\u003eYou will be presented with a variety of sequences of real numbers.  Your job is to answer the question:  \"Is this a uniformly distributed sequence of random numbers?\"\u003c/p\u003e\u003cp\u003e\u003cb\u003eOnly the distribution needs to be examined in this problem.\u003c/b\u003e  (You do not need to check for autocorrelation.)\u003c/p\u003e\u003cpre\u003e Input:   x, a row vector of real numbers.  \r\n Output:  y, a Boolean scalar.  \u003c/pre\u003e\u003cp\u003eSome sequences have been generated by MATLAB's (pseudo)random number generator, such as:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ex = 0.062    0.945    0.006    0.301    0.638    0.920    0.043    0.533    0.539    0.292    0.218    0.465    0.826    0.172    0.686    0.040    0.489    0.3950    0.761    0.038\r\n\u003c/pre\u003e\u003cp\u003eOn average these will have a uniform distribution.  Thus, by splitting up the sequence into 'bins' we find for the example above there are twelve numbers falling into the 0.0-to-0.5 bin, and a further eight numbers falling into the 0.5-to-1.0 bin.  For this length of sequence (a total of twenty numbers), that would be a sufficiently even division to \u003cb\u003eretain\u003c/b\u003e the hypothesis that the underlying distribution from which the numbers were sampled was indeed a random, uniform distribution function (UDF).  \r\nHowever, please note that it may be necessary to divide the data into more than just two bins.\u003c/p\u003e\u003cp\u003eOther sequences will have been constructed so as to weight unevenly.  For example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ex = 7.004    1.002    1.984    3.868    2.048    1.014    1.066    1.337    1.074   60.266    1.008    1.783    2.196    1.065    1.0613    1.049    1.236    1.235    1.394    1.107\r\n\u003c/pre\u003e\u003cp\u003ehas fifteen numbers in the 1.0-to-2.0 bin, but then there are some weird 'outliers' in the remaining five numbers, which reach up to more than 60.  It does \u003cb\u003enot\u003c/b\u003e seem likely that this would have been generated from a UDF.\u003c/p\u003e\u003cp\u003e\u003ctt\u003eNote: the sequences in the examples above were for illustrative purposes; most sequences in the Test Suite are considerably longer.\u003c/tt\u003e\u003c/p\u003e\u003cp\u003eSee also:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44393\"\u003eProblem 44393: \"Testing for randomness: uniform distribution of integers\"\u003c/a\u003e (harder)\u003c/li\u003e\u003c/ul\u003e","function_template":"% Some comments could go here (or below).\r\nfunction y = isItRandom(x)\r\n    % Your code goes here!\r\n    % Some more code goes here!\r\n    % And so on  :-)\r\nend","test_suite":"% It is possible that even a genuine random number generator could produce \r\n% a sequence that does not have the characteristics of a random number stream, \r\n% so a couple of incorrect assessments are allowed as 'leeway' in each test.  \r\n\r\n%%\r\n% Random, short\r\nfaults = 0;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = 1000 * rand(1, 20+randi(10));\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% Bimodal, short\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = [rand(1, 10+randi(5)), 999 + rand(1, 10+randi(5))];\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Random, medium\r\nfaults = 0;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = randi(1000) + 1000 * rand(1, 100+randi(10));\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% Bimodal, medium\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = randi(1000) + [rand(1, 50+randi(5)), 999 + rand(1, 50+randi(5))];\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% Skewed, medium\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = 10 ./ rand(1, 100+randi(10));\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Random, long\r\nfaults = 0;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = 1000 * rand(1, 500+randi(10));\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% Skewed (1), long\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = 10 ./ rand(1, 500+randi(5)) - randi(1000);\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% Skewed (2), long\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = randi(1000) - 10 ./ rand(1, 500+randi(5));\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% Bimodal, long\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = [rand(1, 250+randi(5)), 999 + rand(1, 250+randi(5))];\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% 'Normal' (a.k.a. 'Gaussian'), long\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = 250 * randn(1, 500+randi(5));\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-12-03T12:12:04.000Z","updated_at":"2025-11-30T03:43:10.000Z","published_at":"2017-12-03T13:21:39.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will be presented with a variety of sequences of real numbers. Your job is to answer the question: \\\"Is this a uniformly distributed sequence of random 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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOnly the distribution needs to be examined in this problem.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (You do not need to check for autocorrelation.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input:   x, a row vector of real numbers.  \\n Output:  y, a Boolean scalar.]]\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\u003eSome sequences have been generated by MATLAB's (pseudo)random number generator, such as:\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 = 0.062    0.945    0.006    0.301    0.638    0.920    0.043    0.533    0.539    0.292    0.218    0.465    0.826    0.172    0.686    0.040    0.489    0.3950    0.761    0.038]]\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\u003eOn average these will have a uniform distribution. Thus, by splitting up the sequence into 'bins' we find for the example above there are twelve numbers falling into the 0.0-to-0.5 bin, and a further eight numbers falling into the 0.5-to-1.0 bin. For this length of sequence (a total of twenty numbers), that would be a sufficiently even division 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\u003eretain\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e the hypothesis that the underlying distribution from which the numbers were sampled was indeed a random, uniform distribution function (UDF). However, please note that it may be necessary to divide the data into more than just two bins.\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\u003eOther sequences will have been constructed so as to weight unevenly. For example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[x = 7.004    1.002    1.984    3.868    2.048    1.014    1.066    1.337    1.074   60.266    1.008    1.783    2.196    1.065    1.0613    1.049    1.236    1.235    1.394    1.107]]\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\u003ehas fifteen numbers in the 1.0-to-2.0 bin, but then there are some weird 'outliers' in the remaining five numbers, which reach up to more than 60. It does\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\u003enot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e seem likely that this would have been generated from a UDF.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote: the sequences in the examples above were for illustrative purposes; most sequences in the Test Suite are considerably longer.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee also:\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=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44393\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44393: \\\"Testing for randomness: uniform distribution of integers\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (harder)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":44031,"title":"Matrix Manipulation","description":"Given an m*n matrix, see if a matrix contains any 0s in any row. if it contains 0 anywhere in any particular row, delete that row and fill that row with random integer values between 3 to 15. \r\nFor example: mat = [3 2 1 3; 3 0 0 1; 0 4 3 1];\r\nanswer = [3 2 1 3; 4 7 5 12; 4 9 10 14]","description_html":"\u003cp\u003eGiven an m*n matrix, see if a matrix contains any 0s in any row. if it contains 0 anywhere in any particular row, delete that row and fill that row with random integer values between 3 to 15. \r\nFor example: mat = [3 2 1 3; 3 0 0 1; 0 4 3 1];\r\nanswer = [3 2 1 3; 4 7 5 12; 4 9 10 14]\u003c/p\u003e","function_template":"function y = matrixManipulation(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [3 2 1 3; 3 0 0 1; 0 4 3 1];\r\ny = matrixManipulation(x);\r\n\r\nv = 3:15;\r\nassert(isequal(x(1,:),y(1,:)))\r\nassert(isempty(setdiff(y(2,:),v)))\r\nassert(isempty(setdiff(y(3,:),v)))\r\n\r\n%%\r\nx = eye(4);\r\ny = matrixManipulation(x);\r\n\r\nv = 3:15;\r\nfor i = 1:4\r\n assert(isempty(setdiff(y(i,:),v)))\r\nend\r\n\r\n%%\r\nx = ones(4);\r\ny = matrixManipulation(x);\r\nassert(isequal(x,y))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":111192,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":39,"test_suite_updated_at":"2017-01-25T20:25:39.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2017-01-21T05:38:31.000Z","updated_at":"2026-03-02T13:57:32.000Z","published_at":"2017-01-21T05:38:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an m*n matrix, see if a matrix contains any 0s in any row. if it contains 0 anywhere in any particular row, delete that row and fill that row with random integer values between 3 to 15. For example: mat = [3 2 1 3; 3 0 0 1; 0 4 3 1]; answer = [3 2 1 3; 4 7 5 12; 4 9 10 14]\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":44272,"title":"Generate one sample of uniform random numbers between -pi and +pi","description":"Generate one sample of uniform random numbers between -pi and +pi.","description_html":"\u003cp\u003eGenerate one sample of uniform random numbers between -pi and +pi.\u003c/p\u003e","function_template":"function y = rndpi(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nw=0;\r\nfor k=1:10^3\r\n    w=w+rndpi(1);\r\nend\r\n    \r\nassert(w\u003c1000)\r\n\r\n%%\r\nw=0;\r\nfor k=1:10^3\r\n    w=w+rndpi(1)^2;\r\nend\r\n    \r\nassert(w\u003e10^3)\r\n\r\n%% \r\nw=0;\r\nfor k=1:10^3\r\n    w=min(w,rndpi(1));\r\nend\r\n\r\nassert(w\u003c-pi*0.9)\r\nassert(w\u003e-pi*1.1)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":43,"test_suite_updated_at":"2017-08-02T00:03:53.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-08-01T23:59:01.000Z","updated_at":"2026-04-03T06:50:32.000Z","published_at":"2017-08-01T23:59:07.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eGenerate one sample of uniform random numbers between -pi and +pi.\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":2289,"title":"サイコロを作ろう","description":"1から6までの独立かつランダムな数値を返すような関数を作成しましょう。\r\n\r\n例：\r\n\r\n  \u003e\u003e [x1,x2] = rollDice();\r\n\r\nと入力すると\r\n\r\n  x1 = 5\r\n  x2 = 2\r\n\r\nのような解を返します。","description_html":"\u003cp\u003e1から6までの独立かつランダムな数値を返すような関数を作成しましょう。\u003c/p\u003e\u003cp\u003e例：\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u0026gt;\u0026gt; [x1,x2] = rollDice();\r\n\u003c/pre\u003e\u003cp\u003eと入力すると\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ex1 = 5\r\nx2 = 2\r\n\u003c/pre\u003e\u003cp\u003eのような解を返します。\u003c/p\u003e","function_template":"function [x1 x2] = rollDice(x)\r\n  x1 = x;\r\n  x2 = x;\r\nend","test_suite":"%%\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)","published":true,"deleted":false,"likes_count":6,"comments_count":4,"created_by":11824,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":404,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":36,"created_at":"2014-04-16T07:43:57.000Z","updated_at":"2026-03-16T19:03:50.000Z","published_at":"2014-04-16T07:48:39.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\u003e1から6までの独立かつランダムな数値を返すような関数を作成しましょう。\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=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[\u003e\u003e [x1,x2] = rollDice();]]\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\u003eと入力すると\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[x1 = 5\\nx2 = 2]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eのような解を返します。\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2793,"title":"Guess","description":"A random number between 1 and 10 is created for the variable y. Guess what its value is.","description_html":"\u003cp\u003eA random number between 1 and 10 is created for the variable y. Guess what its value is.\u003c/p\u003e","function_template":"function y = guess(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 10;\r\ny_correct = randi(x);\r\nassert(isequal(guess(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":33304,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":90,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-17T14:28:15.000Z","updated_at":"2026-02-18T16:36:34.000Z","published_at":"2014-12-17T14:28:15.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA random number between 1 and 10 is created for the variable y. Guess what its value is.\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":44477,"title":"Find left eigenvector of row stochastic matrix","description":"Find the left eigenvector of the given stochastic matrix P that has eigenvalue 1. \r\nNormalize the vector so the sum of the entries is 1 (called a probability vector). \r\nThe output vector should be a row vector.\r\n\r\n(This can be thought of as a stationary distribution for a Markov chain.\r\n\u003chttps://en.wikipedia.org/wiki/Markov_chain#Finite_state_space\u003e )\r\n\r\nE.g:\r\nFor P = [ .7 .3 ;\r\n          .6 .4 ]\r\nreturn [ .6666666 .3333333 ] (or any vector close to this would be accepted).\r\n\r\nThe left eigenvector v of a matrix P (with eigenvalue 1) is a row vector such that v=v*P. ","description_html":"\u003cp\u003eFind the left eigenvector of the given stochastic matrix P that has eigenvalue 1. \r\nNormalize the vector so the sum of the entries is 1 (called a probability vector). \r\nThe output vector should be a row vector.\u003c/p\u003e\u003cp\u003e(This can be thought of as a stationary distribution for a Markov chain. \u003ca href = \"https://en.wikipedia.org/wiki/Markov_chain#Finite_state_space\"\u003ehttps://en.wikipedia.org/wiki/Markov_chain#Finite_state_space\u003c/a\u003e )\u003c/p\u003e\u003cp\u003eE.g:\r\nFor P = [ .7 .3 ;\r\n          .6 .4 ]\r\nreturn [ .6666666 .3333333 ] (or any vector close to this would be accepted).\u003c/p\u003e\u003cp\u003eThe left eigenvector v of a matrix P (with eigenvalue 1) is a row vector such that v=v*P.\u003c/p\u003e","function_template":"function v = find_left_evector(P)\r\n  v = [ .2 .3 .5];\r\nend","test_suite":"%%\r\nP = [  0.536668396674091   0.463331603325909;\r\n   0.628171641615730   0.371828358384270]\r\npc = [  0.575510558055411   0.424489441944469]\r\nassert(  sum(abs(pc - find_left_evector(P))) \u003c .001 )\r\n\r\n%%\r\nP =[   0.490126287130221   0.063810857836059   0.446062855033720;\r\n   0.351100472099344   0.522156819868217   0.126742708032439;\r\n   0.016119408853126   0.459671543012232   0.524209048134642]\r\npc =  [0.270232959896393   0.376204159405191   0.353562880698251]\r\nassert(  sum(abs(pc - find_left_evector(P))) \u003c .001 )\r\n\r\n%%\r\nP= [   0.000295973934872   0.298979544879362   0.282216466268297   0.418508014917470;\r\n   0.305614143800419   0.169335098209289   0.318119927666875   0.206930830323418;\r\n   0.274040969162178   0.358495094643379   0.257083476284641   0.110380459909802;\r\n   0.362700492263105   0.083477678435433   0.309658548481881   0.244163280819581]\r\npc = [   0.237529575372038   0.234524560057871   0.289883972779590   0.238061891790800]\r\nassert(  sum(abs(pc - find_left_evector(P))) \u003c .001 )\r\n\r\n%%\r\nP =[   0.206900154678670   0.148378489932199   0.322150635982830   0.314216412936451   0.008354306469849;\r\n   0.260256141508665   0.099217372921749   0.160593109350477   0.261083704996893   0.218849671222215;\r\n   0.239143386227262   0.208748199654121   0.157570271848609   0.243411982213855   0.151126160056153;\r\n   0.278091600172443   0.098346886570860   0.258034757795764   0.264131640312126   0.101395115148807;\r\n   0.332707101127035   0.028439807716601   0.229818689497991   0.282967894831867   0.126066506826505]\r\npc = [  0.254374450013656   0.129637934241022   0.235068662146163   0.273627230656508   0.107291722942842]\r\nassert(  sum(abs(pc - find_left_evector(P))) \u003c .001 )\r\n\r\n%% \r\nP = [   0.132301071463971   0.118964494040826   0.133724887078453   0.164995061775188   0.040846954071962   0.145500258220330   0.063426378618235   0.129644361564668   0.066729252864125   0.003867280302243;\r\n   0.132078324816755   0.158842681592186   0.021345097287269   0.116096463338978   0.011399564178502   0.140138687399582   0.177066809582189   0.065776052252923   0.015539976826641   0.161716342724976;\r\n   0.017067043037843   0.083233444933711   0.084600955134299   0.150272784632142   0.123640429188190   0.137325974960960   0.036120936255903   0.135601262483591   0.103142500899762   0.128994668473599;\r\n   0.127071623799322   0.131013361691360   0.060749137485579   0.030485605165969   0.125140409826980   0.094272001681351   0.121644411243946   0.136891396463886   0.033674609302846   0.139057443338763;\r\n   0.084699633418611   0.028081492787019   0.099909358534447   0.168407595038166   0.130764931483391   0.116220306891560   0.110612661554048   0.104402758049448   0.008236859479167   0.148664402764143;\r\n   0.037733369184740   0.169572983103210   0.070941210905428   0.141330441010770   0.114190951485877   0.169117213270117   0.068871861233898   0.031453791309126   0.128616891142078   0.068171287354757;\r\n   0.021608820428507   0.118635979900457   0.091045405806744   0.126644005048004   0.091912863890716   0.097377838242980   0.031186928136198   0.209989895433764   0.076205987507149   0.135392275605482;\r\n   0.200801721742751   0.165730897943703   0.044066996479387   0.107288300031138   0.095274563967673   0.014633627838425   0.006128344875136   0.064690108023551   0.161069824250084   0.140315614848152;\r\n   0.037498791878979   0.007834244109932   0.054720922238198   0.055198093789809   0.174871800390143   0.185715803502670   0.090230412306462   0.198107071552124   0.082250330729007   0.113572529502674;\r\n   0.040849998758864   0.202090814652096   0.005128610576370   0.187791319910819   0.079274530709314   0.157633265466675   0.045977261982389   0.055884488572257   0.156673705328071   0.068696004043146]\r\npc = [ 0.088341588996646   0.125827616221029   0.062738581066497   0.123052908662097   0.095658900658645   0.125218780388122   0.080036509221240   0.105209734515629   0.082635110452906   0.111280269817457]\r\nassert(  sum(abs(pc - find_left_evector(P))) \u003c .001 )\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":65480,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":15,"test_suite_updated_at":"2018-01-03T20:26:54.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-01-03T20:25:00.000Z","updated_at":"2026-03-11T09:48:37.000Z","published_at":"2018-01-03T20:26:54.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the left eigenvector of the given stochastic matrix P that has eigenvalue 1. Normalize the vector so the sum of the entries is 1 (called a probability vector). The output vector should be a row vector.\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(This can be thought of as a stationary distribution for a Markov chain.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Markov_chain#Finite_state_space\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/Markov_chain#Finite_state_space\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt; )\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eE.g: For P = [ .7 .3 ; .6 .4 ] return [ .6666666 .3333333 ] (or any vector close to this would be accepted).\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 left eigenvector v of a matrix P (with eigenvalue 1) is a row vector such that v=v*P.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44315,"title":"Predicting life and death of a memory-less light bulb","description":"*\u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161* \r\n\r\nYou have a light bulb that can fail any moment according to the exponential probability distribution. \r\n\r\nAt any moment, the probability that it will survive just N hours = exp(-N*P), where P is a constant. \r\n\r\nNotice that this probability is very small if N is very large. \r\n\r\nNow suppose, the bulb has already survived N hours. \r\n\r\nPlease calculate the probability of its surviving M more hours.\r\n","description_html":"\u003cp\u003e\u003cb\u003e\u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161 \u0026#128161\u003c/b\u003e\u003c/p\u003e\u003cp\u003eYou have a light bulb that can fail any moment according to the exponential probability distribution.\u003c/p\u003e\u003cp\u003eAt any moment, the probability that it will survive just N hours = exp(-N*P), where P is a constant.\u003c/p\u003e\u003cp\u003eNotice that this probability is very small if N is very large.\u003c/p\u003e\u003cp\u003eNow suppose, the bulb has already survived N hours.\u003c/p\u003e\u003cp\u003ePlease calculate the probability of its surviving M more hours.\u003c/p\u003e","function_template":"function hope = fate(N,P,M)\r\n  hope=exp(-(N+M)*P);\r\nend","test_suite":"%%\r\nN = 1;\r\nP=1;\r\nM=0;\r\nhope_correct = 1;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN = 1;\r\nP=0;\r\nM=1;\r\nhope_correct = 1;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN=1;\r\nP=1;\r\nM=1;\r\nhope_correct = 0.3679;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN=2;\r\nP=1;\r\nM=1;\r\nhope_correct = 0.3679;\r\nassert(fate(N,P,M)\u003ehope_correct*0.999)\r\n%%\r\nN=2;\r\nP=1;\r\nM=2;\r\nhope_correct = 0.1353;\r\nassert(fate(N,P,M)\u003chope_correct*1.1)\r\n%%\r\nN=2;\r\nP=2;\r\nM=2;\r\nhope_correct = 0.0183;\r\nassert(fate(N,P,M)\u003chope_correct*1.1)\r\n%%","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":336,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-12T02:53:45.000Z","updated_at":"2026-03-25T02:55:11.000Z","published_at":"2017-10-16T01:45:07.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161 \u0026amp;#128161\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou have a light bulb that can fail any moment according to the exponential probability distribution.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAt any moment, the probability that it will survive just N hours = exp(-N*P), where P is a constant.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNotice that this probability is very small if N is very large.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNow suppose, the bulb has already survived N hours.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePlease calculate the probability of its surviving M more hours.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":43592,"title":"Sample from random roulette","description":"Given a list of values and their probabilities sample 10,000 values.\r\nExample:\r\nx = [1 2 3 4 5];\r\nprob = [0.2 0.1 0.4 0.1 0.2]\r\nNote that sum(prob)=1. Function output should look like this:\r\noutput = [1 4 3 1 4 1 2 3 1 1 1 ... 3 4 2] % a vector of length 10,000\r\nAll vectors are meant to be row vectors.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 194.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 97.15px; transform-origin: 407px 97.15px; 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: 208.5px 8px; transform-origin: 208.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a list of values and their probabilities sample 10,000 values.\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: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 64px 8.5px; tab-size: 4; transform-origin: 64px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ex = [1 2 3 4 5];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 112px 8.5px; tab-size: 4; transform-origin: 112px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eprob = [0.2 0.1 0.4 0.1 0.2]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 190px 8px; transform-origin: 190px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNote that sum(prob)=1. Function output should look like this:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 280px 8.5px; tab-size: 4; transform-origin: 280px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 128px 8.5px; transform-origin: 128px 8.5px; \"\u003eoutput = [1 4 3 1 4 1 2 3 1 1 1 \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); perspective-origin: 12px 8.5px; text-decoration: none; text-decoration-color: rgb(14, 0, 255); text-emphasis-color: rgb(14, 0, 255); transform-origin: 12px 8.5px; \"\u003e...\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); perspective-origin: 140px 8.5px; text-decoration: none; text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); transform-origin: 140px 8.5px; \"\u003e 3 4 2] % a vector of length 10,000\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 124.5px 8px; transform-origin: 124.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAll vectors are meant to be row vectors.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function output = RandomRoulette(x,prob)\r\n    draws = 10000; % Do not change the # of draws\r\n    output = ?;\r\nend","test_suite":"%%\r\nx = 1:3;\r\nprob = [0.3 0.2 0.5];\r\nassert( numel(RandomRoulette(x,prob))==1e4 \u0026\u0026 (sum(RandomRoulette(x,prob))\u003c1.5*22*1e3) \u0026\u0026 (sum(RandomRoulette(x,prob))\u003e0.5*22*1e3) \u0026\u0026 all(ismember(RandomRoulette(x,prob),x)) )\r\n\r\n%%\r\nx = 1:4;\r\nprob = [0.1 0.2 0.3 0.4];\r\nassert( numel(RandomRoulette(x,prob))==1e4 \u0026\u0026 (sum(RandomRoulette(x,prob))\u003c1.5*30*1e3) \u0026\u0026 (sum(RandomRoulette(x,prob))\u003e0.5*30*1e3) \u0026\u0026 all(ismember(RandomRoulette(x,prob),x)) \u0026\u0026 any(RandomRoulette(x,prob)~=RandomRoulette(x,prob)))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":8,"created_by":29461,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":22,"test_suite_updated_at":"2021-11-14T11:00:46.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-22T21:06:06.000Z","updated_at":"2026-01-20T13:29:43.000Z","published_at":"2016-10-22T21:06:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a list of values and their probabilities sample 10,000 values.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[x = [1 2 3 4 5];\\nprob = [0.2 0.1 0.4 0.1 0.2]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNote that sum(prob)=1. Function output should look like this:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[output = [1 4 3 1 4 1 2 3 1 1 1 ... 3 4 2] % a vector of length 10,000]]\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\u003eAll vectors are meant to be row vectors.\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":596,"title":"More luck than brains ","description":"Give a random function that guess and return numbers from 1 to 6 exactly like the test suite .","description_html":"\u003cp\u003eGive a random function that guess and return numbers from 1 to 6 exactly like the test suite .\u003c/p\u003e","function_template":"function y = More_luck_then_brains()\r\n  y = 1 ;\r\nend","test_suite":"%%\r\nassert(isequal(More_luck_then_brains(),randi(6)));\r\n%%\r\nassert(isequal(More_luck_then_brains(),randi(6)));\r\n%%\r\nassert(isequal(More_luck_then_brains(),randi(6)));\r\n;","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":3077,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":69,"test_suite_updated_at":"2012-04-18T10:33:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-04-18T05:12:54.000Z","updated_at":"2025-06-13T07:05:05.000Z","published_at":"2012-04-18T05:14: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\",\"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\u003eGive a random function that guess and return numbers from 1 to 6 exactly like the test suite .\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":51970,"title":"Determine the average number of rounds for the following game.","description":"Each round a uniformly distributed random number is picked between 0 and 1. The game ends when the sum of the random numbers is greater than 1. Find the average number of rounds the game will end in. Note: Use 100,000 trials of the game.\r\n","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: 72px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 36px; transform-origin: 407px 36px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eEach round a uniformly distributed random number is picked between 0 and 1. The game ends when the sum of the random numbers is greater than 1. Find the average number of rounds the game will end in. Note: Use 100,000 trials of the game.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [val] = playgame()\r\n  \r\nend","test_suite":"%%\r\nsol=exp(1);\r\ny_correct = playgame();\r\nassessVariableEqual('y_correct',sol);\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":342621,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":12,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2021-06-04T15:56:32.000Z","updated_at":"2021-06-08T16:49:58.000Z","published_at":"2021-06-04T15:56:32.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\u003eEach round a uniformly distributed random number is picked between 0 and 1. The game ends when the sum of the random numbers is greater than 1. Find the average number of rounds the game will end in. Note: Use 100,000 trials of the game.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\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":699,"title":"Reading Web Binary Files (jpg,pdf,tiff,png)","description":"The Challenge is to access a Web binary file, a PDF in this case, and provide the value of a specific byte.\r\n\r\n.\r\n\r\nAccessing files on the web provide multiple challenges due to the data structures being text or binary.\r\n\r\nThe functions urlread and urlwrite both access web files but provide different results for binary files. (jpg, pdf, tiff, png, ppt)\r\n\r\n\r\n\r\nInput:\r\n\r\nfname 'http://some valid location/file.pdf'\r\n\r\nn      The byte for which the value is being requested.\r\n\r\nOutput: Value of the byte, an integer ranging from 0 to 255\r\n\r\n.\r\n\r\n\r\nA solution exists in the test suite to show the different data created by urlread and urlwrite for binary data.\r\n\r\nA urlreadbin can be readily created to directly push the file to an array.","description_html":"\u003cp\u003eThe Challenge is to access a Web binary file, a PDF in this case, and provide the value of a specific byte.\u003c/p\u003e\u003cp\u003e.\u003c/p\u003e\u003cp\u003eAccessing files on the web provide multiple challenges due to the data structures being text or binary.\u003c/p\u003e\u003cp\u003eThe functions urlread and urlwrite both access web files but provide different results for binary files. (jpg, pdf, tiff, png, ppt)\u003c/p\u003e\u003cp\u003eInput:\u003c/p\u003e\u003cp\u003efname 'http://some valid location/file.pdf'\u003c/p\u003e\u003cp\u003en      The byte for which the value is being requested.\u003c/p\u003e\u003cp\u003eOutput: Value of the byte, an integer ranging from 0 to 255\u003c/p\u003e\u003cp\u003e.\u003c/p\u003e\u003cp\u003eA solution exists in the test suite to show the different data created by urlread and urlwrite for binary data.\u003c/p\u003e\u003cp\u003eA urlreadbin can be readily created to directly push the file to an array.\u003c/p\u003e","function_template":"function y = access_web_pdf(fname,n)\r\n  y = 0;\r\nend","test_suite":"%%\r\n% Cody External accessibility\r\n\r\n% This file may need to change in the future\r\nin_f='http://www.pvplc.org/_volunteer/docs/PVPLC%20Trail%20Crew%20Training%20Jan-Jun%202012.pdf';\r\n\r\nout_f='PVPLC.pdf';\r\n\r\nurlwrite(in_f,out_f);\r\n\r\nfid=fopen(out_f);\r\nurlwrite_out=fread(fid,128,'*uint8'); \r\n% Display Correct Binary Data\r\nurlwrite_out(1:16)'\r\n\r\n\r\nblock=urlread(in_f);\r\n% Display invalid binary data\r\nurlread_out=block(1:16)-char(0)\r\n% unicode urlread conversion affects bytes 12 thru 15\r\n\r\nn=12\r\nbyte_val = access_web_pdf(in_f,n)\r\n\r\nbyte_correct=181;\r\n\r\nassert(isequal(byte_val,byte_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-05-18T04:26:21.000Z","updated_at":"2012-05-21T05:35:07.000Z","published_at":"2012-05-21T05:35:07.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eThe Challenge is to access a Web binary file, a PDF in this case, and provide the value of a specific byte.\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\u003eAccessing files on the web provide multiple challenges due to the data structures being text or binary.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe functions urlread and urlwrite both access web files but provide different results for binary files. (jpg, pdf, tiff, png, ppt)\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\u003eInput:\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\u003efname 'http://some valid location/file.pdf'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en The byte for which the value is being requested.\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: Value of the byte, an integer ranging from 0 to 255\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\u003eA solution exists in the test suite to show the different data created by urlread and urlwrite for binary data.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA urlreadbin can be readily created to directly push the file to an array.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":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":10719,"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-06T20:28:48.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":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":1729,"title":"Can you beat the lottery again (for hardcore coder) ?","description":"Inspired by the Problem 1713 by Chris E.\r\n\r\nHere is the code that generates the first lottery number:\r\n\r\n rng('shuffle');\r\n number1=randi([10,20]);\r\n for j=1:number1\r\n   round(rand(1,1));\r\n end\r\n\r\nCan you find the number even with the rng('shuffle')?\r\n\r\nAs everybody knows hacking methods, I prefer a logical solution.\r\n\r\nGood luck!","description_html":"\u003cp\u003eInspired by the Problem 1713 by Chris E.\u003c/p\u003e\u003cp\u003eHere is the code that generates the first lottery number:\u003c/p\u003e\u003cpre\u003e rng('shuffle');\r\n number1=randi([10,20]);\r\n for j=1:number1\r\n   round(rand(1,1));\r\n end\u003c/pre\u003e\u003cp\u003eCan you find the number even with the rng('shuffle')?\u003c/p\u003e\u003cp\u003eAs everybody knows hacking methods, I prefer a logical solution.\u003c/p\u003e\u003cp\u003eGood luck!\u003c/p\u003e","function_template":"function y = big_lottery()\r\n  y = 0;\r\nend","test_suite":"%%\r\nrng('shuffle');\r\nnumber1=randi([10,20]);\r\nfor j=1:number1\r\n    round(rand(1,1));\r\nend\r\nassert(isequal(big_lottery(),number1))\r\n\r\n%%\r\nrng('shuffle');\r\nnumber2=randi([10,20]);\r\nfor j=1:number2\r\n    round(rand(1,1));\r\nend\r\nassert(isequal(big_lottery(),number2))\r\n\r\n\r\n%%\r\nrng('shuffle');\r\nnumber3=randi([10,20]);\r\nfor j=1:number3\r\n    round(rand(1,1));\r\nend\r\nassert(isequal(big_lottery(),number3))\r\n\r\n","published":true,"deleted":false,"likes_count":7,"comments_count":0,"created_by":5390,"edited_by":427930,"edited_at":"2022-10-11T14:42:55.000Z","deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2013-07-20T19:03:59.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-20T18:08:18.000Z","updated_at":"2022-10-11T14:42:56.000Z","published_at":"2013-07-20T18:08:33.000Z","restored_at":null,"restored_by":null,"spam":null,"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 the Problem 1713 by Chris E.\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 is the code that generates the first lottery number:\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[ rng('shuffle');\\n number1=randi([10,20]);\\n for j=1:number1\\n   round(rand(1,1));\\n end]]\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\u003eCan you find the number even with the rng('shuffle')?\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\u003eAs everybody knows hacking methods, I prefer a logical solution.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGood luck!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":1713,"title":"Can you beat the lottery?","description":"Well this one you may not get every time, but it is a lottery! Here is the code that generates the lottery numbers (you can try to use it to your advantage if you can):\r\n\r\n    check = 1;\r\n    while check == 1\r\n        D1 = round(rand(1,1)*5+1);\r\n        D2 = round(rand(1,1)*5+1);\r\n        D3 = round(rand(1,1)*5+1);\r\n        draw = sort([D1 D2 D3]);\r\n        if size(unique(fn), 2) == 3\r\n            check = 0;\r\n        end\r\n    end\r\n\r\nSo \"draw\" is the draw that is made. It is made up of 3 numbers between 1 and 5.  Note that the numbers do not repeat.  SO an example of an input is:\r\n\r\nlottery = [4 3 5];\r\n\r\nNow the odds are 1 in 10 (or at least that is the total combinations that can occur), so if you get it exactly you win! (you win the correct answer...) \r\n\r\nGood luck, and please play responsibly...","description_html":"\u003cp\u003eWell this one you may not get every time, but it is a lottery! Here is the code that generates the lottery numbers (you can try to use it to your advantage if you can):\u003c/p\u003e\u003cpre\u003e    check = 1;\r\n    while check == 1\r\n        D1 = round(rand(1,1)*5+1);\r\n        D2 = round(rand(1,1)*5+1);\r\n        D3 = round(rand(1,1)*5+1);\r\n        draw = sort([D1 D2 D3]);\r\n        if size(unique(fn), 2) == 3\r\n            check = 0;\r\n        end\r\n    end\u003c/pre\u003e\u003cp\u003eSo \"draw\" is the draw that is made. It is made up of 3 numbers between 1 and 5.  Note that the numbers do not repeat.  SO an example of an input is:\u003c/p\u003e\u003cp\u003elottery = [4 3 5];\u003c/p\u003e\u003cp\u003eNow the odds are 1 in 10 (or at least that is the total combinations that can occur), so if you get it exactly you win! (you win the correct answer...)\u003c/p\u003e\u003cp\u003eGood luck, and please play responsibly...\u003c/p\u003e","function_template":"function draw = lottery()\r\n  draw = [x x x];\r\nend","test_suite":"%%\r\ncheck = 1;\r\nwhile check == 1\r\n     D1 = round(rand(1,1)*4+1);\r\n     D2 = round(rand(1,1)*4+1);\r\n     D3 = round(rand(1,1)*4+1);\r\n     draw = sort([D1 D2 D3]);\r\n        if size(unique(draw), 2) == 3\r\n            check = 0;\r\n        end\r\nend\r\nassert(isequal(sort(lottery()),draw))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":15013,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":48,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-12T21:15:43.000Z","updated_at":"2025-11-17T20:59:24.000Z","published_at":"2013-07-12T22:07:45.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\u003eWell this one you may not get every time, but it is a lottery! Here is the code that generates the lottery numbers (you can try to use it to your advantage if you can):\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[    check = 1;\\n    while check == 1\\n        D1 = round(rand(1,1)*5+1);\\n        D2 = round(rand(1,1)*5+1);\\n        D3 = round(rand(1,1)*5+1);\\n        draw = sort([D1 D2 D3]);\\n        if size(unique(fn), 2) == 3\\n            check = 0;\\n        end\\n    end]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSo \\\"draw\\\" is the draw that is made. It is made up of 3 numbers between 1 and 5. Note that the numbers do not repeat. SO an example of an input is:\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\u003elottery = [4 3 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\u003eNow the odds are 1 in 10 (or at least that is the total combinations that can occur), so if you get it exactly you win! (you win the correct answer...)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGood luck, and please play responsibly...\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":2356,"title":"Simulating the selection of a state with given probabilities","description":"Lets say we have 3 different states [1,2,3] with the probabilities of occurrences of each state is given as [0.5 0.2 0.3]. Which means 50% state 1 will be selected among others. Generate randomly selected states with the probabilities given\r\n\r\nOutput array will be consisting of state numbers based on the probabilities given as input. \r\n\r\nExample:\r\n(Quick tip: The higher simulation sampling sizes the more robust results)","description_html":"\u003cp\u003eLets say we have 3 different states [1,2,3] with the probabilities of occurrences of each state is given as [0.5 0.2 0.3]. Which means 50% state 1 will be selected among others. Generate randomly selected states with the probabilities given\u003c/p\u003e\u003cp\u003eOutput array will be consisting of state numbers based on the probabilities given as input.\u003c/p\u003e\u003cp\u003eExample:\r\n(Quick tip: The higher simulation sampling sizes the more robust results)\u003c/p\u003e","function_template":"function states = select_state(probs)\r\n  states = 0;\r\nend","test_suite":"%%\r\nprobs = rand;\r\nwhile sum(probs) \u003c 1\r\n    a = rand;\r\n    if a + sum(probs) \u003e 1\r\n        probs = [probs 1-sum(probs)];\r\n        break;\r\n    else\r\n        probs = [probs a];\r\n    end\r\nend\r\n\r\nstates = 1:length(probs);\r\nfor i = 1:100\r\n    y{i,1} = select_state(probs);\r\n    [nelements,centers] = hist(y{i},states);\r\n    probs_result{i} = nelements/length(y{i});\r\n    error(i,1) = sum(abs(probs-probs_result{i}));\r\nend\r\n\r\nassert(mean(error) \u003c= 0.05 \u0026 mean(error) \u003e 0);","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":27005,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":29,"test_suite_updated_at":"2014-06-11T14:25:30.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2014-06-11T00:57:51.000Z","updated_at":"2025-11-21T18:44:38.000Z","published_at":"2014-06-11T01:00:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eLets say we have 3 different states [1,2,3] with the probabilities of occurrences of each state is given as [0.5 0.2 0.3]. Which means 50% state 1 will be selected among others. Generate randomly selected states with the probabilities given\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 array will be consisting of state numbers based on the probabilities given as input.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample: (Quick tip: The higher simulation sampling sizes the more robust results)\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":46568,"title":"Beat the RNG - EASY","description":null,"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: 110.71px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.989px 55.3551px; transform-origin: 406.996px 55.3551px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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=\"\"\u003eGenerate random n-by-m matrices.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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=\"font-style: italic; \"\u003eBut\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 generate the same matrices as in the Test Suite.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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=\"\"\u003eRead the manual. \u0026gt;:)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20px; border-bottom-left-radius: 4px; border-bottom-right-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: 403.991px 10px; transform-origin: 403.999px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ehelp \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003erandi\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = cheeseRNG(m, n)\r\n  y = randi(m, n)\r\nend","test_suite":"%%\r\nm = 1;\r\nn = 1;\r\nassert(isequal(cheeseRNG(m,n),randi(m,n)))\r\n\r\n%%\r\nm = 5;\r\nn = 4;\r\nassert(isequal(cheeseRNG(m,n),randi(m,n)))\r\n\r\n%%\r\nm = 10;\r\nn = 15;\r\nassert(isequal(cheeseRNG(m,n),randi(m,n)))\r\n\r\n%%\r\nm = 1337;\r\nn = 42;\r\nassert(isequal(cheeseRNG(m,n),randi(m,n)))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":543257,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-08-28T23:56:07.000Z","updated_at":"2025-11-19T17:08:00.000Z","published_at":"2020-08-29T00:32:14.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\u003eGenerate random n-by-m matrices.\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eBut\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e generate the same matrices as in the Test Suite.\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\u003eRead the manual. \u0026gt;:)\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[help randi]]\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":52323,"title":"Guess the number I'm thinking of (Part 2)","description":"Have you tried the original \"Guess the number I'm thinking of\" (Problem 44630)?  This problem is just like that, except that the range of possible numbers can change, and pre-calculated answers are explicitly disallowed.  Computing all possible permutations on the fly is not disallowed per se, but it is discouraged due to the high computational load involved.  \r\nIn 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 N (inclusive).  N is an integer between 4 and 1000 (inclusive) that will be specified in each test as upperLimit.  I don't provide any other clues about the number that is to be guessed.\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 substantially better than 33.3%.  The success rate is defined as follows.  \r\nsuccess rate = (wins + draws/2) / games\r\nThe precise value of the expected success rate (when guessing with the optimal strategy) depends upon the value of N:  when N = 4 you should be able to achieve a success rate of 17/48 ≈ 35.4% on average, increasing monotonically to above 50% for N ≥ 24, eventually approaching an asymptote of 19/36 ≈ 52.8%.  (See the Test Suite for details of the thresholds applied.) \r\n\r\nRELATED PROBLEM:  \r\nProblem 44630. Guess the number I'm thinking of (Part 1)","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: 691px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 345.5px; transform-origin: 407px 345.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; 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 31.5px; text-align: left; transform-origin: 384px 31.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=\"font-style: italic; \"\u003eHave you tried the original \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://au.mathworks.com/matlabcentral/cody/problems/44630-guess-the-number-i-m-thinking-of\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"font-style: italic; \"\u003e\"Guess the number I'm thinking of\" (Problem 44630)\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e?  This problem is just like that, except that the range of possible numbers can change, and pre-calculated answers are explicitly disallowed.  Computing all possible permutations on the fly is not disallowed per se, but it is discouraged due to the high computational load involved.  \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=\"\"\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: 181px; 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 90.5px; transform-origin: 391px 90.5px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 41px; 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 20.5px; text-align: left; transform-origin: 363px 20.5px; 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-style: italic; font-weight: 700; \"\u003eN\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).  \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; font-weight: 700; \"\u003eN\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 is an integer between 4 and 1000 (inclusive) that will be specified in each test as \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-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eupperLimit\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.  I don't provide any other clues about the number that is to be guessed.\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: 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=\"\"\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 substantially better than 33.3%\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.  The success rate is defined as follows.  \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: 84px; 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 42px; text-align: left; transform-origin: 384px 42px; 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=\"\"\u003eThe precise value of the expected success rate (when guessing with the optimal strategy) depends upon the value of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eN\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:  when \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-style: italic; \"\u003eN\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 = 4 you should be able to achieve a success rate of 17/48 ≈ 35.4% on average, increasing monotonically to above 50% for \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-style: italic; \"\u003eN\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 ≥ 24, eventually approaching an asymptote of 19/36 ≈ 52.8%.  (See the Test Suite for details of the thresholds applied.) \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/44630\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 44630. Guess the number I'm thinking of (Part 1)\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(upperLimit, guessesOfOpponents)\r\n    y = 42;\r\nend","test_suite":"%% Anti-hacking test.\r\nassessFunctionAbsence({'rng', 'RandStream'}, 'FileName','myGuess.m')\r\n\r\n%% Anti-precalculation test.\r\n% Do not try to get evade the test.  Just follow the clear rule:  DO NOT PRECALCULATE.\r\nassessFunctionAbsence({'sub2ind', 'str2num'}, 'FileName','myGuess.m')\r\n\r\n% And while we're at it, I dislike the practice of using \"ans\" in a script.  \r\nassessFunctionAbsence({'ans'}, 'FileName','myGuess.m')\r\n\r\n% And you don't really need regexp or regexpi eithr.\r\nassessFunctionAbsence({'regexp', 'regexpi'}, 'FileName','myGuess.m')\r\n\r\n%% Ensure unique guesses of integers, which are in-range.\r\nfor j = 1 : 1000\r\n    upperLim = randi([4, 1000]);\r\n    numberToBeGuessed = randi(upperLim);\r\n    gOO = randperm(upperLim, 2);\r\n    mG = myGuess(upperLim, gOO);\r\n    assert( mG \u003e= 1  \u0026  mG \u003c= upperLim , '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%% Check the success rate several times for various values of N.\r\nmaxIts = 50000;    % 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\ntic\r\nfor j = 1 : 12\r\n%for j = 5 : 20 : 1000\r\n    %upperLim = 3 + j;\r\n    if j \u003c= 4,\r\n        % Focus on smaller N.\r\n        upperLim = randi([4, 10]);\r\n    elseif j \u003c= 8,\r\n        % Focus on intermediate N.\r\n        upperLim = randi([11, 40]);\r\n    else\r\n        % Focus on larger N.\r\n        upperLim = randi([41, 1000]);\r\n    end;\r\n    WDL = [0 0 0];\r\n    for itn = 1 : maxIts\r\n        numberToBeGuessed = randi(upperLim);\r\n        gOO = randperm(upperLim, 2);\r\n        diffs = abs( [gOO myGuess(upperLim, 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    minAcceptableSuccessRate = getCutoff(upperLim);\r\n    %[upperLim minAcceptableSuccessRate successRate]\r\n    fprintf('N = %u, Threshold = %5.2f %c, Success rate = %5.2f %c.\\r\\n', upperLim, minAcceptableSuccessRate*100, '%', successRate*100, '%');\r\n    assert( successRate \u003e= minAcceptableSuccessRate )\r\nend;\r\ntoc\r\n\r\n% Define the minimum success rate that must be achieved.  \r\n% Note:  functions must be defined at the end of a script.  See https://au.mathworks.com/help/matlab/ref/function.html?s_tid=doc_ta#description\r\nfunction threshold = getCutoff(N)\r\n    % The success rate as a function of N is fit quite well \r\n    % by an equation of the form  s = sInf – A / N^k\r\n    expectedSuccessRate = 0.527353226 - 0.740005 / N^1.050420528;   \r\n    % (From fitting 310 points recorded to four decimal places.  \r\n    % The coefficients appear to be accurate to at least 3 significant figures.)  \r\n\r\n    % However, practically speaking we need to include a safety margin\r\n    % to avoid failing correct solutions on account of stochastic fluctuations.  \r\n    % A safety margin of 1 percentage point is almost always enough.  \r\n    % (1.5 percentage points would allow even more natural fluctuation, but would also risk passing incorrect 'solutions'.)  \r\n    threshold = expectedSuccessRate - 0.010;\r\nend","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":"2021-07-19T10:43:08.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2021-07-18T11:23:40.000Z","updated_at":"2021-07-25T08:12:28.000Z","published_at":"2021-07-18T15:01:47.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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eHave you tried the original \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://au.mathworks.com/matlabcentral/cody/problems/44630-guess-the-number-i-m-thinking-of\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Guess the number I'm thinking of\\\" (Problem 44630)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e?  This problem is just like that, except that the range of possible numbers can change, and pre-calculated answers are explicitly disallowed.  Computing all possible permutations on the fly is not disallowed per se, but it is discouraged due to the high computational load involved.  \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\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\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (inclusive).  \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is an integer between 4 and 1000 (inclusive) that will be specified in each test as \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\u003eupperLimit\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.  I don't provide any other clues about the number that is to be guessed.\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 substantially better than 33.3%\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.  The success rate is defined as follows.  \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\u003eThe precise value of the expected success rate (when guessing with the optimal strategy) depends upon the value of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:  when \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e = 4 you should be able to achieve a success rate of 17/48 ≈ 35.4% on average, increasing monotonically to above 50% for \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ≥ 24, eventually approaching an asymptote of 19/36 ≈ 52.8%.  (See the Test Suite for details of the thresholds applied.) \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/44630\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44630. Guess the number I'm thinking of (Part 1)\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":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":46585,"title":"Beat the RNG - Passwords","description":null,"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: 301.52px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.989px 150.753px; transform-origin: 406.996px 150.76px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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=\"\"\u003eThe Test Suite randomly generates a list of 1024 passwords.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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=\"\"\u003eGiven the source code and one generated password, return the complete list of all passwords.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 100px; border-bottom-left-radius: 4px; border-bottom-right-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: 403.991px 50px; transform-origin: 403.999px 50px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e% Password generator source code\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003erng(\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'shuffle'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ealphanum = [\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'a'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e:\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'z' 'A'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e:\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'Z' '0'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e:\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'9'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003epasswords = string(alphanum(randi([1 length(alphanum)], [1024 6])));\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003erng(\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'shuffle'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.9091px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eContinuation of \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/46568-beat-the-rng-easy\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 46568\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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: 20.9091px; 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: 383.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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=\"\"\u003eRead the manual. \u0026gt;:)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40px; border-bottom-left-radius: 4px; border-bottom-right-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: 403.991px 20px; transform-origin: 403.999px 20px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ehelp \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003erandi\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 0.994318px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.994318px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.994318px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.994318px; 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: 403.991px 10px; transform-origin: 403.999px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ehelp \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003erng\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":" function y = get_all_passwords(x)\r\n    alphanum = ['a':'z' 'A':'Z' '0':'9'];\r\n    y = string(alphanum(randi([1 length(alphanum)], [1024 6])));\r\n end","test_suite":"%%\r\n\r\n% Randomly generate 1024 alphanumeric strings\r\nrng('shuffle')\r\nalphanum = ['a':'z' 'A':'Z' '0':'9'];\r\npasswords = string(alphanum(randi([1 length(alphanum)], [1024 6])));\r\nrng('shuffle')\r\n\r\n%\r\nx = passwords(8);\r\ny = get_all_passwords(x);\r\n\r\nassert(isequal(passwords,y))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":543257,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":6,"test_suite_updated_at":"2020-09-18T03:34:59.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-09-15T00:14:36.000Z","updated_at":"2020-09-18T03:45:47.000Z","published_at":"2020-09-15T00:45:31.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\u003eThe Test Suite randomly generates a list of 1024 passwords.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven the source code and one generated password, return the complete list of all passwords.\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[% Password generator source code\\nrng('shuffle')\\nalphanum = ['a':'z' 'A':'Z' '0':'9'];\\npasswords = string(alphanum(randi([1 length(alphanum)], [1024 6])));\\nrng('shuffle')]]\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\u003eContinuation of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/46568-beat-the-rng-easy\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 46568\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\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\u003eRead the manual. \u0026gt;:)\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[help randi\\nhelp rng]]\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":44694,"title":"Monte Carlo integration:  area of a polygon","description":"The area of a polygon (or any plane shape) can be evaluated by \u003chttps://www.mathworks.com/matlabcentral/cody/problems/179 Monte Carlo integration\u003e.  The process involves 'random' sampling of (x,y) points in the xy plane, and testing whether they fall inside or outside the shape.  That is illustrated schematically below for a circle.  \r\n\r\n\u003c\u003chttps://upload.wikimedia.org/wikipedia/commons/thumb/2/20/MonteCarloIntegrationCircle.svg/247px-MonteCarloIntegrationCircle.svg.png\u003e\u003e\r\n\r\n^\r\n\r\n*Steps:*\r\n\r\n# Define a 2D region within which to sample points.  In the present problem you must choose the rectangular box (aligned to the axes) that bounds the specified polygon.  \r\n# By a 'random' process generate coordinates of a point within the bounding box.  In the present problem a basic scheme using the uniform pseudorandom distribution available in MATLAB must be employed.  _Other schemes in use include quasi-random sampling (for greater uniformity of coverage) and stratified sampling (with more attention near the edges of the polygon)._\r\n# Determine \u003chttps://www.mathworks.com/matlabcentral/cody/problems/198 whether the sampled point is inside or outside the polygon\u003e.  _Due to working in double precision, it is extremely unlikely to sample a point falling exactly on the edge of the polygon, and consequently if it does happen it doesn't really matter whether it's counted as inside or outside or null._  \r\n# Repeat steps 2–3 |N| times.  \r\n# Based upon the proportion of sampled points falling within the polygon, report the approximate area of the polygon.  \r\n\r\nInputs to your function will be |N|, the number of points to sample, and |polygonX| \u0026 |polygonY|, which together constitute \u003chttps://www.mathworks.com/matlabcentral/cody/problems/194 an ordered list of polygon vertices\u003e.  |N| will always be a positive integer.  |polygonX| \u0026 |polygonY| will always describe a single, continuous outline;  however, the polygon may be self-intersecting.  \r\n\r\nFor polygons that are self-intersecting, you must find the area of the enclosed point set. In the case of the cross-quadrilateral, it is treated as two simple triangles (cf. three triangles in the first figure below), and the clockwise/counterclockwise ordering of points is irrelevant.  A self-intersecting pentagram (left \u0026 middle of the second figure below) will therefore have the same area as a concave decagon (right).\r\n\r\n\u003c\u003chttps://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Complex_polygon.svg/288px-Complex_polygon.svg.png\u003e\u003e\r\n\r\n\u003c\u003chttps://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Pentagram_interpretations.svg/320px-Pentagram_interpretations.svg.png\u003e\u003e\r\n\r\n^\r\n\r\nEXAMPLE\r\n\r\n % Input\r\n N = 1000\r\n polygonX = [1 0 -1  0]\r\n polygonY = [0 1  0 -1]\r\n % Output\r\n A = 2.036\r\n\r\nExplanation:  the above polygon is a square of side-length √2 centred on the origin, but rotated by 45°.  The exact area is hence 2.  As the value of |N| is moderate, the estimate by Monte Carlo integration is moderately accurate (an error of 0.036 in this example, corresponding to 509 of the 1000 sampled points falling within the polygon).  \r\nOf course, if the code were run again then a slightly different value of |A| would probably be returned, such as |A|=1.992 (corresponding to 498 of the 1000 sampled points falling within the polygon), due to the random qualities of the technique.  ","description_html":"\u003cp\u003eThe area of a polygon (or any plane shape) can be evaluated by \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/179\"\u003eMonte Carlo integration\u003c/a\u003e.  The process involves 'random' sampling of (x,y) points in the xy plane, and testing whether they fall inside or outside the shape.  That is illustrated schematically below for a circle.\u003c/p\u003e\u003cimg src = \"https://upload.wikimedia.org/wikipedia/commons/thumb/2/20/MonteCarloIntegrationCircle.svg/247px-MonteCarloIntegrationCircle.svg.png\"\u003e\u003cp\u003e^\u003c/p\u003e\u003cp\u003e\u003cb\u003eSteps:\u003c/b\u003e\u003c/p\u003e\u003col\u003e\u003cli\u003eDefine a 2D region within which to sample points.  In the present problem you must choose the rectangular box (aligned to the axes) that bounds the specified polygon.\u003c/li\u003e\u003cli\u003eBy a 'random' process generate coordinates of a point within the bounding box.  In the present problem a basic scheme using the uniform pseudorandom distribution available in MATLAB must be employed.  \u003ci\u003eOther schemes in use include quasi-random sampling (for greater uniformity of coverage) and stratified sampling (with more attention near the edges of the polygon).\u003c/i\u003e\u003c/li\u003e\u003cli\u003eDetermine \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/198\"\u003ewhether the sampled point is inside or outside the polygon\u003c/a\u003e.  \u003ci\u003eDue to working in double precision, it is extremely unlikely to sample a point falling exactly on the edge of the polygon, and consequently if it does happen it doesn't really matter whether it's counted as inside or outside or null.\u003c/i\u003e\u003c/li\u003e\u003cli\u003eRepeat steps 2–3 \u003ctt\u003eN\u003c/tt\u003e times.\u003c/li\u003e\u003cli\u003eBased upon the proportion of sampled points falling within the polygon, report the approximate area of the polygon.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eInputs to your function will be \u003ctt\u003eN\u003c/tt\u003e, the number of points to sample, and \u003ctt\u003epolygonX\u003c/tt\u003e \u0026 \u003ctt\u003epolygonY\u003c/tt\u003e, which together constitute \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/194\"\u003ean ordered list of polygon vertices\u003c/a\u003e.  \u003ctt\u003eN\u003c/tt\u003e will always be a positive integer.  \u003ctt\u003epolygonX\u003c/tt\u003e \u0026 \u003ctt\u003epolygonY\u003c/tt\u003e will always describe a single, continuous outline;  however, the polygon may be self-intersecting.\u003c/p\u003e\u003cp\u003eFor polygons that are self-intersecting, you must find the area of the enclosed point set. In the case of the cross-quadrilateral, it is treated as two simple triangles (cf. three triangles in the first figure below), and the clockwise/counterclockwise ordering of points is irrelevant.  A self-intersecting pentagram (left \u0026 middle of the second figure below) will therefore have the same area as a concave decagon (right).\u003c/p\u003e\u003cimg src = \"https://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Complex_polygon.svg/288px-Complex_polygon.svg.png\"\u003e\u003cimg src = \"https://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Pentagram_interpretations.svg/320px-Pentagram_interpretations.svg.png\"\u003e\u003cp\u003e^\u003c/p\u003e\u003cp\u003eEXAMPLE\u003c/p\u003e\u003cpre\u003e % Input\r\n N = 1000\r\n polygonX = [1 0 -1  0]\r\n polygonY = [0 1  0 -1]\r\n % Output\r\n A = 2.036\u003c/pre\u003e\u003cp\u003eExplanation:  the above polygon is a square of side-length √2 centred on the origin, but rotated by 45°.  The exact area is hence 2.  As the value of \u003ctt\u003eN\u003c/tt\u003e is moderate, the estimate by Monte Carlo integration is moderately accurate (an error of 0.036 in this example, corresponding to 509 of the 1000 sampled points falling within the polygon).  \r\nOf course, if the code were run again then a slightly different value of \u003ctt\u003eA\u003c/tt\u003e would probably be returned, such as \u003ctt\u003eA\u003c/tt\u003e=1.992 (corresponding to 498 of the 1000 sampled points falling within the polygon), due to the random qualities of the technique.\u003c/p\u003e","function_template":"function A = monteCarloArea(N, polygonX, polygonY)\r\n    % Fun starts here\r\nend\r\n\r\n\r\n% Note:  the Test Suite has been designed to account for variability in outputs. \r\n%        Nevertheless, it is possible that on rare occasions a valid submission \r\n%        might fail the Test Suite in one instance.  \r\n%        If your submission has narrowly failed only one of the test cases, \r\n%        then please try resubmitting it, in case it was just due to 'bad luck'.  ","test_suite":"%% No silly stuff\r\n% This Test Suite can be updated if inappropriate 'hacks' are discovered \r\n% in any submitted solutions, so your submission's status may therefore change over time.  \r\n\r\n% BEGIN EDIT (2019-06-29).  \r\n% Ensure only builtin functions will be called.  \r\n! rm -v fileread.m\r\n! rm -v assert.m\r\n% END OF EDIT (2019-06-29).  \r\n\r\nassessFunctionAbsence({'regexp', 'regexpi', 'str2num'}, 'FileName','monteCarloArea.m')\r\n\r\nRE = regexp(fileread('monteCarloArea.m'), '\\w+', 'match');\r\ntabooWords = {'ans', 'area', 'polyarea'};\r\ntestResult = cellfun( @(z) ismember(z, tabooWords), RE );\r\nmsg = ['Please do not do that in your code!' char([10 13]) ...\r\n    'Found: ' strjoin(RE(testResult)) '.' char([10 13]) ...\r\n    'Banned word.' char([10 13])];\r\nassert(~any( testResult ), msg)\r\n\r\n\r\n%% Unit square, in first quadrant\r\nNvec = 1 : 7 : 200;\r\npolygonX = [0 1 1 0];\r\npolygonY = [0 0 1 1];\r\nareaVec = arrayfun(@(N) monteCarloArea(N, polygonX, polygonY), Nvec);\r\narea_correct = 1;\r\nassert( all(areaVec==area_correct) )\r\n\r\n%% 3×3 square, offset from origin, in all four quadrants\r\nNvec = 1 : 19 : 500;\r\npolygonX = [ 1 1 -2 -2];\r\npolygonY = [-1 2  2 -1];\r\nareaVec = arrayfun(@(N) monteCarloArea(N, polygonX, polygonY), Nvec);\r\narea_correct = 9;\r\nassert( all(areaVec==area_correct) )\r\n\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  small N (1)\r\nN = 1;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_valid = [0 4];\r\nareaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:1000);\r\nassert( all( ismember(areaVec, area_valid) ) , 'Invalid areas reported' )\r\nassert( all( ismember(area_valid, areaVec) ) , 'Not all valid areas accessible in your sampling scheme')\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  small N (2)\r\nN = 2;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_valid = [0 2 4];\r\nareaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:1000);\r\nassert( all( ismember(areaVec, area_valid) ) , 'Invalid areas reported' )\r\nassert( all( ismember(area_valid, areaVec) ) , 'Not all valid areas accessible in your sampling scheme')\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  small N (3)\r\nN = 4;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_valid = [0:4];\r\nareaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:1000);\r\nassert( all( ismember(areaVec, area_valid) ) , 'Invalid areas reported' )\r\nassert( all( ismember(area_valid, areaVec) ) , 'Not all valid areas accessible in your sampling scheme')\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  moderate N (1)\r\nN = 100;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_exact = 2;\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 4 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    assert( worstErrorFraction \u003e 0.05 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.40 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  moderate N (2)\r\nN = 1000;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_exact = 2;\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 5 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    assert( worstErrorFraction \u003e 0.02 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.15 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  moderate N (3)\r\nN = 10000;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_exact = 2;\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 6 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    assert( worstErrorFraction \u003e 0.004 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.049 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n%% Diamond, centred on origin, in all four quadrants:  large N\r\nN = 100000;\r\npolygonX = [1 0 -1  0];\r\npolygonY = [0 1  0 -1];\r\narea_exact = 2;\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 7 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    assert( worstErrorFraction \u003e 0.0016 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.016 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n\r\n%% Cross-quadrilateral, centred on origin, in all four quadrants:  moderate N (1)\r\nN = 100;\r\npolygonX = [ 1 -1  1 -1];\r\npolygonY = [-1  1  1 -1];\r\narea_exact = 2;\r\n\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 4 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    assert( worstErrorFraction \u003e 0.05 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.40 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n%% Cross-quadrilateral, centred on origin, in all four quadrants:  moderate N (2)\r\nN = 10000;\r\nfor j = 1 : 10,\r\n    rVec = 100 * rand(2);\r\n    polygonX = [ 1 -1  1 -1] * rVec(1,1) + rVec(1,2);\r\n    polygonY = [-1  1  1 -1] * rVec(2,1) + rVec(2,2);\r\n    area_exact = 2 * rVec(1,1) * rVec(2,1);\r\n\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 6 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    assert( worstErrorFraction \u003e 0.004 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.049 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n\r\n%% 12-cornered polygon of unit 'circumradius' centred on origin:  moderate N\r\nN = 1000;\r\npoints = 12;\r\ncentre = [0 0];\r\ncircumradius = 1;\r\npolygonX = circumradius * cos(2 * pi * [0:points-1]/points) + centre(1);\r\npolygonY = circumradius * sin(2 * pi * [0:points-1]/points) + centre(2);\r\narea_exact = polyarea(polygonX, polygonY);\r\n\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 5 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    %assert( worstErrorFraction \u003e 0.02 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003e 0.01 , 'Implausibly accurate' )\r\n    %assert( worstErrorFraction \u003c 0.15 , 'Implausibly inaccurate' )\r\n    assert( worstErrorFraction \u003c 0.08 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n%% P-cornered polygon of arbitrary 'circumradius', with centre offset from  the origin:  moderate N\r\nN = 1000;\r\nfor j = 1 : 10,\r\n    points = randi([5 100]);\r\n    centre = randi([2 100], [1 2]);\r\n    circumradius = randi([2 100]);\r\n    r = rand();\r\n    polygonX = circumradius * cos(2 * pi * (r+[0:points-1])/points) + centre(1);\r\n    polygonY = circumradius * sin(2 * pi * (r+[0:points-1])/points) + centre(2);\r\n    area_exact = polyarea(polygonX, polygonY);\r\n\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 5 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    %assert( worstErrorFraction \u003e 0.02 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003e 0.01 , 'Implausibly accurate' )\r\n    %assert( worstErrorFraction \u003c 0.15 , 'Implausibly inaccurate' )\r\n    assert( worstErrorFraction \u003c 0.08 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n\r\n%% 5-pointed star of unit 'circumradius' centred on origin:  moderate N\r\nN = 1000;\r\npoints = 5;\r\ncentre = [0 0];\r\ncircumradius = 1;\r\nx = circumradius * cos(2 * pi * [0:points-1]/points) + centre(1);\r\ny = circumradius * sin(2 * pi * [0:points-1]/points) + centre(2);\r\npolygonX = x([1:2:end, 2:2:end]);\r\npolygonY = y([1:2:end, 2:2:end]);\r\narea_exact = sqrt(650 - 290* sqrt(5))/4  * ( circumradius / sqrt((5 - sqrt(5))/10) )^2;\r\n% http://mathworld.wolfram.com/Pentagram.html\r\n\r\nfor j = 1 : 3,\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 5 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    %assert( worstErrorFraction \u003e 0.02 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003e 0.03 , 'Implausibly accurate' )\r\n    %assert( worstErrorFraction \u003c 0.15 , 'Implausibly inaccurate' )\r\n    assert( worstErrorFraction \u003c 0.25 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n%% 5-pointed star of arbitrary 'circumradius', with centre offset from  the origin:  moderate N\r\nN = 1000;\r\npoints = 5;\r\nfor j = 1 : 10,\r\n    centre = randi([2 100], [1 2]);\r\n    circumradius = randi([2 100]);\r\n    r = rand();\r\n    x = circumradius * cos(2 * pi * (r+[0:points-1])/points) + centre(1);\r\n    y = circumradius * sin(2 * pi * (r+[0:points-1])/points) + centre(2);\r\n    polygonX = x([1:2:end, 2:2:end]);\r\n    polygonY = y([1:2:end, 2:2:end]);\r\n    area_exact = sqrt(650 - 290* sqrt(5))/4  * ( circumradius / sqrt((5 - sqrt(5))/10) )^2;\r\n    % http://mathworld.wolfram.com/Pentagram.html\r\n\r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 5 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    %assert( worstErrorFraction \u003e 0.02 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003e 0.03 , 'Implausibly accurate' )\r\n    %assert( worstErrorFraction \u003c 0.15 , 'Implausibly inaccurate' )\r\n    assert( worstErrorFraction \u003c 0.25 , 'Implausibly inaccurate' )\r\nend;\r\n\r\n\r\n%% P-pointed star of arbitrary 'circumradius', with centre offset from  the origin:  moderate N\r\nN = 1000;\r\nfor j = 1 : 20,\r\n    points = 3 * randi([3 10]) - 1;\r\n    centre = randi([2 100], [1 2]);\r\n    circumradius = randi([2 30]);\r\n    r = rand();\r\n    x = circumradius * cos(2 * pi * (r+[0:points-1])/points) + centre(1);\r\n    y = circumradius * sin(2 * pi * (r+[0:points-1])/points) + centre(2);\r\n    polygonX = x([1:3:end, 2:3:end, 3:3:end]);\r\n    polygonY = y([1:3:end, 2:3:end, 3:3:end]);\r\n    \r\n    area_polyarea = polyarea(polygonX, polygonY);                % Incorrect value\r\n    warning('off', 'MATLAB:polyshape:repairedBySimplify')\r\n    area_polyshapeArea1 = area( polyshape(polygonX, polygonY) ); % Incorrect value\r\n    area_polyshapeArea2 = area( polyshape(polygonX, polygonY, 'Simplify',false) );  % Incorrect value\r\n    \r\n    % REFERENCE:  http://web.sonoma.edu/users/w/wilsonst/papers/stars/a-p/default.html\r\n    % Here: a {points/3} star\r\n    k = 3;\r\n    sideLength = circumradius * sind(180/points) * secd(180*(k-1)/points);\r\n    apothem = circumradius * cosd(180*k/points);\r\n    area_exact = points * sideLength * apothem;                  % Correct value\r\n    fprintf('Area estimates from different methods:  \\r\\npolyarea = %4.1f;  polyshape.area = %4.1f or %4.1f;  geometrical analysis = %4.1f\\r\\n', ...\r\n        area_polyarea, area_polyshapeArea1, area_polyshapeArea2, area_exact);\r\n    \r\n    areaVec = arrayfun(@(dummy) monteCarloArea(N, polygonX, polygonY), 1:10);\r\n    assert( length(unique(areaVec)) \u003e 5 , 'Cannot have so many identical outputs')\r\n    worstErrorFraction = max( abs(area_exact - areaVec) ) / area_exact\r\n    %assert( worstErrorFraction \u003e 0.02 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003e 0.01 , 'Implausibly accurate' )\r\n    assert( worstErrorFraction \u003c 0.15 , 'Implausibly inaccurate' )\r\nend;\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":7,"test_suite_updated_at":"2019-06-29T13:06:05.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2018-07-02T02:19:05.000Z","updated_at":"2025-09-14T14:22:43.000Z","published_at":"2018-07-02T08:55:01.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/media/image1.png\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/media/image2.png\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"targetMode\":\"\",\"relationshipId\":\"rId3\",\"target\":\"/media/image3.png\"}],\"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\u003eThe area of a polygon (or any plane shape) can be evaluated 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=\\\"https://www.mathworks.com/matlabcentral/cody/problems/179\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMonte Carlo integration\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. The process involves 'random' sampling of (x,y) points in the xy plane, and testing whether they fall inside or outside the shape. That is illustrated schematically below for a circle.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e^\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSteps:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDefine a 2D region within which to sample points. In the present problem you must choose the rectangular box (aligned to the axes) that bounds the specified polygon.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBy a 'random' process generate coordinates of a point within the bounding box. In the present problem a basic scheme using the uniform pseudorandom distribution available in MATLAB must be employed. \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\u003eOther schemes in use include quasi-random sampling (for greater uniformity of coverage) and stratified sampling (with more attention near the edges of the polygon).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDetermine\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/198\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ewhether the sampled point is inside or outside the polygon\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. \u003c/w:t\u003e\u003c/w:r\u003e\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\u003eDue to working in double precision, it is extremely unlikely to sample a point falling exactly on the edge of the polygon, and consequently if it does happen it doesn't really matter whether it's counted as inside or outside or null.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRepeat steps 2–3\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e times.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBased upon the proportion of sampled points falling within the polygon, report the approximate area of the polygon.\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\u003eInputs to your function will be\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, the number of points to sample, 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:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003epolygonX\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u0026amp;\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\u003epolygonY\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, which together constitute\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/194\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ean ordered list of polygon vertices\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. \u003c/w:t\u003e\u003c/w:r\u003e\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e will always be a positive integer. \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\u003epolygonX\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u0026amp;\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\u003epolygonY\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e will always describe a single, continuous outline; however, the polygon may be self-intersecting.\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 polygons that are self-intersecting, you must find the area of the enclosed point set. In the case of the cross-quadrilateral, it is treated as two simple triangles (cf. three triangles in the first figure below), and the clockwise/counterclockwise ordering of points is irrelevant. A self-intersecting pentagram (left \u0026amp; middle of the second figure below) will therefore have the same area as a concave decagon (right).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId2\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId3\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e^\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ % Input\\n N = 1000\\n polygonX = [1 0 -1  0]\\n polygonY = [0 1  0 -1]\\n % Output\\n A = 2.036]]\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\u003eExplanation: the above polygon is a square of side-length √2 centred on the origin, but rotated by 45°. The exact area is hence 2. As the value of\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is moderate, the estimate by Monte Carlo integration is moderately accurate (an error of 0.036 in this example, corresponding to 509 of the 1000 sampled points falling within the polygon). Of course, if the code were run again then a slightly different value of\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\u003eA\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e would probably be returned, such as\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\u003eA\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e=1.992 (corresponding to 498 of the 1000 sampled points falling within the polygon), due to the random qualities of the technique.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"},{\"partUri\":\"/media/image1.png\",\"contentType\":\"image/png\",\"content\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPcAAADwCAYAAADcifLrAAAjU0lEQVR42u1dB5gV1dn+7tBdK01AsFIEESKIERULttgNiAZ77GBAorFrRESj2DU2NJYoEDF2fzuCigYj2FEjIghSpHdEYOf/3nvO6t3Zmd25e6edme99nvdhmb17p5zzzjnnO18hEggEAoFAIBAIBAKBQCAQCAQCgUAQPjozP2b+II9CIEgPTmLOYY4RcQsE6cJpzFbM00XcAkE6UZO4t2F2F8bOXsw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kMeaxRlQAAAABJRU5ErkJggg==\"},{\"partUri\":\"/media/image2.png\",\"contentType\":\"image/png\",\"content\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAADwCAYAAACgyrkbAAAXbElEQVR42u2dB7hU1fHAx4ogGgREUBFs2KKoaBKNBRVFYyxR/McSaxSNBVsM9kBiAf1bMPYWbLHFqEETW2zYe+9SooioCCigaIy5457jnbdv777dt7t3b/n9vm++T9nde8+dOWfeuWfOmREBAAAAAAAAAACAvNAxkAVRAwDETfdAPgzk5UB6oA4AiJNdAvnWyVjUAQBxMsI4IJUtUAkAxMXNRQ7orUAWQS0AEAevOMczyTih4agFABrNwoF85ZzOIYHc6f57biAroB4AaCRrmFnPZoGsFMgX7v/vQj0A0EhsBMyH4EeYf9sJFQFAo/DO5mPzbx0CecP9+3uBdEZNANAIbnKO5qGif9/SzILORE0A0AhedU7mwhKf3eg++zqQ/qgKAOqJjYAdWuLznoHMdJ8/Esh8qAwA6sXq5jVr84jvHGG+sx8qA4B6YSNgS0V8Z4FAnnPfmR7IkqgNAOrB76V1BKwU6wfyjfvuZagNAOqBX2R+uILvXuK++99ANkR1AFAr/gzYRRV8t2sg09z3NW/QQqgPANqLOhAfATuswt/sI+Ga0VGoEADay2pSff4fDcPf737zWSDLokYAaA9DjAPqWcXv1jAzp5tRIwC0h5MlDK1Xy2jjvLZFlQBQLTc4BzK+Hb/tFMhE9/t3pFBRAwCgYl52DuTidv5+RzMLGok6AaBStP7XPOc8htVwnb+7a+i1VkWtAFAJq0p9KmAsF8hsd517USsAVMLOxgH1qvFax5tr7YpqAaAtaomAFaMpPV5z15saSBfUCwDlqCUCVopNpHBGTK85BvUCQDlecs7ikjpe8xp3zf8Esi4qBoBS2AjY4XW8ruYT+tRd92kp5BECAGiBjYANqvO1DzbXPghVA0AxOxknsXSdrz1/II+7a+tsqAfqBgDLSVK/CFgpBkhhHUjvcRXqBgDL9RJWuWgU50uYPXFzVA4Anhedc7i0gfdYPJAp7j5v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QCtt3Gmc0JgG3ONcd+13UTcAFKMn0x80Tmhkna9/j7vuOFQNAKVYPJCnjBM6to7XnuKuOQo1A0AUXSSstKFyVB2uaSNge6FiACiHVtp4TcJKGwfUeD0bAVsP9QJAW2iljQkSVtrYrYZrHSBEwACgSrTSxmQJK21s387rnOOuMQGVAkA19JOWlTa2acc1fATsDtQJANWyViDTJay0sWmVv3/f/XY0qgSA9vBjaVlpY/0Kf9dFwgXovVEjALQXjWbNds5khlRW12tD44DWR4UAUAtbBvKlcygfBbJaG9/fX8JwfmfUBwC1smMgX0tllTbOdt+biNoAoF5oXXef5L5cpY273XfuRGUAUE/2da9WvtJGzxLfec99fgbqAoB6M0zCReYXpWWlDRsB2wdVAUAjOElKV9rYQIiAAUAMnC6tK20QAQOA2DhLWlbauMD99yRUAwCNpjjJvQ/V/xPVAEAcaGmfW40T+tbNjAAAYkGLHN5lHNB+qAQA4kQTj10VyAPSMjQPAAAAAAAAAAAAAAAA9eR/oeqV3auxALsAAAAASUVORK5CYII=\"},{\"partUri\":\"/media/image3.png\",\"contentType\":\"image/png\",\"content\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUAAAACWCAYAAACvgFEsAAA0/klEQVR42u1dB3wUxfffcne5Sy69kt5IJUB6CIQmvRNqaCJVQAQBRUEEAcVKVaQJigXsBQsIP3sXAbErCgoooNj/CneXm/+8u1nYLNfr5m6+n8/7QG53p7y38503u2/fMAwFBQUFBQUFBQUFBQUFBQUFBQUFRfPDbCx/YEFY4vxQ/14sB7Cw1BSy1Ucxlo+wvINlP5bO1EwUzQVfYnmdSCMhuvfJ32ewRGE55EcCPIzlOBbewfNPYTHIUM+utMvSNc7qwxd4ltwfuVjKsbQOEP1TBAH2if7/D7mRM8nfO2VAgCos6gC40T1FgM7qwxc46Mf7gxIghVvgbBCgcEwgwFuxHMHyE5be5Ng2LHpyfD45doocG06WRA8Qz2WkqC5bxwRMw/K7aHAtxfIf+XsxuV7cloXkuJGQ9zg7dVlr+yP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lpvMLAJf2ZtHfwrICDPGWaLmyhxjmQaKUEeQ3cLc/FClDcOPXEbaHT5EiLbjeMCNvId4L/B1tocxlFsoRzskQlXkdOZeRLLH2kJtB2s4EUT+yiHs+kdyI4vJHidoG591GyptkpR2bGO98cO+MjaJF/fvSho2E9peRY/Dv80QPoYw5w0cDOVZC7AbHs0W6E+psRx5rTCU25UXnl0j0y1hor9TuvR20j7icMol9GMm5c8k9ByuJPC/byx37StspvY8t2atAov9p5JjWgv6kj6LENpPe41NE5UjHWSFZAoNn+YqFaxkrHCEXnTfBdOItNFf0IF6LP9GW8e5nP3K2kacflgeCvXxpX1f078o14nGWRCZKhjyvbY46bwJlMyW/xcRDDAb9ydVGUk+hOUAZQG1yRf/OXiMdZ+DNrSIe65AA5xgKCgoKCgoKCgoKCgoKCgoKCgoKGeH/AS8924+Oc1GZAAAAAElFTkSuQmCC\"}]}"},{"id":44393,"title":"Testing for randomness:  uniform distribution of integers","description":"On Cody several problems have been set up asking players to generate one or more 'random' numbers.  Usually they are asking for numbers from a uniform distribution function (UDF).  However, Test Suites do not always test very carefully to see how 'random' the sequences generated by the submitted codes are.  Indeed, rigorous testing of randomness is a sophisticated field of endeavour.  (See e.g. \u003chttps://en.wikipedia.org/wiki/TestU01 TestU01\u003e and the \u003chttps://en.wikipedia.org/wiki/Diehard_tests Diehard tests\u003e.)  \r\n\r\nMATLAB provides access to several very good pseudo-random number generators.  Even these do not generate truly random number sequences — however, they are good enough for most purposes.  \r\n\r\nHere we will be considering only integer sequences.  Your task will be to distinguish those that are 'practically' random — in this case being uniformly distributed — from those that aren't.  \r\n\r\nYou must return:\r\n\r\n* the probability of the given sequence being generated (a scalar float);  and  \r\n* your assessment of whether the sequence could 'plausibly' have been produced by a true random number generator (a scalar Boolean).  \r\n\r\nInput sequences will be vectors of various lengths containing only the integers 1, 2, 3 and 4.  \r\n\r\nHere are a few cases to consider:\r\n\r\nEXAMPLE ONE — Random sequence (UDF)\r\n\r\n Input = [3 4 3 3 4 2 2 2 1 3 2 2 1 3 3 2 4 3 1 2 3 2 1 4 2 1 4 4 4 2 3 1 2 1 2 2 1]\r\n prob ~ 5.29E-23\r\n isRandom = true\r\n\r\nEXAMPLE TWO — Non-uniform distribution\r\n\r\n Input = [1 3 3 1 1 1 1 3 1 1 4 1 2 1 1 1 1 1 3 1 3]\r\n % Notice that there are far too many ones, and too few twos and fours.\r\n prob ~ 9.09E-13\r\n isRandom = false\r\n\r\nEXAMPLE THREE — \u003chttp://www.spirit-statement.org/sequence-generation/ Blocked randomisation\u003e (or 'permuted block randomisation') \r\n\r\n Input = [1 3 2 4, 1 4 2 3, 3 1 4 2, 2 1 3 4, 1 4 3 2, 3 2 4 1, 4 1 3]\r\n % Notice that each of the four digits appears in groups of four.  In such cases the identity of neighbouring digits is often biased too, although it isn't apparent in the short sequence above.  \r\n prob ~ 5.55E-17\r\n isRandom = false\r\n\r\nEXAMPLE FOUR — Repeated pattern\r\n\r\n Input = [1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2]\r\n % Notice the pattern of eight digits that is repeated.  Notice also that the identity of neighbouring digits is biased, as e.g. 4 is only ever followed by 2, and 3 is only ever followed by 1.  \r\n prob ~ 5.29E-23\r\n isRandom = false\r\n\r\nEXAMPLE FIVE — Partial repeated sequence, too few runs\r\n\r\n Input = [1 2 3 4 2 3 4 1 3 4 1 2 4 1 2 3 1 2 3 1 2 4 1 3 4 2 3 4 1 2 3 4]\r\n % Notice that the sequence \"1 2 3 4\" is repeated in part or in full.  Notice also that the neighbouring digits are biased — e.g. 2 most commonly follows 1, but 2 is never followed by 1 or 2.  And finally notice that there are no runs (repeated occurrences of the same numeral).  \r\n prob ~ 5.42E-20\r\n isRandom = false\r\n\r\nEXAMPLE SIX — Partially segregated sequence, runs too long\r\n\r\n Input = [1 1 4 1 1 1 1 1 1 3 3 3 3 1 3 3 3 3 4 4 4 4 2 4 4 4 4 2 2 2 2 2 2 3 2 2]\r\n % Notice that the sequence unfolds as mostly 1, then mostly 3, then mostly 4, and mostly 2 at the end.  Notice also that the neighbouring digits are biased — each number most commonly follows itself.  And finally notice that the runs are longer than we would expect from a truly random (UDF) sequence.  \r\n prob ~ 2.12E-22\r\n isRandom = false\r\n\r\nAs will be apparent, there are various tests that _could_ be applied:  inspecting occurrence of numerals, pairs of neighbouring numerals, runs of numerals (length of runs, number of runs), repeated sequences, etc.  Your job is just to return the correct outputs.  You are *not* necessarily required to implement every test.  \r\n\r\n|Note:  the sequences in the examples above were for illustrative purposes;  most sequences in the Test Suite are considerably longer.|\r\n\r\nSee also:\r\n\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44435 Problem 44435: \"Testing for randomness: uniform distribution of real numbers (distribution checking)\"\u003e (easier)","description_html":"\u003cp\u003eOn Cody several problems have been set up asking players to generate one or more 'random' numbers.  Usually they are asking for numbers from a uniform distribution function (UDF).  However, Test Suites do not always test very carefully to see how 'random' the sequences generated by the submitted codes are.  Indeed, rigorous testing of randomness is a sophisticated field of endeavour.  (See e.g. \u003ca href = \"https://en.wikipedia.org/wiki/TestU01\"\u003eTestU01\u003c/a\u003e and the \u003ca href = \"https://en.wikipedia.org/wiki/Diehard_tests\"\u003eDiehard tests\u003c/a\u003e.)\u003c/p\u003e\u003cp\u003eMATLAB provides access to several very good pseudo-random number generators.  Even these do not generate truly random number sequences — however, they are good enough for most purposes.\u003c/p\u003e\u003cp\u003eHere we will be considering only integer sequences.  Your task will be to distinguish those that are 'practically' random — in this case being uniformly distributed — from those that aren't.\u003c/p\u003e\u003cp\u003eYou must return:\u003c/p\u003e\u003cul\u003e\u003cli\u003ethe probability of the given sequence being generated (a scalar float);  and\u003c/li\u003e\u003cli\u003eyour assessment of whether the sequence could 'plausibly' have been produced by a true random number generator (a scalar Boolean).\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eInput sequences will be vectors of various lengths containing only the integers 1, 2, 3 and 4.\u003c/p\u003e\u003cp\u003eHere are a few cases to consider:\u003c/p\u003e\u003cp\u003eEXAMPLE ONE — Random sequence (UDF)\u003c/p\u003e\u003cpre\u003e Input = [3 4 3 3 4 2 2 2 1 3 2 2 1 3 3 2 4 3 1 2 3 2 1 4 2 1 4 4 4 2 3 1 2 1 2 2 1]\r\n prob ~ 5.29E-23\r\n isRandom = true\u003c/pre\u003e\u003cp\u003eEXAMPLE TWO — Non-uniform distribution\u003c/p\u003e\u003cpre\u003e Input = [1 3 3 1 1 1 1 3 1 1 4 1 2 1 1 1 1 1 3 1 3]\r\n % Notice that there are far too many ones, and too few twos and fours.\r\n prob ~ 9.09E-13\r\n isRandom = false\u003c/pre\u003e\u003cp\u003eEXAMPLE THREE — \u003ca href = \"http://www.spirit-statement.org/sequence-generation/\"\u003eBlocked randomisation\u003c/a\u003e (or 'permuted block randomisation')\u003c/p\u003e\u003cpre\u003e Input = [1 3 2 4, 1 4 2 3, 3 1 4 2, 2 1 3 4, 1 4 3 2, 3 2 4 1, 4 1 3]\r\n % Notice that each of the four digits appears in groups of four.  In such cases the identity of neighbouring digits is often biased too, although it isn't apparent in the short sequence above.  \r\n prob ~ 5.55E-17\r\n isRandom = false\u003c/pre\u003e\u003cp\u003eEXAMPLE FOUR — Repeated pattern\u003c/p\u003e\u003cpre\u003e Input = [1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2]\r\n % Notice the pattern of eight digits that is repeated.  Notice also that the identity of neighbouring digits is biased, as e.g. 4 is only ever followed by 2, and 3 is only ever followed by 1.  \r\n prob ~ 5.29E-23\r\n isRandom = false\u003c/pre\u003e\u003cp\u003eEXAMPLE FIVE — Partial repeated sequence, too few runs\u003c/p\u003e\u003cpre\u003e Input = [1 2 3 4 2 3 4 1 3 4 1 2 4 1 2 3 1 2 3 1 2 4 1 3 4 2 3 4 1 2 3 4]\r\n % Notice that the sequence \"1 2 3 4\" is repeated in part or in full.  Notice also that the neighbouring digits are biased — e.g. 2 most commonly follows 1, but 2 is never followed by 1 or 2.  And finally notice that there are no runs (repeated occurrences of the same numeral).  \r\n prob ~ 5.42E-20\r\n isRandom = false\u003c/pre\u003e\u003cp\u003eEXAMPLE SIX — Partially segregated sequence, runs too long\u003c/p\u003e\u003cpre\u003e Input = [1 1 4 1 1 1 1 1 1 3 3 3 3 1 3 3 3 3 4 4 4 4 2 4 4 4 4 2 2 2 2 2 2 3 2 2]\r\n % Notice that the sequence unfolds as mostly 1, then mostly 3, then mostly 4, and mostly 2 at the end.  Notice also that the neighbouring digits are biased — each number most commonly follows itself.  And finally notice that the runs are longer than we would expect from a truly random (UDF) sequence.  \r\n prob ~ 2.12E-22\r\n isRandom = false\u003c/pre\u003e\u003cp\u003eAs will be apparent, there are various tests that \u003ci\u003ecould\u003c/i\u003e be applied:  inspecting occurrence of numerals, pairs of neighbouring numerals, runs of numerals (length of runs, number of runs), repeated sequences, etc.  Your job is just to return the correct outputs.  You are \u003cb\u003enot\u003c/b\u003e necessarily required to implement every test.\u003c/p\u003e\u003cp\u003e\u003ctt\u003eNote:  the sequences in the examples above were for illustrative purposes;  most sequences in the Test Suite are considerably longer.\u003c/tt\u003e\u003c/p\u003e\u003cp\u003eSee also:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44435\"\u003eProblem 44435: \"Testing for randomness: uniform distribution of real numbers (distribution checking)\"\u003c/a\u003e (easier)\u003c/li\u003e\u003c/ul\u003e","function_template":"function [prob, isRandom] = testRandomness(x)\r\n    % Your code goes here!\r\nend","test_suite":"%%\r\n% It is possible that even a genuine random number generator could produce \r\n% a sequence that does not have the characteristics of a random number stream, \r\n% so a couple of incorrect assessments are allowed as 'leeway' in each test.  \r\n\r\n\r\n%% \r\n% Random, very short\r\nfaults = 0;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = randi(4, [1, randi(8)]);\r\n    [prob, isRandom] = testRandomness(x);\r\n%    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%% \r\n% Random, short\r\nfaults = 0;\r\nprob_C = 1.121038771459854E-44;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = randi(4, [1,73]);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%% \r\n% Random, medium\r\nfaults = 0;\r\nprob_C = 1.785917798878555E-102;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = randi(4, [1,169]);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%% \r\n% Random, long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = randi(4, [1,500]);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%% \r\n% Too many of some number, short\r\nfaults = 0;\r\nprob_C = 1.121038771459854E-44;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = randi(4, [1,73]);\r\n    x( randi(3, [1,73]) \u003c 3 ) = randi(4);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%% \r\n% Too many of some number, medium\r\nfaults = 0;\r\nprob_C = 1.785917798878555E-102;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = randi(4, [1,169]);\r\n    x( randi(3, [1,169]) == 1 ) = randi(4);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Too few of some number, long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = randi(4, [1,500]);\r\n    els = find(x == randi(4));\r\n    new = randi(4, [1,length(els)]);\r\n    x(els) = new;\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Repeated patterns, long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = repmat( randi(4, [1, randi([4, 12])]) , [1,150] );\r\n    x = x(1:500);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Blocked randomisation (i.e. permuted block randomisation), medium\r\nfaults = 0;\r\nprob_C = 1.785917798878555E-102;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = [];\r\n    for j = 1 : 50,  x = [x randperm(4)];  end;\r\n    x = x(1:169);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Blocked randomisation (i.e. permuted block randomisation), long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = [];\r\n    for j = 1 : 125,  x = [x randperm(4)];  end;\r\n    %x = x(1:500);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Partially repeated 4-digit sequence, long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    pattern = randperm(4);\r\n    x = [];\r\n    for j = 1 : 300,  \r\n        d = randi(6, [1,4]);\r\n        p = pattern;\r\n        p(d==1) = [];\r\n        x = [x p];  \r\n    end;\r\n    x = x(1:500);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Partially repeated 8-digit sequence, long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    pattern = [randperm(4) randperm(4)];\r\n    x = [];\r\n    for j = 1 : 150,  \r\n        d = randi(6, [1,8]);\r\n        p = pattern;\r\n        p(d==1) = [];\r\n        x = [x p];  \r\n    end;\r\n    x = x(1:500);\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Partially segregated sequence, long\r\nfaults = 0;\r\nprob_C = 9.332636185032189E-302;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    pattern = [randperm(4) randperm(4)];\r\n    x = [];\r\n    for j = 1 : 50,  \r\n        p = randi(12, [1,10]);\r\n        p(p\u003e4) = randi(4);\r\n        x = [x p];  \r\n    end;\r\n    [prob, isRandom] = testRandomness(x);\r\n    assert( abs(prob - prob_C) / prob_C \u003c 1E-5 , 'Wrong probability.')\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** Warning:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-10-30T13:25:51.000Z","updated_at":"2017-12-03T13:23:19.000Z","published_at":"2017-11-01T13:29: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=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOn Cody several problems have been set up asking players to generate one or more 'random' numbers. Usually they are asking for numbers from a uniform distribution function (UDF). However, Test Suites do not always test very carefully to see how 'random' the sequences generated by the submitted codes are. Indeed, rigorous testing of randomness is a sophisticated field of endeavour. (See e.g.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/TestU01\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eTestU01\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Diehard_tests\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDiehard tests\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMATLAB provides access to several very good pseudo-random number generators. Even these do not generate truly random number sequences — however, they are good enough for most 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\u003eHere we will be considering only integer sequences. Your task will be to distinguish those that are 'practically' random — in this case being uniformly distributed — from those that aren't.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou must return:\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\u003ethe probability of the given sequence being generated (a scalar float); and\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\u003eyour assessment of whether the sequence could 'plausibly' have been produced by a true random number generator (a scalar Boolean).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInput sequences will be vectors of various lengths containing only the integers 1, 2, 3 and 4.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHere are a few cases to consider:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE ONE — Random sequence (UDF)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input = [3 4 3 3 4 2 2 2 1 3 2 2 1 3 3 2 4 3 1 2 3 2 1 4 2 1 4 4 4 2 3 1 2 1 2 2 1]\\n prob ~ 5.29E-23\\n isRandom = true]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE TWO — Non-uniform distribution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input = [1 3 3 1 1 1 1 3 1 1 4 1 2 1 1 1 1 1 3 1 3]\\n % Notice that there are far too many ones, and too few twos and fours.\\n prob ~ 9.09E-13\\n isRandom = false]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE THREE —\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.spirit-statement.org/sequence-generation/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eBlocked randomisation\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (or 'permuted block randomisation')\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input = [1 3 2 4, 1 4 2 3, 3 1 4 2, 2 1 3 4, 1 4 3 2, 3 2 4 1, 4 1 3]\\n % Notice that each of the four digits appears in groups of four.  In such cases the identity of neighbouring digits is often biased too, although it isn't apparent in the short sequence above.  \\n prob ~ 5.55E-17\\n isRandom = false]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE FOUR — Repeated pattern\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input = [1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2 4 2 3, 1 3 1 4 2]\\n % Notice the pattern of eight digits that is repeated.  Notice also that the identity of neighbouring digits is biased, as e.g. 4 is only ever followed by 2, and 3 is only ever followed by 1.  \\n prob ~ 5.29E-23\\n isRandom = false]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE FIVE — Partial repeated sequence, too few runs\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input = [1 2 3 4 2 3 4 1 3 4 1 2 4 1 2 3 1 2 3 1 2 4 1 3 4 2 3 4 1 2 3 4]\\n % Notice that the sequence \\\"1 2 3 4\\\" is repeated in part or in full.  Notice also that the neighbouring digits are biased — e.g. 2 most commonly follows 1, but 2 is never followed by 1 or 2.  And finally notice that there are no runs (repeated occurrences of the same numeral).  \\n prob ~ 5.42E-20\\n isRandom = false]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE SIX — Partially segregated sequence, runs too long\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input = [1 1 4 1 1 1 1 1 1 3 3 3 3 1 3 3 3 3 4 4 4 4 2 4 4 4 4 2 2 2 2 2 2 3 2 2]\\n % Notice that the sequence unfolds as mostly 1, then mostly 3, then mostly 4, and mostly 2 at the end.  Notice also that the neighbouring digits are biased — each number most commonly follows itself.  And finally notice that the runs are longer than we would expect from a truly random (UDF) sequence.  \\n prob ~ 2.12E-22\\n isRandom = false]]\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\u003eAs will be apparent, there are various tests that\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecould\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e be applied: inspecting occurrence of numerals, pairs of neighbouring numerals, runs of numerals (length of runs, number of runs), repeated sequences, etc. Your job is just to return the correct outputs. You are\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\u003enot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e necessarily required to implement every test.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote: the sequences in the examples above were for illustrative purposes; most sequences in the Test Suite are considerably longer.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee also:\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=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44435\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44435: \\\"Testing for randomness: uniform distribution of real numbers (distribution checking)\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (easier)\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":797,"title":"Genome Sequence 003R: Sequence DNA of random positioned and flipped segments","description":"This is Challenge 003R in the series on Genome DNA Sequencing. Challenge 3R includes flipped segments. DNA Sequencing is naively simplified into Cody Challenges. Genome sizes is another interesting wiki page.\r\nDNA is represented by symbols ACGT, which for Matlab will be encoded as 0123. The basic goal is to reconstruct the original serial string of ACGT given multiple short segments.\r\nExample: Genome = ACGTCGGCCATGGACATTACG\r\nGiven three overlapping pieces, ACGTCGGCCA, GCCATGGACATC, and GACATTACG these can be readily seen to overlap and create the original if the middle is recognized as being reversed with asymetric overlaps to its adjacent segments.\r\nACGTCGGCCATGGACATTACG\r\nACGTCGGCCAsssssssssss\r\nssssGCCATGGACATCsssss Middle Rev\r\nssssCTACAGGTACCGsssss Middle flipped\r\nssssssssssssGACATTACG\r\nGenome_003R Challenge is to reconstruct a genome under near ideal error free segment creation conditions. Segments may be reversed. The segments start at random locations.\r\nSegments may be reversed (Change from 003)\r\nSegments start at random positions\r\nGenome length is unconstrained\r\nLength of each segment - 48\r\nAll segments may overlap by 16 to 47 characters\r\nNo errors in the segments\r\nGenome is random (No duplicate starts or ends for 16 symbols of segments)\r\nSegment order is scrambled\r\nInput: segs, Array of M rows of 48 value segments. Values are [0, 1, 2, 3].\r\nOutput: Gout, Genome vector of values [0,1,2,3]\r\nExample: [0 1 2 3 2;1 1 2 2 3 2 ; 2 2 1 1 2] creates [0 1 2 3 2 2 1 1 2] W=5, Overlap=varies, Reverses may occur\r\nFuture: Flipped segments(002), Random Position of Segment start locations(003),Random Segment Positions with Flips (003R), Parrot Sequence with Gen3 Long Segments, Extra Segments, Phage Phi X174, Parallel Processing Simulation(Shot Gun Approach), Haemophilus Influenza, Sequence with Segment Errors, and Chromosome 20 with its 59M length using 100K 4K-segments","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 726.633px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 363.317px; transform-origin: 407px 363.317px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 341px 8px; transform-origin: 341px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis is Challenge 003R in the series on Genome DNA Sequencing. Challenge 3R includes flipped segments.\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eDNA Sequencing\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 133.5px 8px; transform-origin: 133.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is naively simplified into Cody Challenges.\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eGenome sizes\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 101.5px 8px; transform-origin: 101.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is another interesting wiki page.\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: 369px 8px; transform-origin: 369px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eDNA is represented by symbols ACGT, which for Matlab will be encoded as 0123. The basic goal is to reconstruct the original serial string of ACGT given multiple short segments.\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: 31.5px 8px; transform-origin: 31.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eExample:\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: 139px 8px; transform-origin: 139px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e Genome = ACGTCGGCCATGGACATTACG\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; 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 31.5px; text-align: left; transform-origin: 384px 31.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: 368.5px 8px; transform-origin: 368.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven three overlapping pieces, ACGTCGGCCA, GCCATGGACATC, and GACATTACG these can be readily seen to overlap and create the original if the middle is recognized as being reversed with asymetric overlaps to its adjacent segments.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 102.167px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 51.0833px; transform-origin: 404px 51.0833px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 84px 8.5px; transform-origin: 84px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eACGTCGGCCATGGACATTACG\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 84px 8.5px; transform-origin: 84px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eACGTCGGCCAsssssssssss\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 128px 8.5px; transform-origin: 128px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 88px 8.5px; transform-origin: 88px 8.5px; \"\u003essssGCCATGGACATCsssss \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 40px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 40px 8.5px; \"\u003eMiddle Rev\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 144px 8.5px; transform-origin: 144px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 88px 8.5px; transform-origin: 88px 8.5px; \"\u003essssCTACAGGTACCGsssss \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 56px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 56px 8.5px; \"\u003eMiddle flipped\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 84px 8.5px; transform-origin: 84px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003essssssssssssGACATTACG\u003c/span\u003e\u003c/span\u003e\u003c/div\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: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 382px 8px; transform-origin: 382px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGenome_003R Challenge is to reconstruct a genome under near ideal error free segment creation conditions. Segments may be reversed. The segments start at random locations.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003col style=\"block-size: 163.467px; counter-reset: list-item 0; 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 81.7333px; transform-origin: 391px 81.7333px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 148.5px 8px; transform-origin: 148.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSegments may be reversed (Change from 003)\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 111.5px 8px; transform-origin: 111.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSegments start at random positions\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 102.5px 8px; transform-origin: 102.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGenome length is unconstrained\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 91px 8px; transform-origin: 91px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eLength of each segment - 48\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 153.5px 8px; transform-origin: 153.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAll segments may overlap by 16 to 47 characters\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 81.5px 8px; transform-origin: 81.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNo errors in the segments\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 240px 8px; transform-origin: 240px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGenome is random (No duplicate starts or ends for 16 symbols of segments)\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 88.5px 8px; transform-origin: 88.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSegment order is scrambled\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ol\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: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eInput:\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: 213px 8px; transform-origin: 213px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e segs, Array of M rows of 48 value segments. Values are [0, 1, 2, 3].\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: 26px 8px; transform-origin: 26px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eOutput:\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: 128.5px 8px; transform-origin: 128.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e Gout, Genome vector of values [0,1,2,3]\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: 31.5px 8px; transform-origin: 31.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eExample:\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: 324.5px 8px; transform-origin: 324.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e [0 1 2 3 2;1 1 2 2 3 2 ; 2 2 1 1 2] creates [0 1 2 3 2 2 1 1 2] W=5, Overlap=varies, Reverses may occur\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 84px; 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 42px; text-align: left; transform-origin: 384px 42px; 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: 25.5px 8px; transform-origin: 25.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eFuture:\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: 355.5px 8px; transform-origin: 355.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e Flipped segments(002), Random Position of Segment start locations(003),Random Segment Positions with Flips (003R), Parrot Sequence with Gen3 Long Segments, Extra Segments, Phage Phi X174, Parallel Processing Simulation(Shot Gun Approach), Haemophilus Influenza, Sequence with Segment Errors, and Chromosome 20 with its 59M length using 100K 4K-segments\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function Gout = Genome_003R(segs)\r\n% segs is an array of N segments of length 48\r\n% Construct the unique Gout sequence\r\n% Guaranteed 16 long blocks are unique\r\n  Gout=[];\r\nend","test_suite":"%%\r\ntic\r\nL=563*17;\r\nwhile 1 % Loop until create a Gtruth with no repeated 16 segments\r\n Gtruth=randi(4,1,L,'uint8')-1;\r\n \r\n Gseg=zeros(L-15,16,'uint8');\r\n GtruthR=fliplr(Gtruth);\r\n for j=1:L-15\r\n  Gseg(j,:)=Gtruth(j:j+15);\r\n  Gseg(j+L-15,:)=GtruthR(j:j+15);\r\n end\r\n Gsegv=uint32(Gseg(:,1));\r\n for j=2:16\r\n  Gsegv=4*Gsegv+uint32(Gseg(:,j));\r\n end\r\n if size(unique(Gsegv),1)==(L-15)*2\r\n  break\r\n end\r\nend % while create valid Gtruth\r\n\r\nsegs=Gtruth(1:48); % First segment is a required\r\nsegs=[segs;Gtruth(L-47:end)]; % Last Segment is required\r\nptr=1;\r\nwhile 1\r\n ptr=ptr+randi(32);\r\n if ptr+48\u003eL,break;end\r\n segs=[segs;Gtruth(ptr:ptr+47)];\r\nend\r\n\r\nv=randperm(size(segs,1)); % Segs Scrambled Over Easy\r\nsegs(:,:)=segs(v,:);\r\n\r\nf=logical(randi(2,size(segs,1),1)-1);\r\nsegs_orig=segs;\r\n\r\nsegs(f,:)=fliplr(segs(f,:));\r\n\r\n\r\n\r\nGout = Genome_003R(segs);\r\ntoc\r\n\r\nassert(isequal(Gout,Gtruth)||isequal(Gout,fliplr(Gtruth)))\r\n%assert( isequal(Gout,Gtruth) )\r\n%%\r\ntic\r\nL=2000+randi(200);\r\nwhile 1 % Loop until create a Gtruth with no repeated 16 segments\r\n Gtruth=randi(4,1,L,'uint8')-1;\r\n \r\n Gseg=zeros(L-15,16,'uint8');\r\n GtruthR=fliplr(Gtruth);\r\n for j=1:L-15\r\n  Gseg(j,:)=Gtruth(j:j+15);\r\n  Gseg(j+L-15,:)=GtruthR(j:j+15);\r\n end\r\n Gsegv=uint32(Gseg(:,1));\r\n for j=2:16\r\n  Gsegv=4*Gsegv+uint32(Gseg(:,j));\r\n end\r\n if size(unique(Gsegv),1)==(L-15)*2\r\n  break\r\n end\r\nend % while create valid Gtruth\r\n\r\nsegs=Gtruth(1:48); % First segment is a required\r\nsegs=[segs;Gtruth(L-47:end)]; % Last Segment is required\r\nptr=1;\r\nwhile 1\r\n ptr=ptr+randi(32);\r\n if ptr+48\u003eL,break;end\r\n segs=[segs;Gtruth(ptr:ptr+47)];\r\nend\r\n\r\nv=randperm(size(segs,1)); % Segs Scrambled Over Easy\r\nsegs(:,:)=segs(v,:);\r\n\r\nf=logical(randi(2,size(segs,1),1)-1);\r\nsegs_orig=segs;\r\n\r\nsegs(f,:)=fliplr(segs(f,:));\r\n\r\n\r\n\r\nGout = Genome_003R(segs);\r\ntoc\r\n\r\nassert(isequal(Gout,Gtruth)||isequal(Gout,fliplr(Gtruth)))\r\n%assert( isequal(Gout,Gtruth) )\r\n%%\r\ntic\r\nL=4000+randi(200);\r\nwhile 1 % Loop until create a Gtruth with no repeated 16 segments\r\n Gtruth=randi(4,1,L,'uint8')-1;\r\n \r\n Gseg=zeros(L-15,16,'uint8');\r\n GtruthR=fliplr(Gtruth);\r\n for j=1:L-15\r\n  Gseg(j,:)=Gtruth(j:j+15);\r\n  Gseg(j+L-15,:)=GtruthR(j:j+15);\r\n end\r\n Gsegv=uint32(Gseg(:,1));\r\n for j=2:16\r\n  Gsegv=4*Gsegv+uint32(Gseg(:,j));\r\n end\r\n if size(unique(Gsegv),1)==(L-15)*2\r\n  break\r\n end\r\nend % while create valid Gtruth\r\n\r\nsegs=Gtruth(1:48); % First segment is a required\r\nsegs=[segs;Gtruth(L-47:end)]; % Last Segment is required\r\nptr=1;\r\nwhile 1\r\n ptr=ptr+randi(32);\r\n if ptr+48\u003eL,break;end\r\n segs=[segs;Gtruth(ptr:ptr+47)];\r\nend\r\n\r\nv=randperm(size(segs,1)); % Segs Scrambled Over Easy\r\nsegs(:,:)=segs(v,:);\r\n\r\nf=logical(randi(2,size(segs,1),1)-1);\r\nsegs_orig=segs;\r\n\r\nsegs(f,:)=fliplr(segs(f,:));\r\n\r\n\r\n\r\nGout = Genome_003R(segs);\r\ntoc\r\n\r\nassert(isequal(Gout,Gtruth)||isequal(Gout,fliplr(Gtruth)))\r\n%assert( isequal(Gout,Gtruth) )\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":3,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2,"test_suite_updated_at":"2021-07-16T14:52:10.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-06-27T17:37:02.000Z","updated_at":"2021-07-16T14:52:10.000Z","published_at":"2012-10-07T22:51:12.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\u003eThis is Challenge 003R in the series on Genome DNA Sequencing. Challenge 3R includes flipped segments.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDNA Sequencing\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is naively simplified into Cody Challenges.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGenome sizes\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is another interesting wiki page.\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\u003eDNA is represented by symbols ACGT, which for Matlab will be encoded as 0123. The basic goal is to reconstruct the original serial string of ACGT given multiple short segments.\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\u003cw:r\u003e\u003cw:t\u003e Genome = ACGTCGGCCATGGACATTACG\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven three overlapping pieces, ACGTCGGCCA, GCCATGGACATC, and GACATTACG these can be readily seen to overlap and create the original if the middle is recognized as being reversed with asymetric overlaps to its adjacent segments.\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[ACGTCGGCCATGGACATTACG\\nACGTCGGCCAsssssssssss\\nssssGCCATGGACATCsssss Middle Rev\\nssssCTACAGGTACCGsssss Middle flipped\\nssssssssssssGACATTACG]]\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\u003eGenome_003R Challenge is to reconstruct a genome under near ideal error free segment creation conditions. Segments may be reversed. The segments start at random locations.\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\u003eSegments may be reversed (Change from 003)\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\u003eSegments start at random positions\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\u003eGenome length is unconstrained\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\u003eLength of each segment - 48\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\u003eAll segments may overlap by 16 to 47 characters\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNo errors in the segments\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\u003eGenome is random (No duplicate starts or ends for 16 symbols of segments)\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\u003eSegment order is scrambled\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\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e segs, Array of M rows of 48 value segments. Values are [0, 1, 2, 3].\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\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Gout, Genome vector of values [0,1,2,3]\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\u003cw:r\u003e\u003cw:t\u003e [0 1 2 3 2;1 1 2 2 3 2 ; 2 2 1 1 2] creates [0 1 2 3 2 2 1 1 2] W=5, Overlap=varies, Reverses may occur\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\u003eFuture:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Flipped segments(002), Random Position of Segment start locations(003),Random Segment Positions with Flips (003R), Parrot Sequence with Gen3 Long Segments, Extra Segments, Phage Phi X174, Parallel Processing Simulation(Shot Gun Approach), Haemophilus Influenza, Sequence with Segment Errors, and Chromosome 20 with its 59M length using 100K 4K-segments\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":44435,"title":"Testing for randomness: uniform distribution of real numbers (distribution checking)","description":"You will be presented with a variety of sequences of real numbers.  Your job is to answer the question:  \"Is this a uniformly distributed sequence of random numbers?\"\r\n\r\n*Only the distribution needs to be examined in this problem.*  (You do not need to check for autocorrelation.)  \r\n\r\n Input:   x, a row vector of real numbers.  \r\n Output:  y, a Boolean scalar.  \r\n\r\nSome sequences have been generated by MATLAB's (pseudo)random number generator, such as:\r\n\r\n  x = 0.062    0.945    0.006    0.301    0.638    0.920    0.043    0.533    0.539    0.292    0.218    0.465    0.826    0.172    0.686    0.040    0.489    0.3950    0.761    0.038\r\n\r\nOn average these will have a uniform distribution.  Thus, by splitting up the sequence into 'bins' we find for the example above there are twelve numbers falling into the 0.0-to-0.5 bin, and a further eight numbers falling into the 0.5-to-1.0 bin.  For this length of sequence (a total of twenty numbers), that would be a sufficiently even division to *retain* the hypothesis that the underlying distribution from which the numbers were sampled was indeed a random, uniform distribution function (UDF).  \r\nHowever, please note that it may be necessary to divide the data into more than just two bins.  \r\n\r\nOther sequences will have been constructed so as to weight unevenly.  For example:  \r\n\r\n  x = 7.004    1.002    1.984    3.868    2.048    1.014    1.066    1.337    1.074   60.266    1.008    1.783    2.196    1.065    1.0613    1.049    1.236    1.235    1.394    1.107\r\n\r\nhas fifteen numbers in the 1.0-to-2.0 bin, but then there are some weird 'outliers' in the remaining five numbers, which reach up to more than 60.  It does *not* seem likely that this would have been generated from a UDF.  \r\n\r\n|Note: the sequences in the examples above were for illustrative purposes; most sequences in the Test Suite are considerably longer.|\r\n\r\nSee also:\r\n\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44393 Problem 44393: \"Testing for randomness: uniform distribution of integers\"\u003e (harder)","description_html":"\u003cp\u003eYou will be presented with a variety of sequences of real numbers.  Your job is to answer the question:  \"Is this a uniformly distributed sequence of random numbers?\"\u003c/p\u003e\u003cp\u003e\u003cb\u003eOnly the distribution needs to be examined in this problem.\u003c/b\u003e  (You do not need to check for autocorrelation.)\u003c/p\u003e\u003cpre\u003e Input:   x, a row vector of real numbers.  \r\n Output:  y, a Boolean scalar.  \u003c/pre\u003e\u003cp\u003eSome sequences have been generated by MATLAB's (pseudo)random number generator, such as:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ex = 0.062    0.945    0.006    0.301    0.638    0.920    0.043    0.533    0.539    0.292    0.218    0.465    0.826    0.172    0.686    0.040    0.489    0.3950    0.761    0.038\r\n\u003c/pre\u003e\u003cp\u003eOn average these will have a uniform distribution.  Thus, by splitting up the sequence into 'bins' we find for the example above there are twelve numbers falling into the 0.0-to-0.5 bin, and a further eight numbers falling into the 0.5-to-1.0 bin.  For this length of sequence (a total of twenty numbers), that would be a sufficiently even division to \u003cb\u003eretain\u003c/b\u003e the hypothesis that the underlying distribution from which the numbers were sampled was indeed a random, uniform distribution function (UDF).  \r\nHowever, please note that it may be necessary to divide the data into more than just two bins.\u003c/p\u003e\u003cp\u003eOther sequences will have been constructed so as to weight unevenly.  For example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ex = 7.004    1.002    1.984    3.868    2.048    1.014    1.066    1.337    1.074   60.266    1.008    1.783    2.196    1.065    1.0613    1.049    1.236    1.235    1.394    1.107\r\n\u003c/pre\u003e\u003cp\u003ehas fifteen numbers in the 1.0-to-2.0 bin, but then there are some weird 'outliers' in the remaining five numbers, which reach up to more than 60.  It does \u003cb\u003enot\u003c/b\u003e seem likely that this would have been generated from a UDF.\u003c/p\u003e\u003cp\u003e\u003ctt\u003eNote: the sequences in the examples above were for illustrative purposes; most sequences in the Test Suite are considerably longer.\u003c/tt\u003e\u003c/p\u003e\u003cp\u003eSee also:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44393\"\u003eProblem 44393: \"Testing for randomness: uniform distribution of integers\"\u003c/a\u003e (harder)\u003c/li\u003e\u003c/ul\u003e","function_template":"% Some comments could go here (or below).\r\nfunction y = isItRandom(x)\r\n    % Your code goes here!\r\n    % Some more code goes here!\r\n    % And so on  :-)\r\nend","test_suite":"% It is possible that even a genuine random number generator could produce \r\n% a sequence that does not have the characteristics of a random number stream, \r\n% so a couple of incorrect assessments are allowed as 'leeway' in each test.  \r\n\r\n%%\r\n% Random, short\r\nfaults = 0;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = 1000 * rand(1, 20+randi(10));\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% Bimodal, short\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = [rand(1, 10+randi(5)), 999 + rand(1, 10+randi(5))];\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Random, medium\r\nfaults = 0;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = randi(1000) + 1000 * rand(1, 100+randi(10));\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% Bimodal, medium\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = randi(1000) + [rand(1, 50+randi(5)), 999 + rand(1, 50+randi(5))];\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% Skewed, medium\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = 10 ./ rand(1, 100+randi(10));\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n\r\n%%\r\n% Random, long\r\nfaults = 0;\r\nisRandom_C = true;\r\nfor i = 1 : 10\r\n    x = 1000 * rand(1, 500+randi(10));\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% Skewed (1), long\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = 10 ./ rand(1, 500+randi(5)) - randi(1000);\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% Skewed (2), long\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = randi(1000) - 10 ./ rand(1, 500+randi(5));\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% Bimodal, long\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = [rand(1, 250+randi(5)), 999 + rand(1, 250+randi(5))];\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n%%\r\n% 'Normal' (a.k.a. 'Gaussian'), long\r\nfaults = 0;\r\nisRandom_C = false;\r\nfor i = 1 : 10\r\n    x = 250 * randn(1, 500+randi(5));\r\n    isRandom = isItRandom(x);\r\n    if ~isequal(isRandom, isRandom_C),  \r\n        faults = faults + 1;  \r\n        warning('*** CAUTION:  %u faults recorded so far. ***', faults);\r\n    end;\r\n    assert(faults \u003c= 2, 'Too many wrong assessments.');\r\nend;\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-12-03T12:12:04.000Z","updated_at":"2025-11-30T03:43:10.000Z","published_at":"2017-12-03T13:21:39.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will be presented with a variety of sequences of real numbers. Your job is to answer the question: \\\"Is this a uniformly distributed sequence of random 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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOnly the distribution needs to be examined in this problem.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (You do not need to check for autocorrelation.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input:   x, a row vector of real numbers.  \\n Output:  y, a Boolean scalar.]]\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\u003eSome sequences have been generated by MATLAB's (pseudo)random number generator, such as:\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 = 0.062    0.945    0.006    0.301    0.638    0.920    0.043    0.533    0.539    0.292    0.218    0.465    0.826    0.172    0.686    0.040    0.489    0.3950    0.761    0.038]]\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\u003eOn average these will have a uniform distribution. Thus, by splitting up the sequence into 'bins' we find for the example above there are twelve numbers falling into the 0.0-to-0.5 bin, and a further eight numbers falling into the 0.5-to-1.0 bin. For this length of sequence (a total of twenty numbers), that would be a sufficiently even division 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\u003eretain\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e the hypothesis that the underlying distribution from which the numbers were sampled was indeed a random, uniform distribution function (UDF). However, please note that it may be necessary to divide the data into more than just two bins.\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\u003eOther sequences will have been constructed so as to weight unevenly. For example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[x = 7.004    1.002    1.984    3.868    2.048    1.014    1.066    1.337    1.074   60.266    1.008    1.783    2.196    1.065    1.0613    1.049    1.236    1.235    1.394    1.107]]\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\u003ehas fifteen numbers in the 1.0-to-2.0 bin, but then there are some weird 'outliers' in the remaining five numbers, which reach up to more than 60. It does\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\u003enot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e seem likely that this would have been generated from a UDF.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote: the sequences in the examples above were for illustrative purposes; most sequences in the Test Suite are considerably longer.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee also:\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=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44393\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44393: \\\"Testing for randomness: uniform distribution of integers\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (harder)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"random\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"random\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"random\"","","\"","random","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007ff7fc063668\u003e":null,"#\u003cMathWorks::Search::Field:0x00007ff7fc0635c8\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007ff7fc062d08\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007ff7fc0638e8\u003e":1,"#\u003cMathWorks::Search::Field:0x00007ff7fc063848\u003e":50,"#\u003cMathWorks::Search::Field:0x00007ff7fc0637a8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007ff7fc063708\u003e":"tag:\"random\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007ff7fc063708\u003e":"tag:\"random\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"cody-search","password":"78X075ddcV44","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"random\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"random\"","","\"","random","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007ff7fc063668\u003e":null,"#\u003cMathWorks::Search::Field:0x00007ff7fc0635c8\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007ff7fc062d08\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007ff7fc0638e8\u003e":1,"#\u003cMathWorks::Search::Field:0x00007ff7fc063848\u003e":50,"#\u003cMathWorks::Search::Field:0x00007ff7fc0637a8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007ff7fc063708\u003e":"tag:\"random\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007ff7fc063708\u003e":"tag:\"random\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":44031,"difficulty_rating":"easy"},{"id":44272,"difficulty_rating":"easy"},{"id":2289,"difficulty_rating":"easy"},{"id":2793,"difficulty_rating":"easy-medium"},{"id":44477,"difficulty_rating":"easy-medium"},{"id":44315,"difficulty_rating":"easy-medium"},{"id":43592,"difficulty_rating":"easy-medium"},{"id":596,"difficulty_rating":"easy-medium"},{"id":51970,"difficulty_rating":"easy-medium"},{"id":699,"difficulty_rating":"easy-medium"},{"id":174,"difficulty_rating":"easy-medium"},{"id":1227,"difficulty_rating":"easy-medium"},{"id":1729,"difficulty_rating":"easy-medium"},{"id":1713,"difficulty_rating":"easy-medium"},{"id":2356,"difficulty_rating":"easy-medium"},{"id":46568,"difficulty_rating":"medium"},{"id":52323,"difficulty_rating":"medium"},{"id":1089,"difficulty_rating":"medium"},{"id":46585,"difficulty_rating":"medium"},{"id":44694,"difficulty_rating":"medium"},{"id":44393,"difficulty_rating":"medium"},{"id":44630,"difficulty_rating":"medium"},{"id":797,"difficulty_rating":"hard"},{"id":44435,"difficulty_rating":"hard"}]}}