{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.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":"2025-12-14T00: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":44083,"title":"First use of arrayfun() and anonymous function @(x)","description":"Create an anonymous function using @(x) for a parabola equation for the given coefficients stored in s with\r\ns(1)x2 + s(2)x + s(3).\r\nUse arrayfun() to apply the parabola equation to each element in the array A.\r\nNote: for , while , and eval are forbidden.\r\nHave fun :o)","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: 141px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 70.5px; transform-origin: 407px 70.5px; 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: 337px 8px; transform-origin: 337px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCreate an anonymous function using @(x) for a parabola equation for the given coefficients stored in s with\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: 65.5px 8px; transform-origin: 65.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003es(1)x2 + s(2)x + s(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: 243px 8px; transform-origin: 243px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eUse arrayfun() to apply the parabola equation to each element in the array A.\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: 16.5px 8px; transform-origin: 16.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNote:\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\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: 8.5px 8px; transform-origin: 8.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003efor\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: 4px 8px; transform-origin: 4px 8px; unicode-bidi: normal; \"\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\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: 15.5px 8px; transform-origin: 15.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003ewhile\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: 18px 8px; transform-origin: 18px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e , and\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\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: 12.5px 8px; transform-origin: 12.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eeval\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: 46.5px 8px; transform-origin: 46.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e are forbidden.\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: 38.5px 8px; transform-origin: 38.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eHave fun :o)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function B = parabola_equation(A,s)\r\n    \r\n  B = A;\r\n  \r\nend","test_suite":"%%\r\nA = [0 1 2];\r\ns = [1 2 3];\r\ny_correct = [3 6 11];\r\nassert(isequal(parabola_equation(A,s),y_correct))\r\n%%\r\nA = -12:4:11;\r\ns = [-5 -8 0];\r\ny_correct = [-624  -256   -48     0  -112  -384];\r\nassert(isequal(parabola_equation(A,s),y_correct))\r\n%%\r\nA = -2:2;\r\ns = [0 pi 0];\r\ny_correct = [-2*pi -pi 0  pi 2*pi];\r\nassert(isequal(parabola_equation(A,s),y_correct))\r\n%%\r\nassert(isempty(regexp(evalc('type parabola_equation'),'(eval|for|while|polyval|)')))\r\nassert(not(isempty(regexp(evalc('type parabola_equation'),'(@)'))))\r\nassert(not(isempty(regexp(evalc('type parabola_equation'),'arrayfun'))))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":100084,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":72,"test_suite_updated_at":"2022-03-01T19:46:58.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-03-10T22:47:36.000Z","updated_at":"2026-03-16T13:46:36.000Z","published_at":"2017-03-10T22:48:28.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\u003eCreate an anonymous function using @(x) for a parabola equation for the given coefficients stored in s with\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\u003es(1)x2 + s(2)x + s(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:t\u003eUse arrayfun() to apply the parabola equation to each element in the array 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\u003eNote:\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\u003efor\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: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\u003ewhile\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eeval\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e are forbidden.\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\u003eHave fun :o)\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":1298,"title":"P-smooth numbers","description":"This Challenge is to find \u003chttps://en.wikipedia.org/wiki/Smooth_number P-smooth number\u003e partial sets given P and a max series value.\r\n\r\nA P-smooth number set of N contains a subset of 1:N integers whose prime factors are all \u003c=P.\r\n\r\nFor P=3 and N=16: P-smooth subset is [1 2 3 4 6 8 9 12 16]. Values 5,7,10,13,14,and 15 are primes \u003e3 or values divisible by primes\u003e3.\r\n\r\nvs = find_psmooth(P,N)\r\n\r\n\r\nSample \u003chttps://oeis.org/A051038 OEIS 11-smooth numbers\u003e\r\n\r\nWhere are P-smooth numbers utilized or present themselves?\r\nUpcoming Challenge solved by P-smooth numbers.","description_html":"\u003cp\u003eThis Challenge is to find \u003ca href = \"https://en.wikipedia.org/wiki/Smooth_number\"\u003eP-smooth number\u003c/a\u003e partial sets given P and a max series value.\u003c/p\u003e\u003cp\u003eA P-smooth number set of N contains a subset of 1:N integers whose prime factors are all \u0026lt;=P.\u003c/p\u003e\u003cp\u003eFor P=3 and N=16: P-smooth subset is [1 2 3 4 6 8 9 12 16]. Values 5,7,10,13,14,and 15 are primes \u0026gt;3 or values divisible by primes\u0026gt;3.\u003c/p\u003e\u003cp\u003evs = find_psmooth(P,N)\u003c/p\u003e\u003cp\u003eSample \u003ca href = \"https://oeis.org/A051038\"\u003eOEIS 11-smooth numbers\u003c/a\u003e\u003c/p\u003e\u003cp\u003eWhere are P-smooth numbers utilized or present themselves?\r\nUpcoming Challenge solved by P-smooth numbers.\u003c/p\u003e","function_template":"function vs = find_psmooth(pmax,vmax)\r\n% pmax is prime max\r\n% vmax is max value of set 1:vmax\r\n  vs=1;\r\nend","test_suite":"%%\r\nvs = find_psmooth(2,16);\r\nassert(isequal(vs,[1 2 4 8 16]))\r\n%%\r\nvs = find_psmooth(3,128);\r\nassert(isequal(vs,[1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 81, 96, 108, 128]))\r\n%%\r\nvs = find_psmooth(11,73);\r\nassert(isequal(vs,[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 27, 28, 30, 32, 33, 35, 36, 40, 42, 44, 45, 48, 49, 50, 54, 55, 56, 60, 63, 64, 66, 70, 72]))\r\n%%\r\npmax=7; vmax=120;\r\nvs = find_psmooth(pmax,vmax);\r\nvs=unique(vs); % Validity checks\r\nvs(vs\u003evmax)=[];\r\nvs(vs\u003c1)=[];\r\nvs=floor(vs);\r\nlength(vs)\r\nif length(vs)==50 % Known length\r\n pass=true;\r\nelse\r\n pass=false;\r\nend\r\npv=primes(vmax);\r\npv(pv\u003c=pmax)=[];\r\nfor i=pv\r\n if any(mod(vs,i)==0) % check for prime divisors \u003epmax\r\n  pass=false;\r\n  break;\r\n end\r\nend\r\nassert(pass)\r\n%%\r\npmax=11; vmax=300;\r\nvs = find_psmooth(pmax,vmax);\r\nvs=unique(vs); % Validity checks\r\nvs(vs\u003evmax)=[];\r\nvs(vs\u003c1)=[];\r\nvs=floor(vs);\r\nlength(vs)\r\nif length(vs)==104 % Known length\r\n pass=true;\r\nelse\r\n pass=false;\r\nend\r\npv=primes(vmax);\r\npv(pv\u003c=pmax)=[];\r\nfor i=pv\r\n if any(mod(vs,i)==0) % check for prime divisors \u003epmax\r\n  pass=false;\r\n  break;\r\n end\r\nend\r\nassert(pass)\r\n%%\r\npmax=13; vmax=900;\r\nvs = find_psmooth(pmax,vmax);\r\nvs=unique(vs); % Validity checks\r\nvs(vs\u003evmax)=[];\r\nvs(vs\u003c1)=[];\r\nvs=floor(vs);\r\nlength(vs)\r\nif length(vs)==231% Known length\r\n pass=true;\r\nelse\r\n pass=false;\r\nend\r\npv=primes(vmax);\r\npv(pv\u003c=pmax)=[];\r\nfor i=pv\r\n if any(mod(vs,i)==0) % check for prime divisors \u003epmax\r\n  pass=false;\r\n  break;\r\n end\r\nend\r\nassert(pass)\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":97,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":44,"created_at":"2013-02-23T23:06:45.000Z","updated_at":"2026-02-07T16:12:25.000Z","published_at":"2016-02-21T23:06:03.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is to find\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/Smooth_number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eP-smooth number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e partial sets given P and a max series value.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA P-smooth number set of N contains a subset of 1:N integers whose prime factors are all \u0026lt;=P.\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 P=3 and N=16: P-smooth subset is [1 2 3 4 6 8 9 12 16]. Values 5,7,10,13,14,and 15 are primes \u0026gt;3 or values divisible by primes\u0026gt;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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003evs = find_psmooth(P,N)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSample\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://oeis.org/A051038\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOEIS 11-smooth numbers\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\u003eWhere are P-smooth numbers utilized or present themselves? Upcoming Challenge solved by P-smooth numbers.\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":1684,"title":"Identify Reachable Points ","description":"Given a vector of 2-D Points and a vector of 2-D Deltas create an array of all Locations that can be reached from the points using the Deltas. The provided Deltas are only positive but the points that can be reached may use Negative Deltas or Y-deltas for X moves, like moves of a Knight dxy [1 2].\r\n\r\n*Input:* [Pts, dxy]\r\n\r\n\r\n*Output:* Mxy\r\n\r\n*Example:* \r\n\r\n  Pts [5 5; 7 9]\r\n\r\n  dxy [0 1]  % Multiple dxy are possible\r\n  \r\n  Mxy =[4 5;5 4;5 6;6 5;6 9;7 8;7 10;8 9]\r\n\r\n*Related Challenges:*\r\n\r\n1) Minimum Sized Circle for N integer points with all unique distances ","description_html":"\u003cp\u003eGiven a vector of 2-D Points and a vector of 2-D Deltas create an array of all Locations that can be reached from the points using the Deltas. The provided Deltas are only positive but the points that can be reached may use Negative Deltas or Y-deltas for X moves, like moves of a Knight dxy [1 2].\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e [Pts, dxy]\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e Mxy\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ePts [5 5; 7 9]\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003edxy [0 1]  % Multiple dxy are possible\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eMxy =[4 5;5 4;5 6;6 5;6 9;7 8;7 10;8 9]\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eRelated Challenges:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e1) Minimum Sized Circle for N integer points with all unique distances\u003c/p\u003e","function_template":"function Mxy=Knights(Pts,dxy)\r\n  Mxy=Pts;\r\nend","test_suite":"%%\r\nPts=[5 5; 7 9];\r\ndxy=[0 1];\r\nMxy=unique(Knights(Pts,dxy),'rows');\r\n\r\nMxy_exp =[4 5;5 4;5 6;6 5;6 9;7 8;7 10;8 9];\r\nassert(isequal(Mxy,Mxy_exp))\r\n%%\r\nPts=[5 5];\r\ndxy=[0 1;1 2];\r\nMxy=unique(Knights(Pts,dxy),'rows');\r\n\r\nMxy_exp =[3 4;3 6;4 3;4 5;4 7;5 4;5 6;6 3;6 5;6 7;7 4;7 6];\r\nassert(isequal(Mxy,Mxy_exp))\r\n%%\r\npts=randi(20,6,2);\r\ndxy=randi(6,4,2);\r\nMxy=unique(Knights(pts,dxy),'rows');\r\n\r\n nP=size(pts,1);\r\n ndxy=size(dxy,1);\r\n \r\n mxy=[];\r\n for i=1:nP\r\n  mxy=[mxy;\r\n      dxy(:,1)+pts(i,1) dxy(:,2)+pts(i,2);\r\n      -dxy(:,1)+pts(i,1) dxy(:,2)+pts(i,2);\r\n      dxy(:,1)+pts(i,1) -dxy(:,2)+pts(i,2);\r\n      -dxy(:,1)+pts(i,1) -dxy(:,2)+pts(i,2);\r\n       dxy(:,2)+pts(i,1) dxy(:,1)+pts(i,2);\r\n      -dxy(:,2)+pts(i,1) dxy(:,1)+pts(i,2);\r\n      dxy(:,2)+pts(i,1) -dxy(:,1)+pts(i,2);\r\n      -dxy(:,2)+pts(i,1) -dxy(:,1)+pts(i,2)];\r\n end\r\n\r\n Mxy_exp=unique(mxy,'rows');\r\n\r\nassert(isequal(Mxy,Mxy_exp))\r\n\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":3097,"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-06-28T03:22:54.000Z","updated_at":"2026-02-15T07:15:08.000Z","published_at":"2013-06-28T03:58:36.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a vector of 2-D Points and a vector of 2-D Deltas create an array of all Locations that can be reached from the points using the Deltas. The provided Deltas are only positive but the points that can be reached may use Negative Deltas or Y-deltas for X moves, like moves of a Knight dxy [1 2].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw: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 [Pts, dxy]\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\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Mxy\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\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[Pts [5 5; 7 9]\\n\\ndxy [0 1]  % Multiple dxy are possible\\n\\nMxy =[4 5;5 4;5 6;6 5;6 9;7 8;7 10;8 9]]]\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\u003eRelated Challenges:\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\u003e1) Minimum Sized Circle for N integer points with all unique distances\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":47335,"title":"arrayfun bomb","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: 51px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 25.5px; transform-origin: 407px 25.5px; 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=\"\"\u003eCan you blow up this seemingly invulnerable expression with a bomb array?\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=\"\"\u003earrayfun(@(A)A,A)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = BombArray()\r\n  y = [];\r\nend","test_suite":"%%\r\nBa=BombArray;\r\nassert(~isequal(size(Ba),[1 1]));\r\ntry\r\n\r\n    arrayfun(@(Ba)Ba,Ba);\r\ncatch\r\n    return;\r\nend\r\nassert(false);","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":362068,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":"2020-11-07T03:18:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-11-05T16:56:51.000Z","updated_at":"2025-06-28T08:43:06.000Z","published_at":"2020-11-05T16:56:51.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\u003eCan you blow up this seemingly invulnerable expression with a bomb array?\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\u003earrayfun(@(A)A,A)\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":3074,"title":"Compute the cokurtosis of a given portfolio.","description":"As input data, you are given a nObs-by-nAssets matrix _portRet_ of return series for assets in a portfolio along with an nAssets-by-1 vector _portWeights_ of portfolio weights. Example: \r\n\r\n \u003e\u003e nObs = 504; % Number of observations\r\n\r\n \u003e\u003e nAssets = 5; % Number of assets in the portfolio\r\n\r\n \u003e\u003e portRet = randn(nObs, nAssets); % Sample portfolio return series\r\n\r\n \u003e\u003e portWeights = rand(nAssets, 1); \r\n\r\n \u003e\u003e portWeights = portWeights/sum(portWeights); % Portfolio weights are \u003e=0 and sum to 1.\r\n\r\nThe task is to compute the *portfolio cokurtosis* , which is a scalar statistic associated with the portfolio. A full description of this statistic, along with sample MATLAB code for computing it, can be found here:\r\n\r\nhttp://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/\r\n\r\nWrite a function that accepts _portRet_ and _portWeights_ as input arguments and returns the scalar statistic _portCokurt_ as its output. You can use the code at the website above as a starting point, but try to simplify and shorten it in the spirit of Cody.\r\n\r\n\r\n\r\n","description_html":"\u003cp\u003eAs input data, you are given a nObs-by-nAssets matrix \u003ci\u003eportRet\u003c/i\u003e of return series for assets in a portfolio along with an nAssets-by-1 vector \u003ci\u003eportWeights\u003c/i\u003e of portfolio weights. Example:\u003c/p\u003e\u003cpre\u003e \u0026gt;\u0026gt; nObs = 504; % Number of observations\u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; nAssets = 5; % Number of assets in the portfolio\u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; portRet = randn(nObs, nAssets); % Sample portfolio return series\u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; portWeights = rand(nAssets, 1); \u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; portWeights = portWeights/sum(portWeights); % Portfolio weights are \u0026gt;=0 and sum to 1.\u003c/pre\u003e\u003cp\u003eThe task is to compute the \u003cb\u003eportfolio cokurtosis\u003c/b\u003e , which is a scalar statistic associated with the portfolio. A full description of this statistic, along with sample MATLAB code for computing it, can be found here:\u003c/p\u003e\u003cp\u003e\u003ca href = \"http://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/\"\u003ehttp://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/\u003c/a\u003e\u003c/p\u003e\u003cp\u003eWrite a function that accepts \u003ci\u003eportRet\u003c/i\u003e and \u003ci\u003eportWeights\u003c/i\u003e as input arguments and returns the scalar statistic \u003ci\u003eportCokurt\u003c/i\u003e as its output. You can use the code at the website above as a starting point, but try to simplify and shorten it in the spirit of Cody.\u003c/p\u003e","function_template":"function portCokurt = computePortCokurt(portRet, portWeights)\r\n\r\n\r\nend","test_suite":"%%\r\nrng('default')\r\nR = randn(504, 5);\r\nw = ones(5, 1)/5;\r\nassert(abs(computePortCokurt(R, w)-0.119749008958925)\u003c1e-3)\r\n\r\n%%\r\nrng('default')\r\nR = randn(252, 15);\r\nw = ones(15, 1)/15;\r\nassert(abs(computePortCokurt(R, w)-0.013012357540290)\u003c1e-3)\r\n\r\n%% \r\nrng('default')\r\nR = randn(100, 1);\r\nw = 1;\r\nassert(abs(computePortCokurt(R, w)-6.280759230562035)\u003c1e-3)\r\n\r\n%%\r\nrng('default')\r\nR = randn(5, 10);\r\nw = [0.1*ones(5, 1); 0.5; zeros(4, 1)];\r\nassert(abs(computePortCokurt(R, w)-0.169198885214440)\u003c1e-3)","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":2328,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":5,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-03-10T11:04:22.000Z","updated_at":"2015-03-11T18:00:35.000Z","published_at":"2015-03-10T11:25:35.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\u003eAs input data, you are given a nObs-by-nAssets matrix\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\u003eportRet\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of return series for assets in a portfolio along with an nAssets-by-1 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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eportWeights\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of portfolio weights. 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[ \u003e\u003e nObs = 504; % Number of observations\\n\\n \u003e\u003e nAssets = 5; % Number of assets in the portfolio\\n\\n \u003e\u003e portRet = randn(nObs, nAssets); % Sample portfolio return series\\n\\n \u003e\u003e portWeights = rand(nAssets, 1); \\n\\n \u003e\u003e portWeights = portWeights/sum(portWeights); % Portfolio weights are \u003e=0 and sum to 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\u003eThe task is to compute the\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\u003eportfolio cokurtosis\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e , which is a scalar statistic associated with the portfolio. A full description of this statistic, along with sample MATLAB code for computing it, can be found here:\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:hyperlink w:docLocation=\\\"http://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/\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\u003eWrite a function that accepts\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\u003eportRet\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eportWeights\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as input arguments and returns the scalar statistic\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\u003eportCokurt\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as its output. You can use the code at the website above as a starting point, but try to simplify and shorten it in the spirit of Cody.\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":44083,"title":"First use of arrayfun() and anonymous function @(x)","description":"Create an anonymous function using @(x) for a parabola equation for the given coefficients stored in s with\r\ns(1)x2 + s(2)x + s(3).\r\nUse arrayfun() to apply the parabola equation to each element in the array A.\r\nNote: for , while , and eval are forbidden.\r\nHave fun :o)","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: 141px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 70.5px; transform-origin: 407px 70.5px; 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: 337px 8px; transform-origin: 337px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCreate an anonymous function using @(x) for a parabola equation for the given coefficients stored in s with\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: 65.5px 8px; transform-origin: 65.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003es(1)x2 + s(2)x + s(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: 243px 8px; transform-origin: 243px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eUse arrayfun() to apply the parabola equation to each element in the array A.\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: 16.5px 8px; transform-origin: 16.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNote:\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\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: 8.5px 8px; transform-origin: 8.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003efor\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: 4px 8px; transform-origin: 4px 8px; unicode-bidi: normal; \"\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\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: 15.5px 8px; transform-origin: 15.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003ewhile\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: 18px 8px; transform-origin: 18px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e , and\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\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: 12.5px 8px; transform-origin: 12.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eeval\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: 46.5px 8px; transform-origin: 46.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e are forbidden.\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: 38.5px 8px; transform-origin: 38.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eHave fun :o)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function B = parabola_equation(A,s)\r\n    \r\n  B = A;\r\n  \r\nend","test_suite":"%%\r\nA = [0 1 2];\r\ns = [1 2 3];\r\ny_correct = [3 6 11];\r\nassert(isequal(parabola_equation(A,s),y_correct))\r\n%%\r\nA = -12:4:11;\r\ns = [-5 -8 0];\r\ny_correct = [-624  -256   -48     0  -112  -384];\r\nassert(isequal(parabola_equation(A,s),y_correct))\r\n%%\r\nA = -2:2;\r\ns = [0 pi 0];\r\ny_correct = [-2*pi -pi 0  pi 2*pi];\r\nassert(isequal(parabola_equation(A,s),y_correct))\r\n%%\r\nassert(isempty(regexp(evalc('type parabola_equation'),'(eval|for|while|polyval|)')))\r\nassert(not(isempty(regexp(evalc('type parabola_equation'),'(@)'))))\r\nassert(not(isempty(regexp(evalc('type parabola_equation'),'arrayfun'))))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":100084,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":72,"test_suite_updated_at":"2022-03-01T19:46:58.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-03-10T22:47:36.000Z","updated_at":"2026-03-16T13:46:36.000Z","published_at":"2017-03-10T22:48:28.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\u003eCreate an anonymous function using @(x) for a parabola equation for the given coefficients stored in s with\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\u003es(1)x2 + s(2)x + s(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:t\u003eUse arrayfun() to apply the parabola equation to each element in the array 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\u003eNote:\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\u003efor\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: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\u003ewhile\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eeval\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e are forbidden.\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\u003eHave fun :o)\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":1298,"title":"P-smooth numbers","description":"This Challenge is to find \u003chttps://en.wikipedia.org/wiki/Smooth_number P-smooth number\u003e partial sets given P and a max series value.\r\n\r\nA P-smooth number set of N contains a subset of 1:N integers whose prime factors are all \u003c=P.\r\n\r\nFor P=3 and N=16: P-smooth subset is [1 2 3 4 6 8 9 12 16]. Values 5,7,10,13,14,and 15 are primes \u003e3 or values divisible by primes\u003e3.\r\n\r\nvs = find_psmooth(P,N)\r\n\r\n\r\nSample \u003chttps://oeis.org/A051038 OEIS 11-smooth numbers\u003e\r\n\r\nWhere are P-smooth numbers utilized or present themselves?\r\nUpcoming Challenge solved by P-smooth numbers.","description_html":"\u003cp\u003eThis Challenge is to find \u003ca href = \"https://en.wikipedia.org/wiki/Smooth_number\"\u003eP-smooth number\u003c/a\u003e partial sets given P and a max series value.\u003c/p\u003e\u003cp\u003eA P-smooth number set of N contains a subset of 1:N integers whose prime factors are all \u0026lt;=P.\u003c/p\u003e\u003cp\u003eFor P=3 and N=16: P-smooth subset is [1 2 3 4 6 8 9 12 16]. Values 5,7,10,13,14,and 15 are primes \u0026gt;3 or values divisible by primes\u0026gt;3.\u003c/p\u003e\u003cp\u003evs = find_psmooth(P,N)\u003c/p\u003e\u003cp\u003eSample \u003ca href = \"https://oeis.org/A051038\"\u003eOEIS 11-smooth numbers\u003c/a\u003e\u003c/p\u003e\u003cp\u003eWhere are P-smooth numbers utilized or present themselves?\r\nUpcoming Challenge solved by P-smooth numbers.\u003c/p\u003e","function_template":"function vs = find_psmooth(pmax,vmax)\r\n% pmax is prime max\r\n% vmax is max value of set 1:vmax\r\n  vs=1;\r\nend","test_suite":"%%\r\nvs = find_psmooth(2,16);\r\nassert(isequal(vs,[1 2 4 8 16]))\r\n%%\r\nvs = find_psmooth(3,128);\r\nassert(isequal(vs,[1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 81, 96, 108, 128]))\r\n%%\r\nvs = find_psmooth(11,73);\r\nassert(isequal(vs,[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 27, 28, 30, 32, 33, 35, 36, 40, 42, 44, 45, 48, 49, 50, 54, 55, 56, 60, 63, 64, 66, 70, 72]))\r\n%%\r\npmax=7; vmax=120;\r\nvs = find_psmooth(pmax,vmax);\r\nvs=unique(vs); % Validity checks\r\nvs(vs\u003evmax)=[];\r\nvs(vs\u003c1)=[];\r\nvs=floor(vs);\r\nlength(vs)\r\nif length(vs)==50 % Known length\r\n pass=true;\r\nelse\r\n pass=false;\r\nend\r\npv=primes(vmax);\r\npv(pv\u003c=pmax)=[];\r\nfor i=pv\r\n if any(mod(vs,i)==0) % check for prime divisors \u003epmax\r\n  pass=false;\r\n  break;\r\n end\r\nend\r\nassert(pass)\r\n%%\r\npmax=11; vmax=300;\r\nvs = find_psmooth(pmax,vmax);\r\nvs=unique(vs); % Validity checks\r\nvs(vs\u003evmax)=[];\r\nvs(vs\u003c1)=[];\r\nvs=floor(vs);\r\nlength(vs)\r\nif length(vs)==104 % Known length\r\n pass=true;\r\nelse\r\n pass=false;\r\nend\r\npv=primes(vmax);\r\npv(pv\u003c=pmax)=[];\r\nfor i=pv\r\n if any(mod(vs,i)==0) % check for prime divisors \u003epmax\r\n  pass=false;\r\n  break;\r\n end\r\nend\r\nassert(pass)\r\n%%\r\npmax=13; vmax=900;\r\nvs = find_psmooth(pmax,vmax);\r\nvs=unique(vs); % Validity checks\r\nvs(vs\u003evmax)=[];\r\nvs(vs\u003c1)=[];\r\nvs=floor(vs);\r\nlength(vs)\r\nif length(vs)==231% Known length\r\n pass=true;\r\nelse\r\n pass=false;\r\nend\r\npv=primes(vmax);\r\npv(pv\u003c=pmax)=[];\r\nfor i=pv\r\n if any(mod(vs,i)==0) % check for prime divisors \u003epmax\r\n  pass=false;\r\n  break;\r\n end\r\nend\r\nassert(pass)\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":97,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":44,"created_at":"2013-02-23T23:06:45.000Z","updated_at":"2026-02-07T16:12:25.000Z","published_at":"2016-02-21T23:06:03.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is to find\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/Smooth_number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eP-smooth number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e partial sets given P and a max series value.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA P-smooth number set of N contains a subset of 1:N integers whose prime factors are all \u0026lt;=P.\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 P=3 and N=16: P-smooth subset is [1 2 3 4 6 8 9 12 16]. Values 5,7,10,13,14,and 15 are primes \u0026gt;3 or values divisible by primes\u0026gt;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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003evs = find_psmooth(P,N)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSample\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://oeis.org/A051038\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOEIS 11-smooth numbers\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\u003eWhere are P-smooth numbers utilized or present themselves? Upcoming Challenge solved by P-smooth numbers.\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":1684,"title":"Identify Reachable Points ","description":"Given a vector of 2-D Points and a vector of 2-D Deltas create an array of all Locations that can be reached from the points using the Deltas. The provided Deltas are only positive but the points that can be reached may use Negative Deltas or Y-deltas for X moves, like moves of a Knight dxy [1 2].\r\n\r\n*Input:* [Pts, dxy]\r\n\r\n\r\n*Output:* Mxy\r\n\r\n*Example:* \r\n\r\n  Pts [5 5; 7 9]\r\n\r\n  dxy [0 1]  % Multiple dxy are possible\r\n  \r\n  Mxy =[4 5;5 4;5 6;6 5;6 9;7 8;7 10;8 9]\r\n\r\n*Related Challenges:*\r\n\r\n1) Minimum Sized Circle for N integer points with all unique distances ","description_html":"\u003cp\u003eGiven a vector of 2-D Points and a vector of 2-D Deltas create an array of all Locations that can be reached from the points using the Deltas. The provided Deltas are only positive but the points that can be reached may use Negative Deltas or Y-deltas for X moves, like moves of a Knight dxy [1 2].\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e [Pts, dxy]\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e Mxy\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ePts [5 5; 7 9]\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003edxy [0 1]  % Multiple dxy are possible\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eMxy =[4 5;5 4;5 6;6 5;6 9;7 8;7 10;8 9]\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eRelated Challenges:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e1) Minimum Sized Circle for N integer points with all unique distances\u003c/p\u003e","function_template":"function Mxy=Knights(Pts,dxy)\r\n  Mxy=Pts;\r\nend","test_suite":"%%\r\nPts=[5 5; 7 9];\r\ndxy=[0 1];\r\nMxy=unique(Knights(Pts,dxy),'rows');\r\n\r\nMxy_exp =[4 5;5 4;5 6;6 5;6 9;7 8;7 10;8 9];\r\nassert(isequal(Mxy,Mxy_exp))\r\n%%\r\nPts=[5 5];\r\ndxy=[0 1;1 2];\r\nMxy=unique(Knights(Pts,dxy),'rows');\r\n\r\nMxy_exp =[3 4;3 6;4 3;4 5;4 7;5 4;5 6;6 3;6 5;6 7;7 4;7 6];\r\nassert(isequal(Mxy,Mxy_exp))\r\n%%\r\npts=randi(20,6,2);\r\ndxy=randi(6,4,2);\r\nMxy=unique(Knights(pts,dxy),'rows');\r\n\r\n nP=size(pts,1);\r\n ndxy=size(dxy,1);\r\n \r\n mxy=[];\r\n for i=1:nP\r\n  mxy=[mxy;\r\n      dxy(:,1)+pts(i,1) dxy(:,2)+pts(i,2);\r\n      -dxy(:,1)+pts(i,1) dxy(:,2)+pts(i,2);\r\n      dxy(:,1)+pts(i,1) -dxy(:,2)+pts(i,2);\r\n      -dxy(:,1)+pts(i,1) -dxy(:,2)+pts(i,2);\r\n       dxy(:,2)+pts(i,1) dxy(:,1)+pts(i,2);\r\n      -dxy(:,2)+pts(i,1) dxy(:,1)+pts(i,2);\r\n      dxy(:,2)+pts(i,1) -dxy(:,1)+pts(i,2);\r\n      -dxy(:,2)+pts(i,1) -dxy(:,1)+pts(i,2)];\r\n end\r\n\r\n Mxy_exp=unique(mxy,'rows');\r\n\r\nassert(isequal(Mxy,Mxy_exp))\r\n\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":3097,"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-06-28T03:22:54.000Z","updated_at":"2026-02-15T07:15:08.000Z","published_at":"2013-06-28T03:58:36.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a vector of 2-D Points and a vector of 2-D Deltas create an array of all Locations that can be reached from the points using the Deltas. The provided Deltas are only positive but the points that can be reached may use Negative Deltas or Y-deltas for X moves, like moves of a Knight dxy [1 2].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw: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 [Pts, dxy]\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\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Mxy\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\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[Pts [5 5; 7 9]\\n\\ndxy [0 1]  % Multiple dxy are possible\\n\\nMxy =[4 5;5 4;5 6;6 5;6 9;7 8;7 10;8 9]]]\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\u003eRelated Challenges:\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\u003e1) Minimum Sized Circle for N integer points with all unique distances\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":47335,"title":"arrayfun bomb","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: 51px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 25.5px; transform-origin: 407px 25.5px; 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=\"\"\u003eCan you blow up this seemingly invulnerable expression with a bomb array?\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=\"\"\u003earrayfun(@(A)A,A)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = BombArray()\r\n  y = [];\r\nend","test_suite":"%%\r\nBa=BombArray;\r\nassert(~isequal(size(Ba),[1 1]));\r\ntry\r\n\r\n    arrayfun(@(Ba)Ba,Ba);\r\ncatch\r\n    return;\r\nend\r\nassert(false);","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":362068,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":"2020-11-07T03:18:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-11-05T16:56:51.000Z","updated_at":"2025-06-28T08:43:06.000Z","published_at":"2020-11-05T16:56:51.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\u003eCan you blow up this seemingly invulnerable expression with a bomb array?\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\u003earrayfun(@(A)A,A)\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":3074,"title":"Compute the cokurtosis of a given portfolio.","description":"As input data, you are given a nObs-by-nAssets matrix _portRet_ of return series for assets in a portfolio along with an nAssets-by-1 vector _portWeights_ of portfolio weights. Example: \r\n\r\n \u003e\u003e nObs = 504; % Number of observations\r\n\r\n \u003e\u003e nAssets = 5; % Number of assets in the portfolio\r\n\r\n \u003e\u003e portRet = randn(nObs, nAssets); % Sample portfolio return series\r\n\r\n \u003e\u003e portWeights = rand(nAssets, 1); \r\n\r\n \u003e\u003e portWeights = portWeights/sum(portWeights); % Portfolio weights are \u003e=0 and sum to 1.\r\n\r\nThe task is to compute the *portfolio cokurtosis* , which is a scalar statistic associated with the portfolio. A full description of this statistic, along with sample MATLAB code for computing it, can be found here:\r\n\r\nhttp://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/\r\n\r\nWrite a function that accepts _portRet_ and _portWeights_ as input arguments and returns the scalar statistic _portCokurt_ as its output. You can use the code at the website above as a starting point, but try to simplify and shorten it in the spirit of Cody.\r\n\r\n\r\n\r\n","description_html":"\u003cp\u003eAs input data, you are given a nObs-by-nAssets matrix \u003ci\u003eportRet\u003c/i\u003e of return series for assets in a portfolio along with an nAssets-by-1 vector \u003ci\u003eportWeights\u003c/i\u003e of portfolio weights. Example:\u003c/p\u003e\u003cpre\u003e \u0026gt;\u0026gt; nObs = 504; % Number of observations\u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; nAssets = 5; % Number of assets in the portfolio\u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; portRet = randn(nObs, nAssets); % Sample portfolio return series\u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; portWeights = rand(nAssets, 1); \u003c/pre\u003e\u003cpre\u003e \u0026gt;\u0026gt; portWeights = portWeights/sum(portWeights); % Portfolio weights are \u0026gt;=0 and sum to 1.\u003c/pre\u003e\u003cp\u003eThe task is to compute the \u003cb\u003eportfolio cokurtosis\u003c/b\u003e , which is a scalar statistic associated with the portfolio. A full description of this statistic, along with sample MATLAB code for computing it, can be found here:\u003c/p\u003e\u003cp\u003e\u003ca href = \"http://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/\"\u003ehttp://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/\u003c/a\u003e\u003c/p\u003e\u003cp\u003eWrite a function that accepts \u003ci\u003eportRet\u003c/i\u003e and \u003ci\u003eportWeights\u003c/i\u003e as input arguments and returns the scalar statistic \u003ci\u003eportCokurt\u003c/i\u003e as its output. You can use the code at the website above as a starting point, but try to simplify and shorten it in the spirit of Cody.\u003c/p\u003e","function_template":"function portCokurt = computePortCokurt(portRet, portWeights)\r\n\r\n\r\nend","test_suite":"%%\r\nrng('default')\r\nR = randn(504, 5);\r\nw = ones(5, 1)/5;\r\nassert(abs(computePortCokurt(R, w)-0.119749008958925)\u003c1e-3)\r\n\r\n%%\r\nrng('default')\r\nR = randn(252, 15);\r\nw = ones(15, 1)/15;\r\nassert(abs(computePortCokurt(R, w)-0.013012357540290)\u003c1e-3)\r\n\r\n%% \r\nrng('default')\r\nR = randn(100, 1);\r\nw = 1;\r\nassert(abs(computePortCokurt(R, w)-6.280759230562035)\u003c1e-3)\r\n\r\n%%\r\nrng('default')\r\nR = randn(5, 10);\r\nw = [0.1*ones(5, 1); 0.5; zeros(4, 1)];\r\nassert(abs(computePortCokurt(R, w)-0.169198885214440)\u003c1e-3)","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":2328,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":5,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-03-10T11:04:22.000Z","updated_at":"2015-03-11T18:00:35.000Z","published_at":"2015-03-10T11:25:35.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\u003eAs input data, you are given a nObs-by-nAssets matrix\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\u003eportRet\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of return series for assets in a portfolio along with an nAssets-by-1 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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eportWeights\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of portfolio weights. 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[ \u003e\u003e nObs = 504; % Number of observations\\n\\n \u003e\u003e nAssets = 5; % Number of assets in the portfolio\\n\\n \u003e\u003e portRet = randn(nObs, nAssets); % Sample portfolio return series\\n\\n \u003e\u003e portWeights = rand(nAssets, 1); \\n\\n \u003e\u003e portWeights = portWeights/sum(portWeights); % Portfolio weights are \u003e=0 and sum to 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\u003eThe task is to compute the\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\u003eportfolio cokurtosis\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e , which is a scalar statistic associated with the portfolio. A full description of this statistic, along with sample MATLAB code for computing it, can be found here:\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:hyperlink w:docLocation=\\\"http://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/\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\u003eWrite a function that accepts\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\u003eportRet\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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eportWeights\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as input arguments and returns the scalar statistic\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\u003eportCokurt\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as its output. You can use the code at the website above as a starting point, but try to simplify and shorten it in the spirit of Cody.\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:\"arrayfun\"","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:\"arrayfun\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"arrayfun\"","","\"","arrayfun","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fa2d5fc2090\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fa2d5fc1d70\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fa2d600db80\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fa2d5fc2450\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fa2d5fc2270\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fa2d5fc21d0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fa2d5fc2130\u003e":"tag:\"arrayfun\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fa2d5fc2130\u003e":"tag:\"arrayfun\""},"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":"search","password":"J3bGPZzQ7asjJcCk","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:\"arrayfun\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"arrayfun\"","","\"","arrayfun","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fa2d5fc2090\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fa2d5fc1d70\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fa2d600db80\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fa2d5fc2450\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fa2d5fc2270\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fa2d5fc21d0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fa2d5fc2130\u003e":"tag:\"arrayfun\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fa2d5fc2130\u003e":"tag:\"arrayfun\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":44083,"difficulty_rating":"easy-medium"},{"id":1298,"difficulty_rating":"easy-medium"},{"id":1684,"difficulty_rating":"easy-medium"},{"id":47335,"difficulty_rating":"medium"},{"id":3074,"difficulty_rating":"unrated"}]}}