{"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":61168,"title":"Find record values in a sequence","description":"Write a function to find the record values in a sequence—that is, the largest values seen since the start. For example, if the sequence is\r\n1, 2, 0, 4, 5, 3, 7, 8, 6, 10, 11, 9, 13, 14, 12, 16\r\nthen the function should return\r\n1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"block-size: 132px; display: block; min-width: 0px; padding-block-start: 0px; padding-inline-start: 2px; padding-left: 2px; padding-top: 0px; perspective-origin: 408px 66px; transform-origin: 408px 66px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to find the record values in a sequence—that is, the largest values seen since the start. For example, if the sequence is\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; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003e1, 2, 0, 4, 5, 3, 7, 8, 6, 10, 11, 9, 13, 14, 12, 16\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; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ethen the function should return\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; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003e1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = records(x)\r\n  y = sort(x,'descending');\r\nend","test_suite":"%%  Example (tersum n+n)\r\nx = [1 2 0 4 5 3 7 8 6 10 11 9 13 14 12 16];\r\ny = records(x);\r\ny_correct = [1 2 4 5 7 8 10 11 13 14 16];\r\nassert(isequal(y,y_correct))\r\n\r\n%%  Prime gaps\r\nx = [1 2 2 4 2 4 2 4 6 2 6 4 2 4 6 6 2 6 4 2 6 4 6 8 4 2 4 2 4 14 4 6 2 10 2 6 6 4 6 6 2 10 2 4 2 12 12 4 2 4 6 2 10 6 6 6 2 6 4 2 10 14 4 2 4 14 6 10 2 4 6 8 6 6 4 6 8 4 8 10 2 10 2 6 4 6 8 4 2 4 12 8 4 8 4 6 12 2 18 6];\r\ny = records(x);\r\ny_correct = [1 2 4 6 8 14 18];\r\nassert(isequal(y,y_correct))\r\n\r\n%%  Numbers of divisors\r\nx = [1 2 2 3 2 4 2 4 3 4 2 6 2 4 4 5 2 6 2 6 4 4 2 8 3 4 4 6 2 8 2 6 4 4 4 9 2 4 4 8 2 8 2 6 6 4 2 10 3 6 4 6 2 8 4 8 4 4 2 12 2 4 6 7 4 8 2 6 4 8 2 12 2 4 6 6 4 8 2 10 5 4 2 12 4 4 4 8 2 12 4 6 4 4 4 12 2 6 6 9];\r\ny = records(x);\r\ny_correct = [1 2 3 4 6 8 9 10 12];\r\nassert(isequal(y,y_correct))\r\n\r\n%%  Length of the period of the continued fraction of (1+sqrt(n))/2\r\nx = [0 2 2 0 1 4 4 4 0 2 2 2 1 4 2 0 3 6 6 4 2 6 4 4 0 2 2 4 1 2 8 4 4 4 2 0 3 6 6 8 5 4 10 6 2 8 4 4 0 2 2 4 1 6 4 2 6 6 6 4 3 4 2 0 3 6 10 6 4 6 8 4 9 6 4 8 2 4 4 4 0 2 2 2 1 6 2 8 7 2 8 8 2 12 4 8 9 4 2 0];\r\ny = records(x);\r\ny_correct = [0 2 4 6 8 10 12];\r\nassert(isequal(y,y_correct))\r\n\r\n%%  Numbers of ways n can be properly factored\r\nx = [0 0 0 1 0 1 0 2 1 1 0 3 0 1 1 4 0 3 0 3 1 1 0 6 1 1 2 3 0 4 0 6 1 1 1 8 0 1 1 6 0 4 0 3 3 1 0 11 1 3 1 3 0 6 1 6 1 1 0 10 0 1 3 10 1 4 0 3 1 4 0 15 0 1 3 3 1 4 0 11 4 1 0 10 1 1 1 6 0 10 1 3 1 1 1 18 0 3 3 8];\r\ny = records(x);\r\ny_correct = [0 1 2 3 4 6 8 11 15 18];   \r\nassert(isequal(y,y_correct))\r\n\r\n%%  Numbers of ways n can be properly factored\r\nx = [1 1 1 2 1 1 1 3 2 1 1 2 1 1 1 4 1 2 1 2 1 1 1 3 2 1 3 2 1 1 1 5 1 1 1 4 1 1 1 3 1 1 1 2 2 1 1 4 2 2 1 2 1 3 1 3 1 1 1 2 1 1 2 6 1 1 1 2 1 1 1 6 1 1 2 2 1 1 1 4 4 1 1 2 1 1 1 3 1 2 1 2 1 1 1 5 1 2 2 4 1 1 1 3 1 1 1 6 1 1 1 4 1 1 1 2 2 1 1 3 2 1 1 2 3 2 1 7 1 1 1 2 1 1 3 3 1 1 1 2 1 1 1 8 1 1 2 2 1 2 1 3 2 1 1 2 1 1 1 5 1 4 1 2 1 1 1 3 2 1 2 2 1 1 2 4 1 1 1 4 1 1 1 3 1 1 1 2 3 1 1 6 1 1 1 4 1 2 1 6];\r\ny = records(x);\r\ny_correct = 1:8;   \r\nassert(isequal(y,y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":46909,"edited_by":46909,"edited_at":"2026-01-20T02:33:49.000Z","deleted_by":null,"deleted_at":null,"solvers_count":18,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2026-01-20T02:33:28.000Z","updated_at":"2026-02-18T21:58:32.000Z","published_at":"2026-01-20T02:33:49.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to find the record values in a sequence—that is, the largest values seen since the start. For example, if the sequence is\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1, 2, 0, 4, 5, 3, 7, 8, 6, 10, 11, 9, 13, 14, 12, 16\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen the function should return\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16\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":44706,"title":"The Deadly Sin","description":"Melvyn and Banner are fighting over chocolates. Melvyn has X chocolates, while Banner has Y. Whoever has a lesser number of chocolates eats as many chocolates as he has from the other's collection. This eatfest war continues till either they have the same number of chocolates, or at least one of them is left with no chocolates.\r\nCan you help Eliza predict the total number of chocolates they'll be left with at the end of their war?\r\n\r\nExample \r\n  \r\n\r\n  Input:\r\nx = [5 3]\r\n\r\n  \r\nExplanation:\r\nDenoting Melvyn as M, Banner as B\r\n\r\nM=5, B=3 - Banner eats 3 chocolates of Melvyn.\r\n\r\nM=2, B=3 - Melvyn eats 2 chocolates of Banner.\r\n\r\nM=2, B=1 - Banner eats 1 chocolate of Melvyn.\r\n\r\nM=1, B=1 - Since they have the same no of candies, they stop quarreling.\r\n\r\nTotal candies left: 2 \r\n\r\n  Output:\r\n  y = 2\r\n","description_html":"\u003cp\u003eMelvyn and Banner are fighting over chocolates. Melvyn has X chocolates, while Banner has Y. Whoever has a lesser number of chocolates eats as many chocolates as he has from the other's collection. This eatfest war continues till either they have the same number of chocolates, or at least one of them is left with no chocolates.\r\nCan you help Eliza predict the total number of chocolates they'll be left with at the end of their war?\u003c/p\u003e\u003cp\u003eExample\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInput:\r\nx = [5 3]\r\n\u003c/pre\u003e\u003cp\u003eExplanation:\r\nDenoting Melvyn as M, Banner as B\u003c/p\u003e\u003cp\u003eM=5, B=3 - Banner eats 3 chocolates of Melvyn.\u003c/p\u003e\u003cp\u003eM=2, B=3 - Melvyn eats 2 chocolates of Banner.\u003c/p\u003e\u003cp\u003eM=2, B=1 - Banner eats 1 chocolate of Melvyn.\u003c/p\u003e\u003cp\u003eM=1, B=1 - Since they have the same no of candies, they stop quarreling.\u003c/p\u003e\u003cp\u003eTotal candies left: 2\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eOutput:\r\ny = 2\r\n\u003c/pre\u003e","function_template":"function y = the_deadly_sin(x)\r\n  % Try to be witty. The problem is not that difficult to figure out.\r\nend","test_suite":"%%\r\nx = [5 3];\r\ny_correct = 2;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n%%\r\nx = [10 10];\r\ny_correct = 20;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n%%\r\nx = [4 8];\r\ny_correct = 8;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n%%\r\nx = [30 12];\r\ny_correct = 12;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n%%\r\nx = [42 91];\r\ny_correct = 14;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n\r\n%%\r\nx = [700 80];\r\ny_correct = 40;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n%%\r\nx = [638 899];\r\ny_correct = 58;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n%%\r\nx = [819 949];\r\ny_correct = 26;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n\r\nx = [500 500];\r\ny_correct = 1000;\r\nassert(isequal(the_deadly_sin(x),y_correct))","published":true,"deleted":false,"likes_count":5,"comments_count":0,"created_by":195572,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":27,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-08-02T23:07:17.000Z","updated_at":"2018-08-02T23:08:40.000Z","published_at":"2018-08-02T23:07:17.000Z","restored_at":"2018-10-10T14:57:50.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"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\u003eMelvyn and Banner are fighting over chocolates. Melvyn has X chocolates, while Banner has Y. Whoever has a lesser number of chocolates eats as many chocolates as he has from the other's collection. This eatfest war continues till either they have the same number of chocolates, or at least one of them is left with no chocolates. Can you help Eliza predict the total number of chocolates they'll be left with at the end of their war?\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[Input:\\nx = [5 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\u003eExplanation: Denoting Melvyn as M, Banner as B\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\u003eM=5, B=3 - Banner eats 3 chocolates of Melvyn.\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\u003eM=2, B=3 - Melvyn eats 2 chocolates of Banner.\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\u003eM=2, B=1 - Banner eats 1 chocolate of Melvyn.\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\u003eM=1, B=1 - Since they have the same no of candies, they stop quarreling.\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\u003eTotal candies left: 2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[Output:\\ny = 2]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2408,"title":"Find the biggest digit in a matrix","description":"Write a function to find the biggest digit in a matrix;\r\n\r\n input -\u003e a matrix\r\n\r\n output -\u003e a digit\r\n\r\nFor example;\r\n\r\n [12; 47; 86; 10; 65; 92]   =  9\r\n [11; 10; 1; 0; 2]  = 2\r\n [11; 10; 1; 0; 22; 20; 12]  = 2","description_html":"\u003cp\u003eWrite a function to find the biggest digit in a matrix;\u003c/p\u003e\u003cpre\u003e input -\u0026gt; a matrix\u003c/pre\u003e\u003cpre\u003e output -\u0026gt; a digit\u003c/pre\u003e\u003cp\u003eFor example;\u003c/p\u003e\u003cpre\u003e [12; 47; 86; 10; 65; 92]   =  9\r\n [11; 10; 1; 0; 2]  = 2\r\n [11; 10; 1; 0; 22; 20; 12]  = 2\u003c/pre\u003e","function_template":"function y = biggest_digit(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [12; 47; 86; 10; 65; 92];\r\ny_correct = 9;\r\nassert(isequal(biggest_digit(x),y_correct))\r\n\r\n%%\r\nx = [11; 10; 1; 0; 2; NaN];\r\ny_correct = 2;\r\nassert(isequal(biggest_digit(x),y_correct))\r\n\r\n%%\r\nx = [11; 10; 1; 0; 22; 20; Inf; 12];\r\ny_correct = 2;\r\nassert(isequal(biggest_digit(x),y_correct))\r\n\r\n%%\r\nx = [145; 8586; 12487811; 456788; 0; 147852214];\r\ny_correct = 8;\r\nassert(isequal(biggest_digit(x),y_correct))\r\n\r\n%%\r\nx = ones(5,5);\r\ny_correct = 1;\r\nassert(isequal(biggest_digit(x),y_correct))\r\n\r\n%%\r\nx = magic(9);\r\ny_correct = 9;\r\nassert(isequal(biggest_digit(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":4,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":57,"test_suite_updated_at":"2014-07-09T09:23:03.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2014-07-08T22:40:42.000Z","updated_at":"2025-09-09T17:21:26.000Z","published_at":"2014-07-08T22:40:41.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\u003eWrite a function to find the biggest digit in a matrix;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ input -\u003e a matrix\\n\\n output -\u003e a digit]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ [12; 47; 86; 10; 65; 92]   =  9\\n [11; 10; 1; 0; 2]  = 2\\n [11; 10; 1; 0; 22; 20; 12]  = 2]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":1865,"title":"MiniMax","description":"Find the smallest value in array, which is the maximum of its row and column.\r\n\r\nExample: in array shown below are two numbers which are max in their rows and columns, 16 and 15. 15 is smaller, so it should be on the output.\r\n\r\n \u003c16\u003e    2     3    13\r\n   5    11    10     8\r\n   9     7     6    12\r\n   4    14   \u003c15\u003e    1","description_html":"\u003cp\u003eFind the smallest value in array, which is the maximum of its row and column.\u003c/p\u003e\u003cp\u003eExample: in array shown below are two numbers which are max in their rows and columns, 16 and 15. 15 is smaller, so it should be on the output.\u003c/p\u003e\u003cpre\u003e \u0026lt;16\u003e    2     3    13\r\n   5    11    10     8\r\n   9     7     6    12\r\n   4    14   \u0026lt;15\u003e    1\u003c/pre\u003e","function_template":"function out = minimax(in)\r\n    out = min(in(:));\r\nend","test_suite":"%%\r\nA = magic(4);\r\ncorrect = 15;\r\nassert(isequal(minimax(A),correct))\r\n\r\n%%\r\nA = magic(5);\r\ncorrect = 21;\r\nassert(isequal(minimax(A),correct))\r\n\r\n%%\r\nA = magic(6);\r\nn = randi(1024);\r\ncorrect = 34;\r\nassert(isequal(minimax(A+n),correct+n))\r\n\r\n%%\r\nA = [1 2 3; 0 4 5; 6 0 0];\r\ncorrect = 5;\r\nassert(isequal(minimax(A),correct))\r\n\r\n%%\r\nA = [1 2 3; 0 4 0; 6 0 5];\r\ncorrect = 4;\r\nassert(isequal(minimax(A),correct))\r\n\r\n%%\r\nA = rand(7)+diag(randperm(7));\r\nassert(isequal(floor(minimax(A)),1))\r\n\r\n%% those may be difficult for some approaches\r\nB = [1 2 1; 0 1 0];\r\ncorrect = 2;\r\nassert(isequal(minimax(B),correct))\r\n\r\n%%\r\nB = magic(6)+magic(6)';\r\ncorrect = 61;\r\nassert(isequal(minimax(B),correct))\r\n\r\n% other test suggestions highly welcome","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":38,"test_suite_updated_at":"2013-09-26T10:12:27.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-08T18:07:41.000Z","updated_at":"2025-09-05T03:14:41.000Z","published_at":"2013-09-13T12:38:27.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the smallest value in array, which is the maximum of its row and column.\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: in array shown below are two numbers which are max in their rows and columns, 16 and 15. 15 is smaller, so it should be on the output.\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[ \u003c16\u003e    2     3    13\\n   5    11    10     8\\n   9     7     6    12\\n   4    14   \u003c15\u003e    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":1273,"title":"Max index of 3D array","description":"Given a three dimensional array  M(m,n,p) write a code that finds the three coordinates x,y,z  of the Maximum value.\r\n\r\nExample : \r\n\r\nThe input is F :\r\n\r\nF=zeros(4,4,4); F(2,2,2)=10;\r\n\r\nThe output is \r\n\r\nb=[2 2 2]  % the coordinates \r\n","description_html":"\u003cp\u003eGiven a three dimensional array  M(m,n,p) write a code that finds the three coordinates x,y,z  of the Maximum value.\u003c/p\u003e\u003cp\u003eExample :\u003c/p\u003e\u003cp\u003eThe input is F :\u003c/p\u003e\u003cp\u003eF=zeros(4,4,4); F(2,2,2)=10;\u003c/p\u003e\u003cp\u003eThe output is\u003c/p\u003e\u003cp\u003eb=[2 2 2]  % the coordinates\u003c/p\u003e","function_template":"function y = Index_Max3d(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = zeros(10,10,10);  x(5,5,5) = 10;\r\ny_correct = [5,5,5];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n\r\n%%\r\nx = randn(10,10,10);  x(7,5,8) = 11;\r\ny_correct = [7,5,8];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n\r\n%%\r\nx = randn(10,10,100);  x(10,5,8) = 99;\r\ny_correct = [10,5,8];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n\r\n%%\r\nx = randn(10,10,10);  x(1,3,7) = 42;\r\ny_correct = [1,3,7];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n\r\n%%\r\nx = randn(10,10,100);  x(4,4,7) = 123456789;\r\ny_correct = [4,4,7];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n\r\n%%\r\nx = randn(10,10,10);  x(1,1,9) = 10701;\r\ny_correct = [1,1,9];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n\r\n%%\r\nx = randn(10,10,100);  x(1,7,3) = 10701;\r\ny_correct = [1,7,3];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":9,"comments_count":1,"created_by":5260,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":435,"test_suite_updated_at":"2016-11-18T03:18:41.000Z","rescore_all_solutions":false,"group_id":13,"created_at":"2013-02-15T03:08:20.000Z","updated_at":"2026-04-02T19:25:53.000Z","published_at":"2013-02-15T03:12:32.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a three dimensional array M(m,n,p) write a code that finds the three coordinates x,y,z of the Maximum 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample :\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe input is 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eF=zeros(4,4,4); F(2,2,2)=10;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe output is\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eb=[2 2 2] % the coordinates\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":54750,"title":"Find the length of stream affected by a spill","description":"When a contaminant is spilled into a stream, one might want to know how much of the stream is affected—e.g., the length over which the concentration exceeds a specified threshold. The concentration  is often computed as a function of time  and distance  from the spill using the advection-dispersion equation:\r\n\r\nwhere  is the mean velocity of the river and  is a dispersion coefficient, which describes spreading by several mechanisms. For an instantaneous spill of mass  mixed over the cross section (with area ) at , the concentration can be shown—using some of the math needed for Cody Problem 51625—to be\r\n\r\nWrite a function to compute the length of stream affected by the spill. In other words, find the position  (say) beyond which the concentration never exceeds a threshold . ","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: 282.7px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 141.35px; transform-origin: 407px 141.35px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 378.317px 8px; transform-origin: 378.317px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWhen a contaminant is spilled into a stream, one might want to know how much of the stream is affected—e.g., the length over which the concentration exceeds a specified threshold. The concentration \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eC\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: 123.675px 8px; transform-origin: 123.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is often computed as a function of time \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003et\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: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and distance \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003ex\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: 168.833px 8px; transform-origin: 168.833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e from the spill using the advection-dispersion equation:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 36.6px; 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 18.3px; text-align: left; transform-origin: 384px 18.3px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"vertical-align:-16px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAP0AAABJCAYAAAD2biCfAAAPb0lEQVR4Xu2d2es+NxXG2z9Ai8tVFREXUFSUoq24ouCORVFxA/lBizuCbVGr9kLcqLig4IreiFoFRRFal4IFFcG6oOBy4UIRvXNB/QP0fNp5ymlIZk4yM+8yk4HD+/2+bzKTPDlPcnJykrn4on51BDoCu0Lg4l3Vtle2I9ARuKiTvitBR2BnCHTS76zBe3U7Ap30XQc6AodF4LH2uCeaXGLyF5OvHvbxF3Xz/tCA9+ftGoFPWe1fYXK7yXMGJH5un1eb/PpQyPSR/lBI9+fsHYG3GQCXDaQHi/uZfNfk8SbfM3nuoQDqpD8U0v05e0fgZwbAy03+7IDA1P/V8P/97fMfhwApSnoKJ3OEctEztZojD7G8jzB5dFLBn9j/Px6+e5193poAdAg8Tv0Zz3e4/XsmRk+x/I8yYW6pizkmpieKSZs/0uTgc85Tb4RM+SL8oO1uyeT93/BdLembeRQhPcrxZpNfDoXDRKHHgvhvN4mSn7nMtSaYM/8y+b675zPtb9+p8KhaEM5QV6qKTEeIct0x5HrZgOWn7fMGk8gogaJcZ0Jb3MeE+STtQAcC+d8wfK+CfcD+eFdVKfeXeC4/ID3t8IQgdLN5FCF9riw8+CaTP5lcMaFwKOo3TB5qAtmvN/ls5qa6Jz/VgBDEapPJcAxB1K8NRB6r5Pvtx3cOCeiw32jiTU1+8vNM/n+BSW502iSYC1Yqyg86jB+ZvL7ACV+kxXjUSnoKI4UbGw08kekgnp1RNF8xnB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x8dD5NtNcJhi1abWFellYdEp5AgtX0Hp92bYO+mboesZOwLniUAn/Xm2Wy91R6AZgU76Zuh6xo7AeSLQSX+e7dZL3RFoRqCTvhm6nrEjcJ4IdNKfZ7v1UncEmhHopG+GrmfsCJwnAp3059luvdQdgWYEOumboesZOwLnicD/AWS5b4YFIT97AAAAAElFTkSuQmCC\" alt=\"dC/dt + U dC/dx = K d^2C/dx^2\" style=\"width: 126.5px; height: 36.5px;\" width=\"126.5\" height=\"36.5\"\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 21.0083px 8px; transform-origin: 21.0083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ewhere \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eU\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: 113.958px 8px; transform-origin: 113.958px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is the mean velocity of the river and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eK\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: 202.158px 8px; transform-origin: 202.158px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is a dispersion coefficient, which describes spreading by several mechanisms. For an instantaneous spill of mass \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eM\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: 125.242px 8px; transform-origin: 125.242px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e mixed over the cross section (with area \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eA\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.05px 8px; transform-origin: 12.05px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e) at \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEkAAAAkCAYAAADFGRdYAA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\" height=\"18\"\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: 59.5083px 8px; transform-origin: 59.5083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, the concentration can be shown—using some of the math needed for \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/51625\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003eCody Problem 51625\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 22.5583px 8px; transform-origin: 22.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e—to be\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 40.1px; 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 20.05px; text-align: left; transform-origin: 384px 20.05px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"vertical-align:-17px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZkAAABQCAYAAADLNQgGAAAYVUlEQVR4Xu1d28t3RRXOfyDNvI6ovJCKIlPDDqBlRUUYaUeJD5JOihCdrJQIO6lpER1MFLzw0JEiyk6QF5WQZRQUBB0uuugqK/sHaj36e3S53LNnzezZe8/ev7VheL/vfWfP4ZnZ86y1Zs2ak54QTyA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3ltj1WBZJPWfC7LHt0ab+EeB3nzvHN9qTIJlH4eECmdsr4Btak2nxkdvFdw5b+xjJaNKEFqLDo2sNhf23E8+2fwwT7WmG8ob6SnwxHnhukFRyvUH/n3CbFhLLOJzZBs8o5WEEGE7rPvn3pFs8g2QeBhMEo2N0YYG8U5K9TpXXBZ9v8mNQUu+UTFoSndfFt6Rs5B0jGUgtV0oaCl4JAuFFTfj7VWbBx7tDNmqY/hA5gDgi31MlWbs32mbzUpNBfTZce2m/95y/2WKwZ5Cib8UIYK04W5K1VhQXFCRTDNmsL3DBSAX3m7XyKHyzCFDTDCeAzQ5hVw3n6f5JZjL2KEimq7GNxgQC1QhQCw6zWTWE8aIgwOjtME03Oc8TJBPzKhDYDwIwMWJ/q+o8w35giJ5UIsAAuXgdZ3qaPEEyTWCMQgKBLhDQi8TWDv11AeCRNwJCCp6mcydI5shnVXR/dwiQaB44LBa762B0aBYEYG6dJSJBkMws4xWFBgKrIkBvwPulFfaO+1UbFpV3iQC8PuExa++fatLYIJkmMEYhgUAgEAgEAkMIBMnEvAgEAoFAIBCYDYEgmdmgjYIDgUAgEAgE/g/n2iirvn2JSwAAAABJRU5ErkJggg==\" alt=\"C = (M/(A sqrt(4 pi K t))) exp(-(x-U t)^2/(4 K t))\" style=\"width: 204.5px; height: 40px;\" width=\"204.5\" height=\"40\"\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 44px; 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 22px; text-align: left; transform-origin: 384px 22px; 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: 313.617px 8px; transform-origin: 313.617px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to compute the length of stream affected by the spill. In other words, find the position \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFUAAAAoCAYAAACPSbZFAAADXElEQVRoQ+1YO89NQRT9vh8g4lGJyqNQESESoVEgNAoJeolHoRKCQuGREBqJV6LQCIJGQlBoKAgFiUThUao8gh/AWjL7Zptz3D0zZ853cfdJVs69d2bvmbtmP2dywp/qDExW1+gKJ5zUHozASXVSe2CgB5VuqU5qZwZWGRo+YPx911XGzVJJ6krgRETcfXw/CrwGPjmpZQzcg9i6IPoc7+Vlatqlxs1ShYXP+DAjfNmG9zUntRsD8yD+TqmYXyOO6i2No6XuAAEXAgkkd0G3M2pKjyOpdPUtgYrjeB8aFal0mTl/yI7MqN+Bl7U315M+HU83Yo27tdcZZqmLsRhdZS3AuMNHnyzHb4WxL3gvS4hNszBnUYU/UVpPcs8v1Pq9eOowpbTOrwDrtreBPMagFcB0gKXIeYCuNDPA4otW/cialDC+E3MuJsyLp+zDD1KjsjZdX6DDFEk9Kb0ZWu114DSQW4rQUuLC29xky4Qz+K3EbXV9uh86TpYsbsmkkqotjBb6AKge4K3Ndhxn6PmodKzG58cddbaKp5JK4R9BA+Mn3f1fezZgw3em4j/kkCquU72tm6LTOYZ1Doa1GL629rVuDqlS39FSFwIlFw+jzP7PsGdWKHxKE13SOaSSqrsQKi6t70aV/UtaUxrAFSC7QkghVWo7Zn3pmUs7kVFlf7r61WBmqa0pK56lJWHCIpWn9RTYA7CEaYur5/D7KaDz5W6Sb5VN4h53BVHW1rsNNWJIRTdYbaTS1fk8AS4BNwCp5+J6dS/GGGP/9vJKt6aWlzFE3QZ4NRjfYEmXqc+EXnAAGDQjMalxzIuzZNzm9ZpFy4yyIRXnA1Yvh4Fv0cy5+L4JkMuWuOOSEKLziRzWb+THpNLdjwAM7A+Vher1aa1rhoxX4qKzGv6HzWGvJcp01yaExlbO2r1RYloxtWQz/5sMDe0NQKvkvYeUkuK1jXDipNomIE1DfFcgya9RXjqpNqnSNCzBVLkz1rlltrLeX9qcVJtUufOQZMRwcDYkNMbT7cA0YHA546TapEptTvd/BbBmvwywmWCFQJLZdQ3adifVJpVVBOtxqYhuBhHGVDY8jcbHSbVJzZ7hpGZTZgs4qTZH2TOc1GzKbAEn1eYoe4aTmk2ZLeCk2hxlz/gJfpacKXO5h08AAAAASUVORK5CYII=\" alt=\"x = L_a\" style=\"width: 42.5px; height: 20px;\" width=\"42.5\" height=\"20\"\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: 44.3417px 8px; transform-origin: 44.3417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e (say) beyond which the concentration never exceeds a threshold \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAAAoCAYAAABzXJ2PAAADxUlEQVRoQ+2Zue9NQRTH/f4Ca6VQWAqJhFgbDQ2hVFiiU1iiFISIQqylwpLQaJDQSIgloaCxhigUllJlKfwBfD8yI+d3f/fOnXnunfdeMpN88+57b+acM985c+bMuRPTSsvKwERWbUXZtEJ4ZicohBfCMzOQWV3x8DEjfL7snWts/qXnd+b7Wj1/EL5nnldf6mZL8OKK8Gfm+1I9w8GXJgMG8XBI3CFsE2YKn4VPTsEGff4UXggYR1vV1+wzycWpdglbhQVmfqhf7Th4YOY/R8+NDpZCOKt3VoBU2iHhlmBXE+NuCitdn4v63JeJmK7V4DAnhL1OMPM6LdgdXO2D8y0MGRJLON58wa0mQrdUFFsdGPFcwBtYlHNdM5FBHs51280BdZuFewG9N/QfOwBP3/i/hEP2dScEstcIbTF5t/pcijA0A3fJKiD7iXMuBi8LOJcXzpi3winh6P8QTrx+agTgtY0HgunnDQjGs2Qq+h/A7vxoyN6uZ7w3pv1Qp51CaCcEb5pV5Xsk7HKMZtcHL0/pnyC6t673JdmfUcRsdndso+8jIbj7QzGcmO0PDDKPWbGax7SfDZ1MISaUJE+1iXC8+5uRluvwq8tzkyelAV+FmNBnZb/UF59dtR5+gxjFmCbC/aHn5fay2jVGV8+MQeeVGv78meP1pY6PtrOJcJ/mIChnOPG5fvQEGjqe1+/Bw6syLpuDNRHOicstkvZKGPfbYtsCWgejb2/ZVRPhv42Fqad12+RG8X+bnfS6o2MIb03mR5HBRJss4b3u6FELKcPKUoYeUqwBrDj1gbbrfKJT1XYfVpZSPTRjb9TJc27y8EEvAb4OsWjABRpWlkKVkzqRb7FpITuScHS8ISvi8kh18d+NO3TTtBcByqzHWkjEO+8I65yS5NUf8oCT0n/E2cCupvoXujz5UvQVS6gbb8u2k+4wIcJtmRU5HJ5Xa4xA8QGBXTGuZPu1tqGU2yY3bFv/ph+88ELisECtv1rcwvH2uwUj4zkjIOuvnLZ6eLXAjoCHwhthurBCoNgTswP8pEb986Aj099DIOuxM3q9PnnLQ/gJ7YBN+v+uMCXDayPck4MXo2iegFLaa+G90FohG3WGa+zD0aj7LxGWCzMEwgteynzb6jQ+PE15cRFL+BhyNlSTecdLdXVK8lAI735dfMZTW3EshHdPuE+pa0vahfDuCfcvbkgHSSgmvUQvhHdPuI/fZHPXhEll4kJ494Tj4cTx2pp8Ibx7woMSC+GF8MwMZFZXPLwQnpmBzOqKhxfCMzOQWd0fvS21Ke8sW2EAAAAASUVORK5CYII=\" alt=\"C = C_t\" style=\"width: 46px; height: 20px;\" width=\"46\" height=\"20\"\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: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function La = affectedReach(U,K,M,A,Ct)\r\n% La = length of affected reach of stream [L]\r\n% U  = mean velocity [L/T]\r\n% K  = dispersion coefficient [L^2/T]\r\n% M  = mass of contaminant [M]\r\n% A  = cross-sectional area (L^2)\r\n% Ct = threshold concentration (M/L^3)\r\n\r\n  La = M/(Ct*A);\r\nend","test_suite":"%%\r\nM = 100;                    %  Mass (kg)\r\nA = 30;                     %  Cross-sectional area (m2)\r\nU = 0.3;                    %  Mean velocity (m/s)\r\nK = 2;                      %  Dispersion coefficient (m2/s)\r\nCt = 0.01;                  %  Target concentration (kg/m3)\r\nLa_correct = 1329.62;       %  Length of affected reach (m)\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_correct)\u003c1e-2)\r\n\r\n%%\r\nM = 50;                     %  Mass (kg)\r\nA = 15;                     %  Cross-sectional area (m2)\r\nU = 0.25;                   %  Mean velocity (m/s)\r\nK = 8.4;                    %  Dispersion coefficient (m2/s)\r\nCt = 0.001;                 %  Target concentration (kg/m3)\r\nLa_correct = 26332.1;       %  Length of affected reach (m)\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_correct)\u003c1e-2)\r\n\r\n%%\r\nM = 15;                     %  Mass (kg)\r\nA = 25;                     %  Cross-sectional area (m2)\r\nU = 0.25;                   %  Mean velocity (m/s)\r\nK = 11;                     %  Dispersion coefficient (m2/s)\r\nCt = 0.003;                 %  Target concentration (kg/m3)\r\nLa_correct = 91.59;         %  Length of affected reach (m)\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_correct)\u003c1e-2)\r\n\r\n%%\r\nM = 15;                     %  Mass (kg)\r\nA = 25;                     %  Cross-sectional area (m2)\r\nU = 0.25;                   %  Mean velocity (m/s)\r\nK = 11;                     %  Dispersion coefficient (m2/s)\r\nCt = 3e-4;                  %  Target concentration (kg/m3)\r\nLa_correct = 7256.28;       %  Length of affected reach (m)\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_correct)\u003c1e-2)\r\n\r\n%%\r\nM = 70;                     %  Mass (kg)\r\nA = 21;                     %  Cross-sectional area (m2)\r\nU = 0.15;                   %  Mean velocity (m/s)\r\nK = 1;                      %  Dispersion coefficient (m2/s)\r\nCt = 0.01;                  %  Target concentration (kg/m3)\r\nLa_correct = 1329.62;       %  Length of affected reach (m)\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_correct)\u003c1e-2)\r\n\r\n%%\r\nM = 280;                    %  Mass (kg)\r\nA = 21;                     %  Cross-sectional area (m2)\r\nU = 0.54;                   %  Mean velocity (m/s)\r\nK = 3.7;                    %  Dispersion coefficient (m2/s)\r\nCt = 0.007;                 %  Target concentration (kg/m3)\r\nLa_correct = 42140.42;      %  Length of affected reach (m)\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_correct)\u003c1e-2)\r\n\r\n%% Approximately plug flow\r\nM = 5*rand;                 %  Mass (kg)\r\nA = 40;                     %  Cross-sectional area (m2)\r\nU = 0.3*(1+rand);           %  Mean velocity (m/s)\r\nK = rand*1e-3;              %  Dispersion coefficient (m2/s)\r\nCt = 0.02*rand;             %  Target concentration (kg/m3)\r\nLa_approx = (U/(4*pi*K))*(M/(Ct*A))^2;\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_approx)/La_approx\u003c1e-3)\r\n\r\n%%\r\nfiletext = fileread('affectedReach.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || contains(filetext,'switch') || contains(filetext,'regexp') || contains(filetext,'if'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":46909,"edited_by":46909,"edited_at":"2022-06-14T05:04:44.000Z","deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":"2022-06-14T05:04:44.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2022-06-14T04:57:20.000Z","updated_at":"2022-06-14T05:04:44.000Z","published_at":"2022-06-14T04:59:16.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWhen a contaminant is spilled into a stream, one might want to know how much of the stream is affected—e.g., the length over which the concentration exceeds a specified threshold. The concentration \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"C\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eC\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e is often computed as a function of time \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"t\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003et\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e and distance \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"x\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003ex\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e from the spill using the advection-dispersion equation:\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:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"true\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"dC/dt + U dC/dx = K d^2C/dx^2\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\frac{\\\\partial C}{\\\\partial t} + U \\\\frac{\\\\partial C}{\\\\partial x} = K \\\\frac{\\\\partial^2 C}{\\\\partial x^2}\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\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\u003ewhere \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"U\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eU\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e is the mean velocity of the river and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"K\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eK\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e is a dispersion coefficient, which describes spreading by several mechanisms. For an instantaneous spill of mass \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"M\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eM\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e mixed over the cross section (with area \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"A\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eA\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e) at \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"x = 0\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003ex = 0\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e, the concentration can be shown—using some of the math needed for \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/51625\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCody Problem 51625\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e—to be\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:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"true\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"C = (M/(A sqrt(4 pi K t))) exp(-(x-U t)^2/(4 K t))\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eC = \\\\frac{M}{A\\\\sqrt{4\\\\pi K t}} \\\\exp\\\\left(-\\\\frac{(x-U t)^2}{4 K t}\\\\right)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\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\u003eWrite a function to compute the length of stream affected by the spill. In other words, find the position \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"x = L_a\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003ex = L_a\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e (say) beyond which the concentration never exceeds a threshold \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"C = C_t\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eC = C_t\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":61168,"title":"Find record values in a sequence","description":"Write a function to find the record values in a sequence—that is, the largest values seen since the start. For example, if the sequence is\r\n1, 2, 0, 4, 5, 3, 7, 8, 6, 10, 11, 9, 13, 14, 12, 16\r\nthen the function should return\r\n1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"block-size: 132px; display: block; min-width: 0px; padding-block-start: 0px; padding-inline-start: 2px; padding-left: 2px; padding-top: 0px; perspective-origin: 408px 66px; transform-origin: 408px 66px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to find the record values in a sequence—that is, the largest values seen since the start. For example, if the sequence is\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; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003e1, 2, 0, 4, 5, 3, 7, 8, 6, 10, 11, 9, 13, 14, 12, 16\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; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ethen the function should return\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; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003e1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = records(x)\r\n  y = sort(x,'descending');\r\nend","test_suite":"%%  Example (tersum n+n)\r\nx = [1 2 0 4 5 3 7 8 6 10 11 9 13 14 12 16];\r\ny = records(x);\r\ny_correct = [1 2 4 5 7 8 10 11 13 14 16];\r\nassert(isequal(y,y_correct))\r\n\r\n%%  Prime gaps\r\nx = [1 2 2 4 2 4 2 4 6 2 6 4 2 4 6 6 2 6 4 2 6 4 6 8 4 2 4 2 4 14 4 6 2 10 2 6 6 4 6 6 2 10 2 4 2 12 12 4 2 4 6 2 10 6 6 6 2 6 4 2 10 14 4 2 4 14 6 10 2 4 6 8 6 6 4 6 8 4 8 10 2 10 2 6 4 6 8 4 2 4 12 8 4 8 4 6 12 2 18 6];\r\ny = records(x);\r\ny_correct = [1 2 4 6 8 14 18];\r\nassert(isequal(y,y_correct))\r\n\r\n%%  Numbers of divisors\r\nx = [1 2 2 3 2 4 2 4 3 4 2 6 2 4 4 5 2 6 2 6 4 4 2 8 3 4 4 6 2 8 2 6 4 4 4 9 2 4 4 8 2 8 2 6 6 4 2 10 3 6 4 6 2 8 4 8 4 4 2 12 2 4 6 7 4 8 2 6 4 8 2 12 2 4 6 6 4 8 2 10 5 4 2 12 4 4 4 8 2 12 4 6 4 4 4 12 2 6 6 9];\r\ny = records(x);\r\ny_correct = [1 2 3 4 6 8 9 10 12];\r\nassert(isequal(y,y_correct))\r\n\r\n%%  Length of the period of the continued fraction of (1+sqrt(n))/2\r\nx = [0 2 2 0 1 4 4 4 0 2 2 2 1 4 2 0 3 6 6 4 2 6 4 4 0 2 2 4 1 2 8 4 4 4 2 0 3 6 6 8 5 4 10 6 2 8 4 4 0 2 2 4 1 6 4 2 6 6 6 4 3 4 2 0 3 6 10 6 4 6 8 4 9 6 4 8 2 4 4 4 0 2 2 2 1 6 2 8 7 2 8 8 2 12 4 8 9 4 2 0];\r\ny = records(x);\r\ny_correct = [0 2 4 6 8 10 12];\r\nassert(isequal(y,y_correct))\r\n\r\n%%  Numbers of ways n can be properly factored\r\nx = [0 0 0 1 0 1 0 2 1 1 0 3 0 1 1 4 0 3 0 3 1 1 0 6 1 1 2 3 0 4 0 6 1 1 1 8 0 1 1 6 0 4 0 3 3 1 0 11 1 3 1 3 0 6 1 6 1 1 0 10 0 1 3 10 1 4 0 3 1 4 0 15 0 1 3 3 1 4 0 11 4 1 0 10 1 1 1 6 0 10 1 3 1 1 1 18 0 3 3 8];\r\ny = records(x);\r\ny_correct = [0 1 2 3 4 6 8 11 15 18];   \r\nassert(isequal(y,y_correct))\r\n\r\n%%  Numbers of ways n can be properly factored\r\nx = [1 1 1 2 1 1 1 3 2 1 1 2 1 1 1 4 1 2 1 2 1 1 1 3 2 1 3 2 1 1 1 5 1 1 1 4 1 1 1 3 1 1 1 2 2 1 1 4 2 2 1 2 1 3 1 3 1 1 1 2 1 1 2 6 1 1 1 2 1 1 1 6 1 1 2 2 1 1 1 4 4 1 1 2 1 1 1 3 1 2 1 2 1 1 1 5 1 2 2 4 1 1 1 3 1 1 1 6 1 1 1 4 1 1 1 2 2 1 1 3 2 1 1 2 3 2 1 7 1 1 1 2 1 1 3 3 1 1 1 2 1 1 1 8 1 1 2 2 1 2 1 3 2 1 1 2 1 1 1 5 1 4 1 2 1 1 1 3 2 1 2 2 1 1 2 4 1 1 1 4 1 1 1 3 1 1 1 2 3 1 1 6 1 1 1 4 1 2 1 6];\r\ny = records(x);\r\ny_correct = 1:8;   \r\nassert(isequal(y,y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":46909,"edited_by":46909,"edited_at":"2026-01-20T02:33:49.000Z","deleted_by":null,"deleted_at":null,"solvers_count":18,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2026-01-20T02:33:28.000Z","updated_at":"2026-02-18T21:58:32.000Z","published_at":"2026-01-20T02:33:49.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to find the record values in a sequence—that is, the largest values seen since the start. For example, if the sequence is\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1, 2, 0, 4, 5, 3, 7, 8, 6, 10, 11, 9, 13, 14, 12, 16\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen the function should return\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16\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":44706,"title":"The Deadly Sin","description":"Melvyn and Banner are fighting over chocolates. Melvyn has X chocolates, while Banner has Y. Whoever has a lesser number of chocolates eats as many chocolates as he has from the other's collection. This eatfest war continues till either they have the same number of chocolates, or at least one of them is left with no chocolates.\r\nCan you help Eliza predict the total number of chocolates they'll be left with at the end of their war?\r\n\r\nExample \r\n  \r\n\r\n  Input:\r\nx = [5 3]\r\n\r\n  \r\nExplanation:\r\nDenoting Melvyn as M, Banner as B\r\n\r\nM=5, B=3 - Banner eats 3 chocolates of Melvyn.\r\n\r\nM=2, B=3 - Melvyn eats 2 chocolates of Banner.\r\n\r\nM=2, B=1 - Banner eats 1 chocolate of Melvyn.\r\n\r\nM=1, B=1 - Since they have the same no of candies, they stop quarreling.\r\n\r\nTotal candies left: 2 \r\n\r\n  Output:\r\n  y = 2\r\n","description_html":"\u003cp\u003eMelvyn and Banner are fighting over chocolates. Melvyn has X chocolates, while Banner has Y. Whoever has a lesser number of chocolates eats as many chocolates as he has from the other's collection. This eatfest war continues till either they have the same number of chocolates, or at least one of them is left with no chocolates.\r\nCan you help Eliza predict the total number of chocolates they'll be left with at the end of their war?\u003c/p\u003e\u003cp\u003eExample\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInput:\r\nx = [5 3]\r\n\u003c/pre\u003e\u003cp\u003eExplanation:\r\nDenoting Melvyn as M, Banner as B\u003c/p\u003e\u003cp\u003eM=5, B=3 - Banner eats 3 chocolates of Melvyn.\u003c/p\u003e\u003cp\u003eM=2, B=3 - Melvyn eats 2 chocolates of Banner.\u003c/p\u003e\u003cp\u003eM=2, B=1 - Banner eats 1 chocolate of Melvyn.\u003c/p\u003e\u003cp\u003eM=1, B=1 - Since they have the same no of candies, they stop quarreling.\u003c/p\u003e\u003cp\u003eTotal candies left: 2\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eOutput:\r\ny = 2\r\n\u003c/pre\u003e","function_template":"function y = the_deadly_sin(x)\r\n  % Try to be witty. The problem is not that difficult to figure out.\r\nend","test_suite":"%%\r\nx = [5 3];\r\ny_correct = 2;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n%%\r\nx = [10 10];\r\ny_correct = 20;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n%%\r\nx = [4 8];\r\ny_correct = 8;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n%%\r\nx = [30 12];\r\ny_correct = 12;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n%%\r\nx = [42 91];\r\ny_correct = 14;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n\r\n%%\r\nx = [700 80];\r\ny_correct = 40;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n%%\r\nx = [638 899];\r\ny_correct = 58;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n%%\r\nx = [819 949];\r\ny_correct = 26;\r\nassert(isequal(the_deadly_sin(x),y_correct))\r\n\r\n\r\nx = [500 500];\r\ny_correct = 1000;\r\nassert(isequal(the_deadly_sin(x),y_correct))","published":true,"deleted":false,"likes_count":5,"comments_count":0,"created_by":195572,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":27,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-08-02T23:07:17.000Z","updated_at":"2018-08-02T23:08:40.000Z","published_at":"2018-08-02T23:07:17.000Z","restored_at":"2018-10-10T14:57:50.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"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\u003eMelvyn and Banner are fighting over chocolates. Melvyn has X chocolates, while Banner has Y. Whoever has a lesser number of chocolates eats as many chocolates as he has from the other's collection. This eatfest war continues till either they have the same number of chocolates, or at least one of them is left with no chocolates. Can you help Eliza predict the total number of chocolates they'll be left with at the end of their war?\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[Input:\\nx = [5 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\u003eExplanation: Denoting Melvyn as M, Banner as B\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\u003eM=5, B=3 - Banner eats 3 chocolates of Melvyn.\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\u003eM=2, B=3 - Melvyn eats 2 chocolates of Banner.\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\u003eM=2, B=1 - Banner eats 1 chocolate of Melvyn.\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\u003eM=1, B=1 - Since they have the same no of candies, they stop quarreling.\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\u003eTotal candies left: 2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[Output:\\ny = 2]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2408,"title":"Find the biggest digit in a matrix","description":"Write a function to find the biggest digit in a matrix;\r\n\r\n input -\u003e a matrix\r\n\r\n output -\u003e a digit\r\n\r\nFor example;\r\n\r\n [12; 47; 86; 10; 65; 92]   =  9\r\n [11; 10; 1; 0; 2]  = 2\r\n [11; 10; 1; 0; 22; 20; 12]  = 2","description_html":"\u003cp\u003eWrite a function to find the biggest digit in a matrix;\u003c/p\u003e\u003cpre\u003e input -\u0026gt; a matrix\u003c/pre\u003e\u003cpre\u003e output -\u0026gt; a digit\u003c/pre\u003e\u003cp\u003eFor example;\u003c/p\u003e\u003cpre\u003e [12; 47; 86; 10; 65; 92]   =  9\r\n [11; 10; 1; 0; 2]  = 2\r\n [11; 10; 1; 0; 22; 20; 12]  = 2\u003c/pre\u003e","function_template":"function y = biggest_digit(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [12; 47; 86; 10; 65; 92];\r\ny_correct = 9;\r\nassert(isequal(biggest_digit(x),y_correct))\r\n\r\n%%\r\nx = [11; 10; 1; 0; 2; NaN];\r\ny_correct = 2;\r\nassert(isequal(biggest_digit(x),y_correct))\r\n\r\n%%\r\nx = [11; 10; 1; 0; 22; 20; Inf; 12];\r\ny_correct = 2;\r\nassert(isequal(biggest_digit(x),y_correct))\r\n\r\n%%\r\nx = [145; 8586; 12487811; 456788; 0; 147852214];\r\ny_correct = 8;\r\nassert(isequal(biggest_digit(x),y_correct))\r\n\r\n%%\r\nx = ones(5,5);\r\ny_correct = 1;\r\nassert(isequal(biggest_digit(x),y_correct))\r\n\r\n%%\r\nx = magic(9);\r\ny_correct = 9;\r\nassert(isequal(biggest_digit(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":4,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":57,"test_suite_updated_at":"2014-07-09T09:23:03.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2014-07-08T22:40:42.000Z","updated_at":"2025-09-09T17:21:26.000Z","published_at":"2014-07-08T22:40:41.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\u003eWrite a function to find the biggest digit in a matrix;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ input -\u003e a matrix\\n\\n output -\u003e a digit]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ [12; 47; 86; 10; 65; 92]   =  9\\n [11; 10; 1; 0; 2]  = 2\\n [11; 10; 1; 0; 22; 20; 12]  = 2]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":1865,"title":"MiniMax","description":"Find the smallest value in array, which is the maximum of its row and column.\r\n\r\nExample: in array shown below are two numbers which are max in their rows and columns, 16 and 15. 15 is smaller, so it should be on the output.\r\n\r\n \u003c16\u003e    2     3    13\r\n   5    11    10     8\r\n   9     7     6    12\r\n   4    14   \u003c15\u003e    1","description_html":"\u003cp\u003eFind the smallest value in array, which is the maximum of its row and column.\u003c/p\u003e\u003cp\u003eExample: in array shown below are two numbers which are max in their rows and columns, 16 and 15. 15 is smaller, so it should be on the output.\u003c/p\u003e\u003cpre\u003e \u0026lt;16\u003e    2     3    13\r\n   5    11    10     8\r\n   9     7     6    12\r\n   4    14   \u0026lt;15\u003e    1\u003c/pre\u003e","function_template":"function out = minimax(in)\r\n    out = min(in(:));\r\nend","test_suite":"%%\r\nA = magic(4);\r\ncorrect = 15;\r\nassert(isequal(minimax(A),correct))\r\n\r\n%%\r\nA = magic(5);\r\ncorrect = 21;\r\nassert(isequal(minimax(A),correct))\r\n\r\n%%\r\nA = magic(6);\r\nn = randi(1024);\r\ncorrect = 34;\r\nassert(isequal(minimax(A+n),correct+n))\r\n\r\n%%\r\nA = [1 2 3; 0 4 5; 6 0 0];\r\ncorrect = 5;\r\nassert(isequal(minimax(A),correct))\r\n\r\n%%\r\nA = [1 2 3; 0 4 0; 6 0 5];\r\ncorrect = 4;\r\nassert(isequal(minimax(A),correct))\r\n\r\n%%\r\nA = rand(7)+diag(randperm(7));\r\nassert(isequal(floor(minimax(A)),1))\r\n\r\n%% those may be difficult for some approaches\r\nB = [1 2 1; 0 1 0];\r\ncorrect = 2;\r\nassert(isequal(minimax(B),correct))\r\n\r\n%%\r\nB = magic(6)+magic(6)';\r\ncorrect = 61;\r\nassert(isequal(minimax(B),correct))\r\n\r\n% other test suggestions highly welcome","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":38,"test_suite_updated_at":"2013-09-26T10:12:27.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-08T18:07:41.000Z","updated_at":"2025-09-05T03:14:41.000Z","published_at":"2013-09-13T12:38:27.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the smallest value in array, which is the maximum of its row and column.\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: in array shown below are two numbers which are max in their rows and columns, 16 and 15. 15 is smaller, so it should be on the output.\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[ \u003c16\u003e    2     3    13\\n   5    11    10     8\\n   9     7     6    12\\n   4    14   \u003c15\u003e    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":1273,"title":"Max index of 3D array","description":"Given a three dimensional array  M(m,n,p) write a code that finds the three coordinates x,y,z  of the Maximum value.\r\n\r\nExample : \r\n\r\nThe input is F :\r\n\r\nF=zeros(4,4,4); F(2,2,2)=10;\r\n\r\nThe output is \r\n\r\nb=[2 2 2]  % the coordinates \r\n","description_html":"\u003cp\u003eGiven a three dimensional array  M(m,n,p) write a code that finds the three coordinates x,y,z  of the Maximum value.\u003c/p\u003e\u003cp\u003eExample :\u003c/p\u003e\u003cp\u003eThe input is F :\u003c/p\u003e\u003cp\u003eF=zeros(4,4,4); F(2,2,2)=10;\u003c/p\u003e\u003cp\u003eThe output is\u003c/p\u003e\u003cp\u003eb=[2 2 2]  % the coordinates\u003c/p\u003e","function_template":"function y = Index_Max3d(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = zeros(10,10,10);  x(5,5,5) = 10;\r\ny_correct = [5,5,5];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n\r\n%%\r\nx = randn(10,10,10);  x(7,5,8) = 11;\r\ny_correct = [7,5,8];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n\r\n%%\r\nx = randn(10,10,100);  x(10,5,8) = 99;\r\ny_correct = [10,5,8];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n\r\n%%\r\nx = randn(10,10,10);  x(1,3,7) = 42;\r\ny_correct = [1,3,7];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n\r\n%%\r\nx = randn(10,10,100);  x(4,4,7) = 123456789;\r\ny_correct = [4,4,7];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n\r\n%%\r\nx = randn(10,10,10);  x(1,1,9) = 10701;\r\ny_correct = [1,1,9];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n\r\n%%\r\nx = randn(10,10,100);  x(1,7,3) = 10701;\r\ny_correct = [1,7,3];\r\nassert(isequal(Index_Max3d(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":9,"comments_count":1,"created_by":5260,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":435,"test_suite_updated_at":"2016-11-18T03:18:41.000Z","rescore_all_solutions":false,"group_id":13,"created_at":"2013-02-15T03:08:20.000Z","updated_at":"2026-04-02T19:25:53.000Z","published_at":"2013-02-15T03:12:32.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a three dimensional array M(m,n,p) write a code that finds the three coordinates x,y,z of the Maximum 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample :\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe input is 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eF=zeros(4,4,4); F(2,2,2)=10;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe output is\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eb=[2 2 2] % the coordinates\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":54750,"title":"Find the length of stream affected by a spill","description":"When a contaminant is spilled into a stream, one might want to know how much of the stream is affected—e.g., the length over which the concentration exceeds a specified threshold. The concentration  is often computed as a function of time  and distance  from the spill using the advection-dispersion equation:\r\n\r\nwhere  is the mean velocity of the river and  is a dispersion coefficient, which describes spreading by several mechanisms. For an instantaneous spill of mass  mixed over the cross section (with area ) at , the concentration can be shown—using some of the math needed for Cody Problem 51625—to be\r\n\r\nWrite a function to compute the length of stream affected by the spill. In other words, find the position  (say) beyond which the concentration never exceeds a threshold . ","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: 282.7px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 141.35px; transform-origin: 407px 141.35px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 378.317px 8px; transform-origin: 378.317px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWhen a contaminant is spilled into a stream, one might want to know how much of the stream is affected—e.g., the length over which the concentration exceeds a specified threshold. The concentration \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eC\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: 123.675px 8px; transform-origin: 123.675px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is often computed as a function of time \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003et\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: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and distance \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003ex\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: 168.833px 8px; transform-origin: 168.833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e from the spill using the advection-dispersion equation:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 36.6px; 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 18.3px; text-align: left; transform-origin: 384px 18.3px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"vertical-align:-16px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAP0AAABJCAYAAAD2biCfAAAPb0lEQVR4Xu2d2es+NxXG2z9Ai8tVFREXUFSUoq24ouCORVFxA/lBizuCbVGr9kLcqLig4IreiFoFRRFal4IFFcG6oOBy4UIRvXNB/QP0fNp5ymlIZk4yM+8yk4HD+/2+bzKTPDlPcnJykrn4on51BDoCu0Lg4l3Vtle2I9ARuKiTvitBR2BnCHTS76zBe3U7Ap30XQc6AodF4LH2uCeaXGLyF5OvHvbxF3Xz/tCA9+ftGoFPWe1fYXK7yXMGJH5un1eb/PpQyPSR/lBI9+fsHYG3GQCXDaQHi/uZfNfk8SbfM3nuoQDqpD8U0v05e0fgZwbAy03+7IDA1P/V8P/97fMfhwApSnoKJ3OEctEztZojD7G8jzB5dFLBn9j/Px6+e5193po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WCv2eJW5WDriHlwK5vCmJLoA4V9k0pfv4trjSZ97ZdbYlDfXIXNqrdbrV5kK15KeCjBX59IyD+bNx4b/GeFzCiMnBvMZwnGZA/VRPq5YpGzB3kdAgj3LOd4b7M1OfiPN4t7iumqeXWqZ4yWHqHeY5uJaVGE6j8sG/lxjn3rbrjgKz1iumx00VUt6Cogi3WiiA/noBFCYL5qUAgI0ogDM9SZfN+nmY71+12JPR6E9D4wadLSKjtTT1SGXfq8v5b5y+JE85ZPvEMDeW7bku9SE4DadeacO13fGTIch++eX6pBbSL+vJu217QhMI6BBTUE3THevGgZH7U1Jp7Ly+DMQcnkrIA2eIu2FoYOYLs1Eik762RD2G3QE7kTAx8dD5NtNcJhi1abWFellYdEp5AgtX0Hp92bYO+mboesZOwLniUAn/Xm2Wy91R6AZgU76Zuh6xo7AeSLQSX+e7dZL3RFoRqCTvhm6nrEjcJ4IdNKfZ7v1UncEmhHopG+GrmfsCJwnAp3059luvdQdgWYEOumboesZOwLnicD/AWS5b4YFIT97AAAAAElFTkSuQmCC\" alt=\"dC/dt + U dC/dx = K d^2C/dx^2\" style=\"width: 126.5px; height: 36.5px;\" width=\"126.5\" height=\"36.5\"\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 21.0083px 8px; transform-origin: 21.0083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ewhere \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eU\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: 113.958px 8px; transform-origin: 113.958px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is the mean velocity of the river and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eK\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: 202.158px 8px; transform-origin: 202.158px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is a dispersion coefficient, which describes spreading by several mechanisms. For an instantaneous spill of mass \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eM\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: 125.242px 8px; transform-origin: 125.242px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e mixed over the cross section (with area \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eA\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.05px 8px; transform-origin: 12.05px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e) at \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEkAAAAkCAYAAADFGRdYAAAC7UlEQVRoQ+2YPU8VQRSG4ReI2lkRPwoqKDQ0WmgBJLYmQPwBaENFTNBSMdFAQ4GY2KsBWiOaSIGFBEK0svCjtFMw/AB9X3MmOTs7s3Puyl1IdjY52Xt3vs48886Zs9vbk68kgd5kjVyhJ0MyiCBDypAMBAxVspIypCiBsyg5I6XvU5zapqQJAHkA24HtwvphfDYLW4X9DAFrE6QlALgNewi7p2BM4fcybB12MwSqLZAciG+AMBwA8RrPRgMA/7FsA6TTmOcX2MkYBNlyz0VdQ7h/0tuuDZCcijjv67BXgbjDQE6V8fK3YyuUtI2JXxQA53D/HoDER79EbYR1vo6S3JH5ObCfL+PZgS/RiCNH8fiPDLqH+6kKB1xcYpUCzKrtNojKlOqINPKlyPI1KaMDXK3YKjnfGB8GDoHUD8NYHIY+fqwBqbAtqyBRPb9FOV8FhjsdTuA/c40nsHFZoapVclyous1DgHQLfTw19KPH60RJhf6tgfsOHHokTlGKL2ELsBcGR3UVrqzrp8OmheqL+BcKwH6fGhJ9ZuIYu/Qca0HSg1FBb2A6IfufCXezrfabyeJYxWBzKLsr5bUgsa01AHZz0p323eh2o3Mu+lNJlzr19gjrWxdXn26FhNIakzhHxh8GaQbAC7Dgy2ACRtOnG91xh441cJdOaisknbVy4FjmmhJM06cb/XEvtvxdeuVQDjvFlXaKBZLLNXiqRVP3FB0pb/p047B6YSZlR/ju6nyqlF6kIHF7bMGmYTxyQ3GJKzUPSyWSRo5dqeb8jp1w7mQLfiUIQeLW4vUB9gy2Anssz/x8aQbPuYePezrAxJjbiF8C/C2nvxJcQXnpS6UPyY8ZfgKmZUluqQStK7Ko2Sl935C2V3Hn5xDC4xz4ShWNsz4kUr0vjd8pBWm/qKZrsFh5zTk00ozzuwEjpD7YvoB7i3s0XKRiUiOeH/dBMiTDCmVIGZKBgKFKVlKGZCBgqJKVlCEZCBiqZCUZIP0F1sSXJS9IuzgAAAAASUVORK5CYII=\" alt=\"x = 0\" style=\"width: 36.5px; height: 18px;\" width=\"36.5\" height=\"18\"\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: 59.5083px 8px; transform-origin: 59.5083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, the concentration can be shown—using some of the math needed for \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/51625\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003eCody Problem 51625\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 22.5583px 8px; transform-origin: 22.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e—to be\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 40.1px; 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 20.05px; text-align: left; transform-origin: 384px 20.05px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"vertical-align:-17px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZkAAABQCAYAAADLNQgGAAAYVUlEQVR4Xu1d28t3RRXOfyDNvI6ovJCKIlPDDqBlRUUYaUeJD5JOihCdrJQIO6lpER1MFLzw0JEiyk6QF5WQZRQUBB0uuugqK/sHaj36e3S53LNnzezZe8/ev7VheL/vfWfP4ZnZ86y1Zs2ak54QTyAQCAQCgUAgMBMCJ81UbhQbCAQCgUAgEAg8IUgmJkEgEAgEAoHAbAgEycwGbRQcCAQCgUAgECQTcyAQCAQCgUBgNgSCZGaDNgoOBFZD4MlS8x2S7pf00dVaERVvBYEPSkMvlvRKSQ+0bnSQTGtEo7xAYF0EQDA/kvRrSe9ZtylR+4YQ+LK09aw5iCZIZkOzIJoaCGQQIMEg2yxSaYzArhGAYNJ87gTJ7HrOROeODAFoMM+QdM4cZo8jw3JP3X2OdOYFkk6W9HdJX0t0DkLKryT9u6WQEiSzp6kUfTlmBGDueLek50r6/TEDEX1/DAKYF2+SdJ+kVxz+8hv5eWlinoCQ7jkQURNza5BMzMhAYPsIvEq68ANJ75L01U67Ayn5GklXS2q+udxpn+doFjbp75X0C0fhyPu8A8kgO82pz5d//1gSTKpDzzvllze1mk9BMo6RiiyBQMcIPE3aBskUkmpq0Vi7+fR2+5A0JLSsaaMBLL8k6buSUmYv1oA9ljdK+puqEprK7w7/P01+pggfpldoPpM14yCZaQMebwcCayPAxeDpZjFZu12sn9Lze+UXHum7l3Z72vEiyXRuJuOtZiGHUHBR4h2bN1U0Mf2YZLh7pH5ouEN//5+DZNDOv0qCAAOvs+onSKYaulVfhI31KQMt8E5SvIoJ+CxTxoPy/17NLasC3mnlNJN9StrX63kYSNt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height: 40px;\" width=\"204.5\" height=\"40\"\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 44px; 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 22px; text-align: left; transform-origin: 384px 22px; 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: 313.617px 8px; transform-origin: 313.617px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to compute the length of stream affected by the spill. In other words, find the position \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFUAAAAoCAYAAACPSbZFAAADXElEQVRoQ+1YO89NQRT9vh8g4lGJyqNQESESoVEgNAoJeolHoRKCQuGREBqJV6LQCIJGQlBoKAgFiUThUao8gh/AWjL7Zptz3D0zZ853cfdJVs69d2bvmbtmP2dywp/qDExW1+gKJ5zUHozASXVSe2CgB5VuqU5qZwZWGRo+YPx911XGzVJJ6krgRETcfXw/CrwGPjmpZQzcg9i6IPoc7+Vlatqlxs1ShYXP+DAjfNmG9zUntRsD8yD+TqmYXyOO6i2No6XuAAEXAgkkd0G3M2pKjyOpdPUtgYrjeB8aFal0mTl/yI7MqN+Bl7U315M+HU83Yo27tdcZZqmLsRhdZS3AuMNHnyzHb4WxL3gvS4hNszBnUYU/UVpPcs8v1Pq9eOowpbTOrwDrtreBPMagFcB0gKXIeYCuNDPA4otW/cialDC+E3MuJsyLp+zDD1KjsjZdX6DDFEk9Kb0ZWu114DSQW4rQUuLC29xky4Qz+K3EbXV9uh86TpYsbsmkkqotjBb6AKge4K3Ndhxn6PmodKzG58cddbaKp5JK4R9BA+Mn3f1fezZgw3em4j/kkCquU72tm6LTOYZ1Doa1GL629rVuDqlS39FSFwIlFw+jzP7PsGdWKHxKE13SOaSSqrsQKi6t70aV/UtaUxrAFSC7QkghVWo7Zn3pmUs7kVFlf7r61WBmqa0pK56lJWHCIpWn9RTYA7CEaYur5/D7KaDz5W6Sb5VN4h53BVHW1rsNNWJIRTdYbaTS1fk8AS4BNwCp5+J6dS/GGGP/9vJKt6aWlzFE3QZ4NRjfYEmXqc+EXnAAGDQjMalxzIuzZNzm9ZpFy4yyIRXnA1Yvh4Fv0cy5+L4JkMuWuOOSEKLziRzWb+THpNLdjwAM7A+Vher1aa1rhoxX4qKzGv6HzWGvJcp01yaExlbO2r1RYloxtWQz/5sMDe0NQKvkvYeUkuK1jXDipNomIE1DfFcgya9RXjqpNqnSNCzBVLkz1rlltrLeX9qcVJtUufOQZMRwcDYkNMbT7cA0YHA546TapEptTvd/BbBmvwywmWCFQJLZdQ3adifVJpVVBOtxqYhuBhHGVDY8jcbHSbVJzZ7hpGZTZgs4qTZH2TOc1GzKbAEn1eYoe4aTmk2ZLeCk2hxlz/gJfpacKXO5h08AAAAASUVORK5CYII=\" alt=\"x = L_a\" style=\"width: 42.5px; height: 20px;\" width=\"42.5\" height=\"20\"\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: 44.3417px 8px; transform-origin: 44.3417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e (say) beyond which the concentration never exceeds a threshold \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAAAoCAYAAABzXJ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N+v+uMCXDayPck4MXo2iegFLaa+G90FohG3WGa+zD0aj7LxGWCzMEwgteynzb6jQ+PE15cRFL+BhyNlSTecdLdXVK8lAI735dfMZTW3EshHdPuE+pa0vahfDuCfcvbkgHSSgmvUQvhHdPuI/fZHPXhEll4kJ494Tj4cTx2pp8Ibx7woMSC+GF8MwMZFZXPLwQnpmBzOqKhxfCMzOQWd0fvS21Ke8sW2EAAAAASUVORK5CYII=\" alt=\"C = C_t\" style=\"width: 46px; height: 20px;\" width=\"46\" height=\"20\"\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: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function La = affectedReach(U,K,M,A,Ct)\r\n% La = length of affected reach of stream [L]\r\n% U  = mean velocity [L/T]\r\n% K  = dispersion coefficient [L^2/T]\r\n% M  = mass of contaminant [M]\r\n% A  = cross-sectional area (L^2)\r\n% Ct = threshold concentration (M/L^3)\r\n\r\n  La = M/(Ct*A);\r\nend","test_suite":"%%\r\nM = 100;                    %  Mass (kg)\r\nA = 30;                     %  Cross-sectional area (m2)\r\nU = 0.3;                    %  Mean velocity (m/s)\r\nK = 2;                      %  Dispersion coefficient (m2/s)\r\nCt = 0.01;                  %  Target concentration (kg/m3)\r\nLa_correct = 1329.62;       %  Length of affected reach (m)\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_correct)\u003c1e-2)\r\n\r\n%%\r\nM = 50;                     %  Mass (kg)\r\nA = 15;                     %  Cross-sectional area (m2)\r\nU = 0.25;                   %  Mean velocity (m/s)\r\nK = 8.4;                    %  Dispersion coefficient (m2/s)\r\nCt = 0.001;                 %  Target concentration (kg/m3)\r\nLa_correct = 26332.1;       %  Length of affected reach (m)\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_correct)\u003c1e-2)\r\n\r\n%%\r\nM = 15;                     %  Mass (kg)\r\nA = 25;                     %  Cross-sectional area (m2)\r\nU = 0.25;                   %  Mean velocity (m/s)\r\nK = 11;                     %  Dispersion coefficient (m2/s)\r\nCt = 0.003;                 %  Target concentration (kg/m3)\r\nLa_correct = 91.59;         %  Length of affected reach (m)\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_correct)\u003c1e-2)\r\n\r\n%%\r\nM = 15;                     %  Mass (kg)\r\nA = 25;                     %  Cross-sectional area (m2)\r\nU = 0.25;                   %  Mean velocity (m/s)\r\nK = 11;                     %  Dispersion coefficient (m2/s)\r\nCt = 3e-4;                  %  Target concentration (kg/m3)\r\nLa_correct = 7256.28;       %  Length of affected reach (m)\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_correct)\u003c1e-2)\r\n\r\n%%\r\nM = 70;                     %  Mass (kg)\r\nA = 21;                     %  Cross-sectional area (m2)\r\nU = 0.15;                   %  Mean velocity (m/s)\r\nK = 1;                      %  Dispersion coefficient (m2/s)\r\nCt = 0.01;                  %  Target concentration (kg/m3)\r\nLa_correct = 1329.62;       %  Length of affected reach (m)\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_correct)\u003c1e-2)\r\n\r\n%%\r\nM = 280;                    %  Mass (kg)\r\nA = 21;                     %  Cross-sectional area (m2)\r\nU = 0.54;                   %  Mean velocity (m/s)\r\nK = 3.7;                    %  Dispersion coefficient (m2/s)\r\nCt = 0.007;                 %  Target concentration (kg/m3)\r\nLa_correct = 42140.42;      %  Length of affected reach (m)\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_correct)\u003c1e-2)\r\n\r\n%% Approximately plug flow\r\nM = 5*rand;                 %  Mass (kg)\r\nA = 40;                     %  Cross-sectional area (m2)\r\nU = 0.3*(1+rand);           %  Mean velocity (m/s)\r\nK = rand*1e-3;              %  Dispersion coefficient (m2/s)\r\nCt = 0.02*rand;             %  Target concentration (kg/m3)\r\nLa_approx = (U/(4*pi*K))*(M/(Ct*A))^2;\r\nassert(abs(affectedReach(U,K,M,A,Ct)-La_approx)/La_approx\u003c1e-3)\r\n\r\n%%\r\nfiletext = fileread('affectedReach.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || contains(filetext,'switch') || contains(filetext,'regexp') || contains(filetext,'if'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":46909,"edited_by":46909,"edited_at":"2022-06-14T05:04:44.000Z","deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":"2022-06-14T05:04:44.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2022-06-14T04:57:20.000Z","updated_at":"2022-06-14T05:04:44.000Z","published_at":"2022-06-14T04:59:16.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWhen a contaminant is spilled into a stream, one might want to know how much of the stream is affected—e.g., the length over which the concentration exceeds a specified threshold. The concentration \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"C\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eC\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e is often computed as a function of time \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"t\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003et\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e and distance \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"x\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003ex\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e from the spill using the advection-dispersion equation:\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:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"true\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"dC/dt + U dC/dx = K d^2C/dx^2\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\frac{\\\\partial C}{\\\\partial t} + U \\\\frac{\\\\partial C}{\\\\partial x} = K \\\\frac{\\\\partial^2 C}{\\\\partial x^2}\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\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\u003ewhere \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"U\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eU\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e is the mean velocity of the river and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"K\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eK\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e is a dispersion coefficient, which describes spreading by several mechanisms. For an instantaneous spill of mass \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"M\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eM\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e mixed over the cross section (with area \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"A\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eA\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e) at \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"x = 0\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003ex = 0\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e, the concentration can be shown—using some of the math needed for \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/51625\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCody Problem 51625\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e—to be\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:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"true\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"C = (M/(A sqrt(4 pi K t))) exp(-(x-U t)^2/(4 K t))\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eC = \\\\frac{M}{A\\\\sqrt{4\\\\pi K t}} \\\\exp\\\\left(-\\\\frac{(x-U t)^2}{4 K t}\\\\right)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\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\u003eWrite a function to compute the length of stream affected by the spill. In other words, find the position \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"x = L_a\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003ex = L_a\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e (say) beyond which the concentration never exceeds a threshold \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"C = C_t\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eC = C_t\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"term":"tag:\"maximum\"","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:\"maximum\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"maximum\"","","\"","maximum","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f194947c598\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f194947c4f8\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f194947bc38\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f194947c818\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f194947c778\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f194947c6d8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f194947c638\u003e":"tag:\"maximum\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f194947c638\u003e":"tag:\"maximum\""},"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:\"maximum\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"maximum\"","","\"","maximum","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f194947c598\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f194947c4f8\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f194947bc38\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f194947c818\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f194947c778\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f194947c6d8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f194947c638\u003e":"tag:\"maximum\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f194947c638\u003e":"tag:\"maximum\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":61168,"difficulty_rating":"easy"},{"id":44706,"difficulty_rating":"easy-medium"},{"id":2408,"difficulty_rating":"easy-medium"},{"id":1865,"difficulty_rating":"easy-medium"},{"id":1273,"difficulty_rating":"easy-medium"},{"id":54750,"difficulty_rating":"medium-hard"}]}}