{"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":42447,"title":"Define the operators of  function_handles","description":"Suppose f and g are function_handles, try to define f+g,f-g,f*g and f/g.\r\n     \r\n  e.g. \r\n     if   f = @(x)x and g = @(x)x+1\r\n     then\r\n          f+g = @(x)2*x+1\r\n          f-g = @(x)-1\r\n          f*g = @(x)x*(x+1)\r\n          f/g = @(x)x/(x+1)","description_html":"\u003cp\u003eSuppose f and g are function_handles, try to define f+g,f-g,f*g and f/g.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ee.g. \r\n   if   f = @(x)x and g = @(x)x+1\r\n   then\r\n        f+g = @(x)2*x+1\r\n        f-g = @(x)-1\r\n        f*g = @(x)x*(x+1)\r\n        f/g = @(x)x/(x+1)\r\n\u003c/pre\u003e","function_template":"function y = fho(f,g,type)\r\n  % 'type' define which operation to be performed\r\n  % for simplicity, 1 represents '+', 2 represents '-', 3 represents '*', 4 represents '/'.\r\n  y = x;\r\nend","test_suite":"%%\r\nf = @(x)x;\r\ng = @(x)x+1;\r\ny = fho(f,g,1)\r\ny_correct = 3;\r\nassert(isequal(y(1),y_correct))\r\n\r\n%%\r\nf = @sqrt;\r\ng = @ceil;\r\ny = fho(f,g,2)\r\ny_correct = -2;\r\nassert(isequal(y(4),y_correct))\r\n\r\n%%\r\nf = @nextpow2;\r\ng = @log10;\r\ny = fho(f,g,3)\r\ny_correct = 4;\r\nassert(isequal(y(10),y_correct))\r\n\r\n%%\r\nf = @floor;\r\ng = @ceil;\r\ny = fho(f,g,4)\r\ny_correct = 0.5;\r\nassert(isequal(y(1.25),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":40597,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":58,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-07-05T14:27:43.000Z","updated_at":"2026-03-31T11:28:04.000Z","published_at":"2015-07-05T15:08:46.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\u003eSuppose f and g are function_handles, try to define f+g,f-g,f*g and f/g.\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[e.g. \\n   if   f = @(x)x and g = @(x)x+1\\n   then\\n        f+g = @(x)2*x+1\\n        f-g = @(x)-1\\n        f*g = @(x)x*(x+1)\\n        f/g = @(x)x/(x+1)]]\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":42817,"title":"Pipeline","description":"Do something that makes\r\n\r\nx\u003e f1 \u003e f2 ... \u003e fn\r\n\r\nequal to\r\n\r\nfn(...f2(f1(x))...)\r\n\r\n* x : MATLAB object\r\n* fi: function handle\r\n\r\nExample:\r\n\r\n  \u003e\u003e cos(sin(1))\r\n  ans =\r\n           0.666366745392881\r\n  \u003e\u003e 1 \u003e @sin \u003e @cos\r\n  ans =\r\n           0.666366745392881","description_html":"\u003cp\u003eDo something that makes\u003c/p\u003e\u003cp\u003ex\u0026gt; f1 \u0026gt; f2 ... \u0026gt; fn\u003c/p\u003e\u003cp\u003eequal to\u003c/p\u003e\u003cp\u003efn(...f2(f1(x))...)\u003c/p\u003e\u003cul\u003e\u003cli\u003ex : MATLAB object\u003c/li\u003e\u003cli\u003efi: function handle\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u0026gt;\u0026gt; cos(sin(1))\r\nans =\r\n         0.666366745392881\r\n\u0026gt;\u0026gt; 1 \u0026gt; @sin \u0026gt; @cos\r\nans =\r\n         0.666366745392881\r\n\u003c/pre\u003e","function_template":"function y = foo\r\n  y = x;\r\nend","test_suite":"%%\r\nfoo()\r\n\r\n%%\r\nassert(isequal(cos(sin(1)), 1\u003e@sin\u003e@cos))\r\n\r\n%%\r\nx = rand(10,'single');\r\nassert(isequal(sum(sum(x\u003e.2)), x\u003e.2\u003e@sum\u003e@sum))\r\n\r\n%%\r\na = rand(100);\r\n[x,y] = find(tan(a)\u003e.1);\r\n[x1,y1] = a\u003e @tan \u003e .1 \u003e @find;\r\nassert(isequal({x,y},{x1,y1}))\r\n\r\n%%\r\na = rand(1,100);\r\na\u003e @(x)x.^2+1 \u003e @cos \u003e @sin \u003e @sum \u003e @(x)isequal(x,sum(sin(cos(a.^2+1)))) \u003e @assert\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":1434,"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":"2016-04-22T03:54:50.000Z","updated_at":"2016-04-22T07:19:26.000Z","published_at":"2016-04-22T03:54: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\u003eDo something that makes\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\u003ex\u0026gt; f1 \u0026gt; f2 ... \u0026gt; fn\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\u003eequal to\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\u003efn(...f2(f1(x))...)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ex : MATLAB object\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\u003efi: function handle\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[\u003e\u003e cos(sin(1))\\nans =\\n         0.666366745392881\\n\u003e\u003e 1 \u003e @sin \u003e @cos\\nans =\\n         0.666366745392881]]\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":42248,"title":"Return fibonacci sequence do not use loop and condition version 3","description":"Calculate the nth Fibonacci number,return sequence\r\n\r\nGiven n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ...\r\n\r\nin this time,return a function handle\r\n\r\n f  = fib(n)\r\n\r\ngenerate the sequence from the n-th item\r\n\r\nif n = 3\r\n\r\nfirst call:\r\n\r\n f() = 2\r\n\r\nsecond call\r\n\r\n f() = 3\r\n\r\nthird call\r\n\r\n f() = 5\r\n\r\nif n = 7\r\n\r\nfirst call:\r\n\r\n f() = 13\r\n\r\nsecond call\r\n\r\n f() = 21\r\n\r\nthird call\r\n\r\n f() = 34\r\n\r\nbut, loop and conditional statement is forbidden","description_html":"\u003cp\u003eCalculate the nth Fibonacci number,return sequence\u003c/p\u003e\u003cp\u003eGiven n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ...\u003c/p\u003e\u003cp\u003ein this time,return a function handle\u003c/p\u003e\u003cpre\u003e f  = fib(n)\u003c/pre\u003e\u003cp\u003egenerate the sequence from the n-th item\u003c/p\u003e\u003cp\u003eif n = 3\u003c/p\u003e\u003cp\u003efirst call:\u003c/p\u003e\u003cpre\u003e f() = 2\u003c/pre\u003e\u003cp\u003esecond call\u003c/p\u003e\u003cpre\u003e f() = 3\u003c/pre\u003e\u003cp\u003ethird call\u003c/p\u003e\u003cpre\u003e f() = 5\u003c/pre\u003e\u003cp\u003eif n = 7\u003c/p\u003e\u003cp\u003efirst call:\u003c/p\u003e\u003cpre\u003e f() = 13\u003c/pre\u003e\u003cp\u003esecond call\u003c/p\u003e\u003cpre\u003e f() = 21\u003c/pre\u003e\u003cp\u003ethird call\u003c/p\u003e\u003cpre\u003e f() = 34\u003c/pre\u003e\u003cp\u003ebut, loop and conditional statement is forbidden\u003c/p\u003e","function_template":"function y = fib(x)\r\n  y = x;\r\nend","test_suite":"%%% Clean workspace\r\n% !/bin/cp fib.m safe\r\n% !/bin/rm *.*\r\n% !/bin/mv safe fib.m\r\n\r\n% Clean user's function from some known jailbreaking mechanisms\r\nfunctions={'!','feval','eval','str2func','str2num','regex','system','dos','unix','perl','assert','fopen','write','save','setenv','path','please','for','if','while','switch','global','figure'...\r\n    'round','roundn','fix','ceil','char','floor','\\.','^','pow','\\^','sscanf','persistent'};\r\nfid = fopen('fib.m');\r\n  st = char(fread(fid)');\r\n  for n = 1:numel(functions)\r\n    st = regexprep(st, functions{n}, 'error(''No fancy functions!''); %','ignorecase');\r\n  end\r\n \r\nfclose(fid);\r\nfid = fopen('fib.m' , 'w');\r\n  fwrite(fid,st);\r\nfclose(fid);\r\n\r\n%%\r\nn = 2;\r\nf = fib(n);\r\nassert(isequal(f() + f(),f()));\r\nassert(isequal(f(),5));\r\n\r\n\r\n\r\n%%\r\nn = 7;\r\nf = fib(n);\r\nassert(isequal(f() + f(),f()));\r\nassert(isequal(f() + f(),f()));\r\nassert(isequal(f(),233));\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":3668,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":"2015-04-22T17:14:27.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-04-22T17:05:37.000Z","updated_at":"2015-04-23T12:17:05.000Z","published_at":"2015-04-22T17:05:37.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCalculate the nth Fibonacci number,return sequence\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ...\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ein this time,return a function handle\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[ f  = fib(n)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003egenerate the sequence from the n-th item\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif n = 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\u003efirst call:\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[ f() = 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\u003esecond call\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[ f() = 3]]\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\u003ethird call\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[ f() = 5]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif n = 7\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\u003efirst call:\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[ f() = 13]]\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\u003esecond call\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[ f() = 21]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethird call\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[ f() = 34]]\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\u003ebut, loop and conditional statement is forbidden\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":42588,"title":"Derivative function","description":"Given a function handle f, generate a function that evaluates the derivative of f\r\n\r\n\r\nExamples:\r\n    \r\n   f = @sin;\r\n   df = Derivative(f);\r\n   df([0 pi])\r\n   ans =\r\n        1    -1\r\n\r\nDerivative of sin is cos, cos([0 pi]) = [1 -1]\r\n\r\nHint(Added 2015/9/17):\r\n\u003chttps://en.wikipedia.org/wiki/Numerical_differentiation\u003e","description_html":"\u003cp\u003eGiven a function handle f, generate a function that evaluates the derivative of f\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cpre\u003e   f = @sin;\r\n   df = Derivative(f);\r\n   df([0 pi])\r\n   ans =\r\n        1    -1\u003c/pre\u003e\u003cp\u003eDerivative of sin is cos, cos([0 pi]) = [1 -1]\u003c/p\u003e\u003cp\u003eHint(Added 2015/9/17): \u003ca href = \"https://en.wikipedia.org/wiki/Numerical_differentiation\"\u003ehttps://en.wikipedia.org/wiki/Numerical_differentiation\u003c/a\u003e\u003c/p\u003e","function_template":"function df = Derivative(f)\r\n  df = f;\r\nend","test_suite":"%%\r\nf = @sin;\r\ndf = Derivative(f);\r\nx = 10*rand(10000,1);\r\ndy = cos(x);\r\nassert(max(abs((dy-df(x))./dy))\u003c1e-13)\r\n%% \r\nf = @log;\r\ndf = Derivative(f);\r\nx = exp(500*rand(10000,1));\r\ndy = 1./x;\r\nassert(max(abs((dy-df(x))./dy))\u003c1e-13)\r\n%%\r\nf = @exp;\r\ndf = Derivative(f);\r\nx = 50*(rand(10000,1)-0.5);\r\ndy = exp(x);\r\nassert(max(abs((dy-df(x))./dy))\u003c1e-13)\r\n%%\r\nt = 10*rand;\r\nf = @(x)1./(x+t);\r\ndf = Derivative(f);\r\nx = 100*(rand(10000,1)-0.5); x(x==-t) = 1;\r\ndy = -1./(x+t).^2;\r\nassert(max(abs((dy-df(x))./dy))\u003c1e-13)\r\n%%\r\nt = 10*rand-5;\r\nf = @(x)atan(t*x);\r\ndf = Derivative(f);\r\nx = 100*(rand(10000,1)-0.5);\r\ndy = t./(t^2*x.^2 + 1);\r\nassert(max(abs((dy-df(x))./dy))\u003c1e-13)\r\n%%\r\nfor t = 2:6\r\n    f = @(x)t.^x./(sin(x).^t+cos(x).^t);\r\n    df = Derivative(f);\r\n    x = 3+rand(10000,1);\r\n    dy = (t.^x.*log(t))./(cos(x).^t+sin(x).^t)-...\r\n        (t.^x.*(t.*cos(x).*sin(x).^(t-1)-...\r\n        t.*cos(x).^(t-1).*sin(x)))./(cos(x).^t+sin(x).^t).^2;\r\n    assert(max(abs((dy-df(x))./dy))\u003c1e-13)\r\nend","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":1434,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":"2015-09-08T18:13:33.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-09-07T05:46:00.000Z","updated_at":"2015-09-17T09:10:17.000Z","published_at":"2015-09-07T05:47: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\u003eGiven a function handle f, generate a function that evaluates the derivative of f\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   f = @sin;\\n   df = Derivative(f);\\n   df([0 pi])\\n   ans =\\n        1    -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\u003eDerivative of sin is cos, cos([0 pi]) = [1 -1]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHint(Added 2015/9/17):\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/Numerical_differentiation\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/Numerical_differentiation\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\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":42447,"title":"Define the operators of  function_handles","description":"Suppose f and g are function_handles, try to define f+g,f-g,f*g and f/g.\r\n     \r\n  e.g. \r\n     if   f = @(x)x and g = @(x)x+1\r\n     then\r\n          f+g = @(x)2*x+1\r\n          f-g = @(x)-1\r\n          f*g = @(x)x*(x+1)\r\n          f/g = @(x)x/(x+1)","description_html":"\u003cp\u003eSuppose f and g are function_handles, try to define f+g,f-g,f*g and f/g.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ee.g. \r\n   if   f = @(x)x and g = @(x)x+1\r\n   then\r\n        f+g = @(x)2*x+1\r\n        f-g = @(x)-1\r\n        f*g = @(x)x*(x+1)\r\n        f/g = @(x)x/(x+1)\r\n\u003c/pre\u003e","function_template":"function y = fho(f,g,type)\r\n  % 'type' define which operation to be performed\r\n  % for simplicity, 1 represents '+', 2 represents '-', 3 represents '*', 4 represents '/'.\r\n  y = x;\r\nend","test_suite":"%%\r\nf = @(x)x;\r\ng = @(x)x+1;\r\ny = fho(f,g,1)\r\ny_correct = 3;\r\nassert(isequal(y(1),y_correct))\r\n\r\n%%\r\nf = @sqrt;\r\ng = @ceil;\r\ny = fho(f,g,2)\r\ny_correct = -2;\r\nassert(isequal(y(4),y_correct))\r\n\r\n%%\r\nf = @nextpow2;\r\ng = @log10;\r\ny = fho(f,g,3)\r\ny_correct = 4;\r\nassert(isequal(y(10),y_correct))\r\n\r\n%%\r\nf = @floor;\r\ng = @ceil;\r\ny = fho(f,g,4)\r\ny_correct = 0.5;\r\nassert(isequal(y(1.25),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":40597,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":58,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-07-05T14:27:43.000Z","updated_at":"2026-03-31T11:28:04.000Z","published_at":"2015-07-05T15:08:46.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\u003eSuppose f and g are function_handles, try to define f+g,f-g,f*g and f/g.\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[e.g. \\n   if   f = @(x)x and g = @(x)x+1\\n   then\\n        f+g = @(x)2*x+1\\n        f-g = @(x)-1\\n        f*g = @(x)x*(x+1)\\n        f/g = @(x)x/(x+1)]]\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":42817,"title":"Pipeline","description":"Do something that makes\r\n\r\nx\u003e f1 \u003e f2 ... \u003e fn\r\n\r\nequal to\r\n\r\nfn(...f2(f1(x))...)\r\n\r\n* x : MATLAB object\r\n* fi: function handle\r\n\r\nExample:\r\n\r\n  \u003e\u003e cos(sin(1))\r\n  ans =\r\n           0.666366745392881\r\n  \u003e\u003e 1 \u003e @sin \u003e @cos\r\n  ans =\r\n           0.666366745392881","description_html":"\u003cp\u003eDo something that makes\u003c/p\u003e\u003cp\u003ex\u0026gt; f1 \u0026gt; f2 ... \u0026gt; fn\u003c/p\u003e\u003cp\u003eequal to\u003c/p\u003e\u003cp\u003efn(...f2(f1(x))...)\u003c/p\u003e\u003cul\u003e\u003cli\u003ex : MATLAB object\u003c/li\u003e\u003cli\u003efi: function handle\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u0026gt;\u0026gt; cos(sin(1))\r\nans =\r\n         0.666366745392881\r\n\u0026gt;\u0026gt; 1 \u0026gt; @sin \u0026gt; @cos\r\nans =\r\n         0.666366745392881\r\n\u003c/pre\u003e","function_template":"function y = foo\r\n  y = x;\r\nend","test_suite":"%%\r\nfoo()\r\n\r\n%%\r\nassert(isequal(cos(sin(1)), 1\u003e@sin\u003e@cos))\r\n\r\n%%\r\nx = rand(10,'single');\r\nassert(isequal(sum(sum(x\u003e.2)), x\u003e.2\u003e@sum\u003e@sum))\r\n\r\n%%\r\na = rand(100);\r\n[x,y] = find(tan(a)\u003e.1);\r\n[x1,y1] = a\u003e @tan \u003e .1 \u003e @find;\r\nassert(isequal({x,y},{x1,y1}))\r\n\r\n%%\r\na = rand(1,100);\r\na\u003e @(x)x.^2+1 \u003e @cos \u003e @sin \u003e @sum \u003e @(x)isequal(x,sum(sin(cos(a.^2+1)))) \u003e @assert\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":1434,"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":"2016-04-22T03:54:50.000Z","updated_at":"2016-04-22T07:19:26.000Z","published_at":"2016-04-22T03:54: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\u003eDo something that makes\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\u003ex\u0026gt; f1 \u0026gt; f2 ... \u0026gt; fn\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\u003eequal to\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\u003efn(...f2(f1(x))...)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ex : MATLAB object\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\u003efi: function handle\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[\u003e\u003e cos(sin(1))\\nans =\\n         0.666366745392881\\n\u003e\u003e 1 \u003e @sin \u003e @cos\\nans =\\n         0.666366745392881]]\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":42248,"title":"Return fibonacci sequence do not use loop and condition version 3","description":"Calculate the nth Fibonacci number,return sequence\r\n\r\nGiven n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ...\r\n\r\nin this time,return a function handle\r\n\r\n f  = fib(n)\r\n\r\ngenerate the sequence from the n-th item\r\n\r\nif n = 3\r\n\r\nfirst call:\r\n\r\n f() = 2\r\n\r\nsecond call\r\n\r\n f() = 3\r\n\r\nthird call\r\n\r\n f() = 5\r\n\r\nif n = 7\r\n\r\nfirst call:\r\n\r\n f() = 13\r\n\r\nsecond call\r\n\r\n f() = 21\r\n\r\nthird call\r\n\r\n f() = 34\r\n\r\nbut, loop and conditional statement is forbidden","description_html":"\u003cp\u003eCalculate the nth Fibonacci number,return sequence\u003c/p\u003e\u003cp\u003eGiven n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ...\u003c/p\u003e\u003cp\u003ein this time,return a function handle\u003c/p\u003e\u003cpre\u003e f  = fib(n)\u003c/pre\u003e\u003cp\u003egenerate the sequence from the n-th item\u003c/p\u003e\u003cp\u003eif n = 3\u003c/p\u003e\u003cp\u003efirst call:\u003c/p\u003e\u003cpre\u003e f() = 2\u003c/pre\u003e\u003cp\u003esecond call\u003c/p\u003e\u003cpre\u003e f() = 3\u003c/pre\u003e\u003cp\u003ethird call\u003c/p\u003e\u003cpre\u003e f() = 5\u003c/pre\u003e\u003cp\u003eif n = 7\u003c/p\u003e\u003cp\u003efirst call:\u003c/p\u003e\u003cpre\u003e f() = 13\u003c/pre\u003e\u003cp\u003esecond call\u003c/p\u003e\u003cpre\u003e f() = 21\u003c/pre\u003e\u003cp\u003ethird call\u003c/p\u003e\u003cpre\u003e f() = 34\u003c/pre\u003e\u003cp\u003ebut, loop and conditional statement is forbidden\u003c/p\u003e","function_template":"function y = fib(x)\r\n  y = x;\r\nend","test_suite":"%%% Clean workspace\r\n% !/bin/cp fib.m safe\r\n% !/bin/rm *.*\r\n% !/bin/mv safe fib.m\r\n\r\n% Clean user's function from some known jailbreaking mechanisms\r\nfunctions={'!','feval','eval','str2func','str2num','regex','system','dos','unix','perl','assert','fopen','write','save','setenv','path','please','for','if','while','switch','global','figure'...\r\n    'round','roundn','fix','ceil','char','floor','\\.','^','pow','\\^','sscanf','persistent'};\r\nfid = fopen('fib.m');\r\n  st = char(fread(fid)');\r\n  for n = 1:numel(functions)\r\n    st = regexprep(st, functions{n}, 'error(''No fancy functions!''); %','ignorecase');\r\n  end\r\n \r\nfclose(fid);\r\nfid = fopen('fib.m' , 'w');\r\n  fwrite(fid,st);\r\nfclose(fid);\r\n\r\n%%\r\nn = 2;\r\nf = fib(n);\r\nassert(isequal(f() + f(),f()));\r\nassert(isequal(f(),5));\r\n\r\n\r\n\r\n%%\r\nn = 7;\r\nf = fib(n);\r\nassert(isequal(f() + f(),f()));\r\nassert(isequal(f() + f(),f()));\r\nassert(isequal(f(),233));\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":3668,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":"2015-04-22T17:14:27.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-04-22T17:05:37.000Z","updated_at":"2015-04-23T12:17:05.000Z","published_at":"2015-04-22T17:05:37.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCalculate the nth Fibonacci number,return sequence\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ...\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ein this time,return a function handle\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[ f  = fib(n)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003egenerate the sequence from the n-th item\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif n = 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\u003efirst call:\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[ f() = 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\u003esecond call\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[ f() = 3]]\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\u003ethird call\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[ f() = 5]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif n = 7\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\u003efirst call:\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[ f() = 13]]\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\u003esecond call\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[ f() = 21]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethird call\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[ f() = 34]]\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\u003ebut, loop and conditional statement is forbidden\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":42588,"title":"Derivative function","description":"Given a function handle f, generate a function that evaluates the derivative of f\r\n\r\n\r\nExamples:\r\n    \r\n   f = @sin;\r\n   df = Derivative(f);\r\n   df([0 pi])\r\n   ans =\r\n        1    -1\r\n\r\nDerivative of sin is cos, cos([0 pi]) = [1 -1]\r\n\r\nHint(Added 2015/9/17):\r\n\u003chttps://en.wikipedia.org/wiki/Numerical_differentiation\u003e","description_html":"\u003cp\u003eGiven a function handle f, generate a function that evaluates the derivative of f\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cpre\u003e   f = @sin;\r\n   df = Derivative(f);\r\n   df([0 pi])\r\n   ans =\r\n        1    -1\u003c/pre\u003e\u003cp\u003eDerivative of sin is cos, cos([0 pi]) = [1 -1]\u003c/p\u003e\u003cp\u003eHint(Added 2015/9/17): \u003ca href = \"https://en.wikipedia.org/wiki/Numerical_differentiation\"\u003ehttps://en.wikipedia.org/wiki/Numerical_differentiation\u003c/a\u003e\u003c/p\u003e","function_template":"function df = Derivative(f)\r\n  df = f;\r\nend","test_suite":"%%\r\nf = @sin;\r\ndf = Derivative(f);\r\nx = 10*rand(10000,1);\r\ndy = cos(x);\r\nassert(max(abs((dy-df(x))./dy))\u003c1e-13)\r\n%% \r\nf = @log;\r\ndf = Derivative(f);\r\nx = exp(500*rand(10000,1));\r\ndy = 1./x;\r\nassert(max(abs((dy-df(x))./dy))\u003c1e-13)\r\n%%\r\nf = @exp;\r\ndf = Derivative(f);\r\nx = 50*(rand(10000,1)-0.5);\r\ndy = exp(x);\r\nassert(max(abs((dy-df(x))./dy))\u003c1e-13)\r\n%%\r\nt = 10*rand;\r\nf = @(x)1./(x+t);\r\ndf = Derivative(f);\r\nx = 100*(rand(10000,1)-0.5); x(x==-t) = 1;\r\ndy = -1./(x+t).^2;\r\nassert(max(abs((dy-df(x))./dy))\u003c1e-13)\r\n%%\r\nt = 10*rand-5;\r\nf = @(x)atan(t*x);\r\ndf = Derivative(f);\r\nx = 100*(rand(10000,1)-0.5);\r\ndy = t./(t^2*x.^2 + 1);\r\nassert(max(abs((dy-df(x))./dy))\u003c1e-13)\r\n%%\r\nfor t = 2:6\r\n    f = @(x)t.^x./(sin(x).^t+cos(x).^t);\r\n    df = Derivative(f);\r\n    x = 3+rand(10000,1);\r\n    dy = (t.^x.*log(t))./(cos(x).^t+sin(x).^t)-...\r\n        (t.^x.*(t.*cos(x).*sin(x).^(t-1)-...\r\n        t.*cos(x).^(t-1).*sin(x)))./(cos(x).^t+sin(x).^t).^2;\r\n    assert(max(abs((dy-df(x))./dy))\u003c1e-13)\r\nend","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":1434,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":"2015-09-08T18:13:33.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-09-07T05:46:00.000Z","updated_at":"2015-09-17T09:10:17.000Z","published_at":"2015-09-07T05:47: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\u003eGiven a function handle f, generate a function that evaluates the derivative of f\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   f = @sin;\\n   df = Derivative(f);\\n   df([0 pi])\\n   ans =\\n        1    -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\u003eDerivative of sin is cos, cos([0 pi]) = [1 -1]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHint(Added 2015/9/17):\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/Numerical_differentiation\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://en.wikipedia.org/wiki/Numerical_differentiation\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\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:\"function_handle\"","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:\"function_handle\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"function_handle\"","","\"","function_handle","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f17e8c351e8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f17e8c34e28\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f17e8c33168\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f17e8c36b88\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f17e8c36ae8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f17e8c36048\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f17e8c35fa8\u003e":"tag:\"function_handle\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f17e8c35fa8\u003e":"tag:\"function_handle\""},"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:\"function_handle\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"function_handle\"","","\"","function_handle","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f17e8c351e8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f17e8c34e28\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f17e8c33168\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f17e8c36b88\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f17e8c36ae8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f17e8c36048\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f17e8c35fa8\u003e":"tag:\"function_handle\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f17e8c35fa8\u003e":"tag:\"function_handle\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":42447,"difficulty_rating":"easy"},{"id":42817,"difficulty_rating":"easy-medium"},{"id":42248,"difficulty_rating":"medium"},{"id":42588,"difficulty_rating":"medium-hard"}]}}