{"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":42846,"title":"Wien's displacement law","description":"Given the black body temperature (in *Celsius*), output the weavelength (in *meters*) at which the radiation peaks, according to \u003chttps://en.wikipedia.org/wiki/Wien's_displacement_law Wien's Displacement Law\u003e.\r\n\r\nTo convert Celsius into Kelvin, use 273.15.","description_html":"\u003cp\u003eGiven the black body temperature (in \u003cb\u003eCelsius\u003c/b\u003e), output the weavelength (in \u003cb\u003emeters\u003c/b\u003e) at which the radiation peaks, according to \u003ca href = \"https://en.wikipedia.org/wiki/Wien's_displacement_law\"\u003eWien's Displacement Law\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eTo convert Celsius into Kelvin, use 273.15.\u003c/p\u003e","function_template":"function lambda = WienWavelength(T)\r\n   h  = 6.62607004081e-34; % Planck's constant [W]\r\n   c  = 299792458;         % Speed of light [m/s]\r\n   R  = 8.314459848;       % Gas constant [J/K/mol]\r\n   Na = 6.02214085774e23;  % Avogadro constant [1/mol]\r\n   kb = R/Na;              % Boltzmann constant [J/K]\r\n   x  = 4.965114231744276; % 5+lambertw(-5*exp(-5)); % Solution for Planck's law with wavelength.\r\n   b  = [];\r\n   lambda = [];\r\nend","test_suite":"%%\r\nT = 1;\r\nlambda_correct = 1.057002706519664e-05;\r\nassert(abs(WienWavelength(T)/lambda_correct-1)\u003c1e-5);\r\n\r\n%%\r\nT = 10;\r\nlambda_correct = 1.023405587117661e-05;\r\nassert(abs(WienWavelength(T)/lambda_correct-1)\u003c1e-5);\r\n\r\n%%\r\nT = 100;\r\nlambda_correct = 7.765705265774241e-06;\r\nassert(abs(WienWavelength(T)/lambda_correct-1)\u003c1e-5);\r\n\r\n%%\r\nT = 1000;\r\nlambda_correct = 2.276065601008253e-06;\r\nassert(abs(WienWavelength(T)/lambda_correct-1)\u003c1e-5);\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":12767,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":54,"test_suite_updated_at":"2016-05-05T13:22:21.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-05-05T12:13:29.000Z","updated_at":"2026-02-10T11:24:06.000Z","published_at":"2016-05-05T13:22:21.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven the black body temperature (in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCelsius\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e), output the weavelength (in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emeters\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e) at which the radiation peaks, according to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Wien's_displacement_law\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWien's Displacement Law\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTo convert Celsius into Kelvin, use 273.15.\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":2959,"title":"Divide by 4","description":"Given the variable x as your input, divide it by four and put the result in y.","description_html":"\u003cp\u003eGiven the variable x as your input, divide it by four and put the result in y.\u003c/p\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = (x/4);\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 1/4;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":11,"comments_count":19,"created_by":33997,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1215,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-02-06T23:33:00.000Z","updated_at":"2026-03-17T15:40:46.000Z","published_at":"2015-02-06T23:33:03.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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 the variable x as your input, divide it by four and put the result in y.\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":60836,"title":"Integer Division Without Remainder","description":"Write a function that takes two positive integers, a and b, and returns the result of integer division (quotient) without remainder. The function should return floor(a / b), meaning the largest integer that does not exceed the division result.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 66.2px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 352px 33.1px; transform-origin: 352px 33.1px; vertical-align: baseline; \"\u003e\u003cdiv style=\"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: 329px 33.1px; text-align: left; transform-origin: 329px 33.1px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function that takes two positive integers, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, and returns the result of integer division (quotient) without remainder. The function should return \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003efloor(a / b)\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, meaning the largest integer that does not exceed the division result.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function q = intDiv(a, b)\r\n    % Your code here\r\nend","test_suite":"%% Test 1: Exact division\r\na = 10; b = 2;\r\ny_correct = 5; % 10 / 2 = 5\r\nassert(isequal(intDiv(a, b), y_correct))\r\n\r\n%% Test 2: Division with remainder\r\na = 7; b = 3;\r\ny_correct = 2; % 7 / 3 = 2.33, floor(2.33) = 2\r\nassert(isequal(intDiv(a, b), y_correct))\r\n\r\n%% Test 3: Division resulting in zero\r\na = 2; b = 5;\r\ny_correct = 0; % 2 / 5 = 0.4, floor(0.4) = 0\r\nassert(isequal(intDiv(a, b), y_correct))\r\n\r\n%% Test 4: Large numbers\r\na = 100; b = 7;\r\ny_correct = 14; % 100 / 7 = 14.28, floor(14.28) = 14\r\nassert(isequal(intDiv(a, b), y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":4857104,"edited_by":4857104,"edited_at":"2025-03-31T05:19:01.000Z","deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2025-03-31T05:19:01.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2025-03-31T05:18:22.000Z","updated_at":"2026-02-17T09:04:47.000Z","published_at":"2025-03-31T05:19:01.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 that takes two positive integers, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and returns the result of integer division (quotient) without remainder. The function should return \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efloor(a / b)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, meaning the largest integer that does not exceed the division result.\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":44331,"title":"Matrix Ax=B problem","description":"Take a incoming A and B vector, and solve for x","description_html":"\u003cp\u003eTake a incoming A and B vector, and solve for x\u003c/p\u003e","function_template":"function y = your_fcn_name(x, x1)\r\n  y = ...;\r\nend","test_suite":"%%\r\nx = [1 2; 3 4]; x1 = [4 3]';\r\ny_correct =  x\\x1;\r\nassert(isequal(your_fcn_name(x, x1),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":12852,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":107,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-09-14T17:42:15.000Z","updated_at":"2026-02-17T14:40:21.000Z","published_at":"2017-09-14T17:42:15.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTake a incoming A and B vector, and solve for x\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":42590,"title":"Divide elements by sum of elements","description":"In this problem, I ask you to write a function which will divide the elements of each column by the sum of the elements of the same column.\r\n\r\nResults should have 2 significant digits.\r\n\r\nYou cannot use for/while loops.","description_html":"\u003cp\u003eIn this problem, I ask you to write a function which will divide the elements of each column by the sum of the elements of the same column.\u003c/p\u003e\u003cp\u003eResults should have 2 significant digits.\u003c/p\u003e\u003cp\u003eYou cannot use for/while loops.\u003c/p\u003e","function_template":"function y = divideElements(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('divideElements.m');\r\nassert(isempty(strfind(filetext, 'for')))\r\nassert(isempty(strfind(filetext, 'while')))\r\n\r\n%%\r\nx = magic(3);\r\ny_correct = [0.53 0.07 0.4;\r\n0.20 0.33 0.47;\r\n0.27 0.60 0.13];\r\nassert(isequal(divideElements(x),y_correct))\r\n\r\n%%\r\nx = magic(4);\r\ny_correct = [0.47\t0.06\t0.09\t0.38\r\n0.15\t0.32\t0.29\t0.24\r\n0.26\t0.21\t0.18\t0.35\r\n0.12\t0.41\t0.44\t0.03];\r\nassert(isequal(divideElements(x),y_correct))\r\n\r\n%%\r\nx = ones(2);\r\ny_correct = repmat(0.5,2,2);\r\nassert(isequal(divideElements(x),y_correct))\r\n\r\n%%\r\nx = [1 0.5; 2 1];\r\ny_correct = [0.33 0.33; 0.67 0.67];\r\nassert(isequal(divideElements(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":142,"test_suite_updated_at":"2015-09-09T15:27:51.000Z","rescore_all_solutions":false,"group_id":24,"created_at":"2015-09-09T14:33:16.000Z","updated_at":"2026-04-02T10:12:10.000Z","published_at":"2015-09-09T14:33:16.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\u003eIn this problem, I ask you to write a function which will divide the elements of each column by the sum of the elements of the same 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eResults should have 2 significant digits.\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\u003eYou cannot use for/while loops.\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":43154,"title":"Basics - not so easy division","description":"Please make a function whcih divides x/y, but pay attention for some exceptions with NaN,0,Inf. Sometimes return \"ERROR\" instead of result.","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: 42px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 21px; transform-origin: 407px 21px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 355px 8px; transform-origin: 355px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ePlease make a function whcih divides x/y, but pay attention for some exceptions with NaN,0,Inf. Sometimes return \"ERROR\" instead of result.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function z = dividing(x,y)\r\n  z = y/x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny=1;\r\nz_correct = 1;\r\nassert(isequal(dividing(x,y),z_correct))\r\n\r\n%%\r\nx = 4;\r\ny=2;\r\nz_correct = 2;\r\nassert(isequal(dividing(x,y),z_correct))\r\n\r\n%%\r\nx = 1;\r\ny=0;\r\nz_correct = 'ERROR';\r\nassert(isequal(dividing(x,y),z_correct))\r\n\r\n%%\r\nx = Inf;\r\ny=-Inf;\r\nz_correct = 'ERROR';\r\nassert(isequal(dividing(x,y),z_correct))\r\n\r\n%%\r\nx = 1;\r\ny=NaN;\r\nz_correct = 'ERROR';\r\nassert(isequal(dividing(x,y),z_correct))","published":true,"deleted":false,"likes_count":23,"comments_count":2,"created_by":90955,"edited_by":223089,"edited_at":"2022-11-16T07:57:14.000Z","deleted_by":null,"deleted_at":null,"solvers_count":145,"test_suite_updated_at":"2022-11-16T07:57:14.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-07T12:36:12.000Z","updated_at":"2026-03-16T12:19:04.000Z","published_at":"2016-10-07T12:36:12.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\u003ePlease make a function whcih divides x/y, but pay attention for some exceptions with NaN,0,Inf. Sometimes return \\\"ERROR\\\" instead of result.\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":45767,"title":"Prime number check (★★)","description":"One way to see if a number x is prime is to compute the remainders obtained when dividing x by all integers from 2 to √(x). If x is prime, then all remainders will be non-zero.\r\n\r\nFor example, if x = 35 then √(x)=5.916, and the set of divisors from 2 to √(x) are [2 3 4 5]. The remainders obtained when dividing 35 by 2,3,4,5 are 1,2,3,0 respectively. Since one of the remainders is 0, the number x is not prime.\r\n\r\nWrite a function that will compute the remainders obtained when dividing x by all integers from 2 to √(x). ","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: 153px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 76.5px; transform-origin: 407px 76.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 384px 10.5px; transform-origin: 384px 10.5px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOne way to see if a number x is prime is to compute the remainders obtained when dividing x by all integers from 2 to √(x). If x is prime, then all remainders will be non-zero.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 375.067px 10.5px; transform-origin: 375.067px 10.5px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor example, if x = 35 then √(x)=5.916, and the set of divisors from 2 to √(x) are [2 3 4 5]. The remainders obtained when dividing 35 by 2,3,4,5 are 1,2,3,0 respectively. Since one of the remainders is 0, the number x is not prime.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 319.733px 10.5px; transform-origin: 319.733px 10.5px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function that will compute the remainders obtained when dividing x by all integers from 2 to √(x).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 84.4167px 10.5px; transform-origin: 84.4167px 10.5px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAvoid using for/while loops.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 35;\r\ny_correct = [1   2   3   0];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 31;\r\ny_correct = [1   1   3   1];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 21;\r\ny_correct = [1   0   1];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nfiletext = fileread('your_fcn_name.m');\r\nassert(isempty(strfind(filetext, 'for')),'for forbidden')\r\nassert(isempty(strfind(filetext, 'while')),'while forbidden')","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":428668,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":"2020-10-17T01:55:26.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-06-05T23:51:27.000Z","updated_at":"2026-03-31T14:53:04.000Z","published_at":"2020-06-05T23:51:27.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOne way to see if a number x is prime is to compute the remainders obtained when dividing x by all integers from 2 to √(x). If x is prime, then all remainders will be non-zero.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, if x = 35 then √(x)=5.916, and the set of divisors from 2 to √(x) are [2 3 4 5]. The remainders obtained when dividing 35 by 2,3,4,5 are 1,2,3,0 respectively. Since one of the remainders is 0, the number x is not prime.\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\u003eWrite a function that will compute the remainders obtained when dividing x by all integers from 2 to √(x).\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\u003eAvoid using for/while loops.\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":43619,"title":"Divide polynomial p1 by p2.","description":"Divide polynomial p1 by p2 given as vectors. Return result q and r vectors which corresponds the quotient and remainder of division respectively.\r\n\r\nExample\r\n\r\np1=[3     2     5     1     0     2 ] \r\n\r\np2=[1     2     0     5     0     3]\r\n\r\nThen q=[3] r=[0    -4     5   -14     0    -7]","description_html":"\u003cp\u003eDivide polynomial p1 by p2 given as vectors. Return result q and r vectors which corresponds the quotient and remainder of division respectively.\u003c/p\u003e\u003cp\u003eExample\u003c/p\u003e\u003cp\u003ep1=[3     2     5     1     0     2 ]\u003c/p\u003e\u003cp\u003ep2=[1     2     0     5     0     3]\u003c/p\u003e\u003cp\u003eThen q=[3] r=[0    -4     5   -14     0    -7]\u003c/p\u003e","function_template":"function [q,r] = DivPol(p1,p2)\r\n  y = x;\r\nend","test_suite":"%%\r\np1=[3 2 5 1 0 2 ]\r\np2=[1 2 0 5 0 3]\r\n\r\nq_correct=[3] \r\nr_correct=[0 -4 5 -14 0 -7]\r\n[q,r]=DivPol(p1,p2)\r\n\r\nassert(isequal(q,q_correct))\r\nassert(isequal(r,r_correct))\r\n%%\r\np1=[-2 0 3 -5 -6 5 -1 0 16 8]\r\np2=[1 0 -1 2 4]\r\n\r\nq_correct=[-2     0     1    -1     3     2] \r\nr_correct=[0 0 0 0 0 0 0 0 0 0]\r\n[q,r]=DivPol(p1,p2)\r\n\r\nassert(isequal(q,q_correct))\r\nassert(isequal(r,r_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":90467,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":62,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-24T23:36:33.000Z","updated_at":"2025-12-07T16:44:49.000Z","published_at":"2016-10-24T23:36:33.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivide polynomial p1 by p2 given as vectors. Return result q and r vectors which corresponds the quotient and remainder of division respectively.\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\u003ep1=[3 2 5 1 0 2 ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ep2=[1 2 0 5 0 3]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThen q=[3] r=[0 -4 5 -14 0 -7]\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":336,"title":"Similar Triangles - find the height of the tree","description":"Given the height, h1, of a power pole, shorter than a tree, a given distance, x2 away, please find h2, height of the tree. Please note that the angle, phi, is the acute angle measured from the ground to an observer's line of sight aimed to the sucessive peaks of the power pole and the tree, in that order. Also the distance from the observer to the power pole is x1, also a given. x2 is the distance between the tree and the power pole. In all tests x1 is always a multiple of x2.\r\n\r\n\r\nInputs: h1, x1, x2\r\n\r\nOutput: h2\r\n\r\nHINT: find phi, given h1 and x1. Phi may be measured in degrees or radians. Note that default trig functions in MATLAB operate in radians.\r\n\r\nEX:\r\nx1 = 4;\r\nx2 = 4;\r\nh1 = 3;\r\n\r\n\u003e\u003eh2=findHeight(x1,x2,h1)\r\n\r\nh2=6\r\n\r\n\u003e\u003e","description_html":"\u003cp\u003eGiven the height, h1, of a power pole, shorter than a tree, a given distance, x2 away, please find h2, height of the tree. Please note that the angle, phi, is the acute angle measured from the ground to an observer's line of sight aimed to the sucessive peaks of the power pole and the tree, in that order. Also the distance from the observer to the power pole is x1, also a given. x2 is the distance between the tree and the power pole. In all tests x1 is always a multiple of x2.\u003c/p\u003e\u003cp\u003eInputs: h1, x1, x2\u003c/p\u003e\u003cp\u003eOutput: h2\u003c/p\u003e\u003cp\u003eHINT: find phi, given h1 and x1. Phi may be measured in degrees or radians. Note that default trig functions in MATLAB operate in radians.\u003c/p\u003e\u003cp\u003eEX:\r\nx1 = 4;\r\nx2 = 4;\r\nh1 = 3;\u003c/p\u003e\u003cp\u003e\u003e\u003eh2=findHeight(x1,x2,h1)\u003c/p\u003e\u003cp\u003eh2=6\u003c/p\u003e\u003cp\u003e\u003e\u003e\u003c/p\u003e","function_template":"function h2 = findHeight(x1,x2,h1)\r\n  h2 = heightoftree\r\nend","test_suite":"%%\r\nx1 = 4;\r\nx2 = 4;\r\nh1 = 3;\r\ny_correct = 6;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 8;\r\nh1 = 3;\r\ny_correct = 9;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 12;\r\nh1 = 3;\r\ny_correct = 12;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 16;\r\nh1 = 3;\r\ny_correct = 15;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 20;\r\nh1 = 3;\r\ny_correct = 18;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 24;\r\nh1 = 3;\r\ny_correct = 21;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 12;\r\nh1 = 5;\r\ny_correct = 20;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 16;\r\nh1 = 10;\r\ny_correct = 50;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 2;\r\nx2 = 4;\r\nh1 = 5;\r\ny_correct = 15;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 3;\r\nx2 = 6;\r\nh1 = 4;\r\ny_correct = 12;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":6,"created_by":1103,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":469,"test_suite_updated_at":"2012-02-18T04:42:47.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-02-17T22:52:21.000Z","updated_at":"2026-03-13T05:26:44.000Z","published_at":"2012-02-18T04:42:47.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 the height, h1, of a power pole, shorter than a tree, a given distance, x2 away, please find h2, height of the tree. Please note that the angle, phi, is the acute angle measured from the ground to an observer's line of sight aimed to the sucessive peaks of the power pole and the tree, in that order. Also the distance from the observer to the power pole is x1, also a given. x2 is the distance between the tree and the power pole. In all tests x1 is always a multiple of x2.\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\u003eInputs: h1, x1, x2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: h2\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\u003eHINT: find phi, given h1 and x1. Phi may be measured in degrees or radians. Note that default trig functions in MATLAB operate in radians.\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\u003eEX: x1 = 4; x2 = 4; h1 = 3;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003e\u003eh2=findHeight(x1,x2,h1)\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\u003eh2=6\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003e\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":54020,"title":"Circle Division","description":"A circle can be divided into 2 sections, by placing 2 points in arbitrary locations along its circumference and drawing a straight line between them. By adding more points and drawing a straight line from each point to every other point, the circle can be divided into more sections. For example, 3 points would divide the circle into 4 sections and 4 points into 8 sections.\r\nGiven a positive integer, n, representing the number of arbitrarily placed points on the circumference of a circle, return d, i and s, the number of straight lines, the number of intersections and the number of sections into which the circle is divided, respectively.\r\nThe only restriction on the positions of the points is that they must be placed such that no 3 lines can share a single intersection.\r\nn will always be greater than 3.\r\nExample:\r\nn = 4;\r\nd = 6\r\ni = 1\r\ns = 8\r\nExample:\r\nn = 5;\r\nd = 10\r\ni = 5\r\ns = 16","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 460.5px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 230.25px; transform-origin: 407px 230.25px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eA circle can be divided into 2 sections, by placing 2 points in arbitrary locations along its circumference and drawing a straight line between them. By adding more points and drawing a straight line from each point to every other point, the circle can be divided into more sections. For example, 3 points would divide the circle into 4 sections and 4 points into 8 sections.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eGiven a positive integer, n, representing the number of arbitrarily placed points on the circumference of a circle, return d, i and s, the number of straight lines, the number of intersections and the number of sections into which the circle is divided, respectively.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eThe only restriction on the positions of the points is that they must be placed such that no 3 lines can share a single intersection.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003en will always be greater than 3.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.75px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.875px; transform-origin: 404px 40.875px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003en = 4;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ed = 6\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ei = 1\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003es = 8\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.75px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.875px; transform-origin: 404px 40.875px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003en = 5;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ed = 10\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ei = 5\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003es = 16\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [d,i,s] = your_fcn_name(n)\r\n    d = 1;\r\n    i = 1;\r\n    s = 1;\r\nend","test_suite":"%%\r\nfiletext = fileread('your_fcn_name.m');\r\nassert(isempty(strfind(filetext,'eval')))\r\nassert(isempty(strfind(filetext,'echo')))\r\nassert(isempty(strfind(filetext,'switch')))\r\nassert(isempty(strfind(filetext,'regexp')))\r\n\r\n%%\r\n[d,i,s] = your_fcn_name(4);\r\nassert(isequal([d i s],[6 1 8]))\r\n\r\n%%\r\n[d,i,s] = your_fcn_name(5);\r\nassert(isequal([d i s],[10 5 16]))\r\n\r\n%%\r\n[d,i,s] = your_fcn_name(7);\r\nassert(isequal([d i s],[21 35 57]))\r\n\r\n%%\r\n[d,i,s] = your_fcn_name(13);\r\nassert(isequal([d i s],[78 715 794]))\r\n\r\n%%\r\n[d,i,s] = your_fcn_name(53);\r\nassert(isequal([d i s],[1378 292825 294204]))\r\n\r\n%%\r\n[d,i,s] = your_fcn_name(100);\r\nassert(isequal([d i s],[4950 3921225 3926176]))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":15521,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":8,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-02-18T20:04:46.000Z","updated_at":"2025-12-02T20:17:27.000Z","published_at":"2022-02-18T20:04:46.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA circle can be divided into 2 sections, by placing 2 points in arbitrary locations along its circumference and drawing a straight line between them. By adding more points and drawing a straight line from each point to every other point, the circle can be divided into more sections. For example, 3 points would divide the circle into 4 sections and 4 points into 8 sections.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a positive integer, n, representing the number of arbitrarily placed points on the circumference of a circle, return d, i and s, the number of straight lines, the number of intersections and the number of sections into which the circle is divided, respectively.\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 only restriction on the positions of the points is that they must be placed such that no 3 lines can share a single intersection.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en will always be greater than 3.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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[n = 4;\\nd = 6\\ni = 1\\ns = 8]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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[n = 5;\\nd = 10\\ni = 5\\ns = 16]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":42316,"title":"Fraction of a fraction of a ...","description":"One sort of brainteaser problem is a math problem wherein you are asked what the given fraction of a fraction of a ... number is. For example,\r\n\r\n* What is one-seventh of two-ninths of 630?\r\n\r\nYou will be supplied with various strings of this format (minus the \"What is\" at the beginning and the question mark at the end. Write a function to translate the string and calculate the value. Hyphens will always be present between top and bottom values of fractions while \"of\" can be replaced by a multiplication symbol. Also, make sure you capture singular and plural fractions. In this case, the translated string might look something like this:\r\n\r\n* 1/7 * 2/9 * 630\r\n\r\nwhich, when evaluated, will yield 20. See the test suite for more examples.","description_html":"\u003cp\u003eOne sort of brainteaser problem is a math problem wherein you are asked what the given fraction of a fraction of a ... number is. For example,\u003c/p\u003e\u003cul\u003e\u003cli\u003eWhat is one-seventh of two-ninths of 630?\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou will be supplied with various strings of this format (minus the \"What is\" at the beginning and the question mark at the end. Write a function to translate the string and calculate the value. Hyphens will always be present between top and bottom values of fractions while \"of\" can be replaced by a multiplication symbol. Also, make sure you capture singular and plural fractions. In this case, the translated string might look something like this:\u003c/p\u003e\u003cul\u003e\u003cli\u003e1/7 * 2/9 * 630\u003c/li\u003e\u003c/ul\u003e\u003cp\u003ewhich, when evaluated, will yield 20. See the test suite for more examples.\u003c/p\u003e","function_template":"function [val] = fraction_of_a(frac_str)\r\n\r\nval = 1;\r\n\r\nend\r\n","test_suite":"%%\r\nfrac_str = 'two-sevenths of five-ninths of three-eighths of 168';\r\nassert(isequal(round(fraction_of_a(frac_str)),10))\r\n\r\n%%\r\nfrac_str = 'one-fifth of four-halfs of three-fourths of 100';\r\nassert(isequal(round(fraction_of_a(frac_str)),30))\r\n\r\n%%\r\nfrac_str = 'two-thirds of three-fourths of one-fifth of 150';\r\nassert(isequal(round(fraction_of_a(frac_str)),15))\r\n\r\n%%\r\nfrac_str = 'five-sevenths of four-fifths of three-halfs of two-sixths of one-fourth of 210';\r\nassert(isequal(round(fraction_of_a(frac_str)),15))\r\n\r\n%%\r\nfrac_str = 'one-seventh of two-ninths of 630';\r\nassert(isequal(round(fraction_of_a(frac_str)),20))\r\n\r\n%%\r\nfrac_str = 'one-half of three-fifths of two-thirds of three-fourths of 1000';\r\nassert(isequal(round(fraction_of_a(frac_str)),150))\r\n\r\n%%\r\nfrac_str = 'one-half of two-thirds of three-fourths of four-fifths of five-sixths of six-sevenths of seven-eighths of eight-ninths of 36288';\r\nassert(isequal(round(fraction_of_a(frac_str)),4032))\r\n\r\n%%\r\nfrac_str = 'one-ninth of two-eighths of three-sevenths of four-sixths of five-fifths of six-fourths of seven-thirds of eight-halfs of 36288';\r\nassert(isequal(round(fraction_of_a(frac_str)),4032))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tfrac_str = 'two-sevenths of five-ninths of three-eighths of 168';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),10))\r\n\tcase 2\r\n\t\tfrac_str = 'one-fifth of four-halfs of three-fourths of 100';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),30))\r\n\tcase 3\r\n\t\tfrac_str = 'two-thirds of three-fourths of one-fifth of 150';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),15))\r\n\tcase 4\r\n\t\tfrac_str = 'one-ninth of two-eighths of three-sevenths of four-sixths of five-fifths of six-fourths of seven-thirds of eight-halfs of 36288';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),4032))\r\nend\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tfrac_str = 'one-half of two-thirds of three-fourths of four-fifths of five-sixths of six-sevenths of seven-eighths of eight-ninths of 36288';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),4032))\r\n\tcase 2\r\n\t\tfrac_str = 'one-fifth of four-halfs of three-fourths of 100';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),30))\r\n\tcase 3\r\n\t\tfrac_str = 'one-seventh of two-ninths of 630';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),20))\r\n\tcase 4\r\n\t\tfrac_str = 'two-thirds of three-fourths of one-fifth of 150';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),15))\r\nend\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tfrac_str = 'one-fifth of four-halfs of three-fourths of 100';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),30))\r\n\tcase 2\r\n\t\tfrac_str = 'two-sevenths of five-ninths of three-eighths of 168';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),10))\r\n\tcase 3\r\n\t\tfrac_str = 'one-half of two-thirds of three-fourths of four-fifths of five-sixths of six-sevenths of seven-eighths of eight-ninths of 36288';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),4032))\r\n\tcase 4\r\n\t\tfrac_str = 'one-seventh of two-ninths of 630';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),20))\r\nend\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":19,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-05-17T01:22:29.000Z","updated_at":"2025-11-03T11:31:32.000Z","published_at":"2015-05-17T01:22:29.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eOne sort of brainteaser problem is a math problem wherein you are asked what the given fraction of a fraction of a ... number is. For example,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWhat is one-seventh of two-ninths of 630?\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will be supplied with various strings of this format (minus the \\\"What is\\\" at the beginning and the question mark at the end. Write a function to translate the string and calculate the value. Hyphens will always be present between top and bottom values of fractions while \\\"of\\\" can be replaced by a multiplication symbol. Also, make sure you capture singular and plural fractions. In this case, the translated string might look something like this:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1/7 * 2/9 * 630\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\u003ewhich, when evaluated, will yield 20. See the test suite for more examples.\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":44357,"title":"Back to basics:  throwing errors / exceptions","description":"*Throwing and handling errors (or exceptions) is an important part of practical programming.*  \r\n\r\nHere your task is to provide an alternative to the built in elementwise division operator *./* (equivalent to the \u003chttp://au.mathworks.com/help/fixedpoint/ref/rdivide.html rdivide\u003e function) with the following differences:\r\n\r\n# throws an error if _any_ of the input elements have a non-zero \u003chttps://en.wikipedia.org/wiki/Imaginary_number imaginary component\u003e (and are therefore 'complex numbers' that are incapable of being correctly represented as real numbers);\r\n# throws an error if _any_ of the input elements are \u003chttp://au.mathworks.com/help/matlab/ref/char.html character arrays\u003e;\r\n# yields \u003chttp://au.mathworks.com/help/matlab/ref/nan.html NaN\u003e wherever the divisor (i.e. the denominator) is equal to zero.\r\n\r\nThis concept is analogous to the built in MATLAB function \u003chttp://au.mathworks.com/help/matlab/ref/realsqrt.html \"realsqrt\"\u003e.\r\n\r\nThe first error must generate an MException with the following properties: identifier = 'realDivision:complexInput',  message = 'The realDivision function only operates on real inputs.'.\r\n\r\nThe second error must generate an MException with the following properties: identifier = 'realDivision:incompatibleInput',  message = 'The realDivision function is not defined for character inputs.'.\r\n\r\nAll other behaviour should be identical to the mrdivide function.  Any exceptions that would have been thrown by mrdivide should also be thrown by your function — with the same contents of the identifier and message fields.  \r\n\r\nNote that the difference in MATLAB between \u003chttp://au.mathworks.com/help/matlab/ref/error.html errors\u003e and \u003chttp://au.mathworks.com/help/matlab/ref/mexception-class.html exceptions\u003e is \u003chttps://au.mathworks.com/matlabcentral/answers/116197-there-seems-to-be-two-different-methods-of-error-handling-in-matlab-error-handling-and-exception somewhat fraught\u003e.  ","description_html":"\u003cp\u003e\u003cb\u003eThrowing and handling errors (or exceptions) is an important part of practical programming.\u003c/b\u003e\u003c/p\u003e\u003cp\u003eHere your task is to provide an alternative to the built in elementwise division operator \u003cb\u003e./\u003c/b\u003e (equivalent to the \u003ca href = \"http://au.mathworks.com/help/fixedpoint/ref/rdivide.html\"\u003erdivide\u003c/a\u003e function) with the following differences:\u003c/p\u003e\u003col\u003e\u003cli\u003ethrows an error if \u003ci\u003eany\u003c/i\u003e of the input elements have a non-zero \u003ca href = \"https://en.wikipedia.org/wiki/Imaginary_number\"\u003eimaginary component\u003c/a\u003e (and are therefore 'complex numbers' that are incapable of being correctly represented as real numbers);\u003c/li\u003e\u003cli\u003ethrows an error if \u003ci\u003eany\u003c/i\u003e of the input elements are \u003ca href = \"http://au.mathworks.com/help/matlab/ref/char.html\"\u003echaracter arrays\u003c/a\u003e;\u003c/li\u003e\u003cli\u003eyields \u003ca href = \"http://au.mathworks.com/help/matlab/ref/nan.html\"\u003eNaN\u003c/a\u003e wherever the divisor (i.e. the denominator) is equal to zero.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eThis concept is analogous to the built in MATLAB function \u003ca href = \"http://au.mathworks.com/help/matlab/ref/realsqrt.html\"\u003e\"realsqrt\"\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eThe first error must generate an MException with the following properties: identifier = 'realDivision:complexInput',  message = 'The realDivision function only operates on real inputs.'.\u003c/p\u003e\u003cp\u003eThe second error must generate an MException with the following properties: identifier = 'realDivision:incompatibleInput',  message = 'The realDivision function is not defined for character inputs.'.\u003c/p\u003e\u003cp\u003eAll other behaviour should be identical to the mrdivide function.  Any exceptions that would have been thrown by mrdivide should also be thrown by your function — with the same contents of the identifier and message fields.\u003c/p\u003e\u003cp\u003eNote that the difference in MATLAB between \u003ca href = \"http://au.mathworks.com/help/matlab/ref/error.html\"\u003eerrors\u003c/a\u003e and \u003ca href = \"http://au.mathworks.com/help/matlab/ref/mexception-class.html\"\u003eexceptions\u003c/a\u003e is \u003ca href = \"https://au.mathworks.com/matlabcentral/answers/116197-there-seems-to-be-two-different-methods-of-error-handling-in-matlab-error-handling-and-exception\"\u003esomewhat fraught\u003c/a\u003e.\u003c/p\u003e","function_template":"function q = realDivision(a, b)\r\n    q = realsqrt(a, b);\r\nend","test_suite":"%% Test 1\r\na = 10;\r\nb = 5;\r\n%disp(a ./ b)\r\nq_correct = 2;\r\nq = realDivision(a, b);\r\nassert( isequal(q, q_correct) )\r\n\r\n\r\n%% Test 2\r\na = [100:2:300; 400:2:600];\r\nb = 2;\r\n%disp(a ./ b)\r\nq_correct = [50:150; 200:300];\r\nq = realDivision(a, b);\r\nassert( isequal(q, q_correct) )\r\n\r\n\r\n%% Test 3\r\na = 24;\r\nb = [1 2 3 4 6 8 12 24];\r\n%disp(a ./ b)\r\nq_correct = [24 12 8 6 4 3 2 1];\r\nq = realDivision(a, b);\r\nassert( isequal(q, q_correct) )\r\n\r\n\r\n%% Test 4\r\na = sqrt(-4);\r\nb = 2;\r\n%disp(a ./ b)\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    %disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\ne_correct.identifier = 'realDivision:complexInput';\r\ne_correct.message = 'The realDivision function only operates on real inputs.';\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 5\r\na = 12 * randi(8, 10);\r\nb = randi(4, 10);\r\nrNum = randi(10);\r\ncNum = randi(10);\r\ncplx = 12 * randi(8) * sqrt(-1);\r\nif rand() \u003c 0.5, \r\n    a(rNum, cNum) = a(rNum, cNum) + cplx;\r\nelse\r\n    b(rNum, cNum) = b(rNum, cNum) - cplx;\r\nend;\r\n%disp(a ./ b)\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    %disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\ne_correct.identifier = 'realDivision:complexInput';\r\ne_correct.message = 'The realDivision function only operates on real inputs.';\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 6\r\na = 'MATLAB';\r\nb = 'coding';\r\n%disp(a ./ b)\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    %disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\ne_correct.identifier = 'realDivision:incompatibleInput';\r\ne_correct.message = 'The realDivision function is not defined for character inputs.';\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 7\r\na = 'MATLAB';\r\nb = 'Cody';\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\ne_correct.identifier = 'realDivision:incompatibleInput';\r\ne_correct.message = 'The realDivision function is not defined for character inputs.';\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 8\r\na = \"Computing\";\r\nb = \"Algorithm\";\r\ne_correct.identifier = 'MATLAB:UndefinedFunction';\r\ne_correct.message = char(\"Undefined function 'rdivide' for input arguments of type 'string'.\");\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 9\r\na = {1, 7, 3};\r\nb = {4, 8, 9};\r\ne_correct.identifier = 'MATLAB:UndefinedFunction';\r\ne_correct.message = char(\"Undefined function 'rdivide' for input arguments of type 'cell'.\");\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 10\r\na.itemOne = 10;\r\na.itemTwo = 20;\r\nb.itemOne = 5;\r\nb.itemTwo = 15;\r\ne_correct.identifier = 'MATLAB:UndefinedFunction';\r\ne_correct.message = char(\"Undefined function 'rdivide' for input arguments of type 'struct'.\");\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 11\r\nratio = randi(11) + 1;\r\nb = randi(8, 10);\r\na = ratio * b;\r\nrNum = randi(10);\r\ncNum = randi(10);\r\nb(rNum, cNum) = nan;\r\n%disp(a ./ b)\r\nq_correct = ratio * ones(10);\r\nq_correct(rNum, cNum) = NaN;\r\nq = realDivision(a, b);\r\nassert( isequal(q(~isnan(q)), q_correct(~isnan(q_correct))) )\r\nassert( isequal(size(q), size(q_correct)) )\r\nassert( isequal(isnan(q), isnan(q_correct)) )\r\n\r\n\r\n%% Test 12\r\nratio = randi(11) + 1;\r\nb = randi(8, 10);\r\na = ratio * b;\r\nrNum = randi(10);\r\ncNum = randi(10);\r\nb(rNum, cNum) = 0;\r\n%disp(a ./ b)\r\nq_correct = ratio * ones(10);\r\nq_correct(rNum, cNum) = nan;\r\nq = realDivision(a, b);\r\nassert( isequal(q(~isnan(q)), q_correct(~isnan(q_correct))) )\r\nassert( isequal(size(q), size(q_correct)) )\r\nassert( isequal(isnan(q), isnan(q_correct)) )\r\n\r\n\r\n%% Test 13\r\nratio = randi(11) + 1;\r\nb = randi(8, 10);\r\na = ratio * b;\r\nidxNum = randi(100, [1, 5]);\r\nb(idxNum) = complex( b(idxNum) );\r\n%disp(a ./ b)\r\nq_correct = ratio * ones(10);\r\nq = realDivision(a, b);\r\nassert( isequal(q, q_correct) )\r\n\r\n\r\n%%\r\n% The first error must generate an MException with the following properties: \r\n% identifier = 'realDivision:complexInput',  message = 'The realDivision function only operates on real inputs.'.\r\n% \r\n% The second error must generate an MException with the following properties: \r\n% identifier = 'realDivision:incompatibleInput',  message = 'The realDivision function is not defined for character inputs.'.\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":6,"test_suite_updated_at":"2017-10-05T10:41:09.000Z","rescore_all_solutions":false,"group_id":677,"created_at":"2017-10-03T13:05:21.000Z","updated_at":"2019-05-02T17:03:22.000Z","published_at":"2017-10-04T05:08:09.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eThrowing and handling errors (or exceptions) is an important part of practical programming.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHere your task is to provide an alternative to the built in elementwise division operator\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e./\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (equivalent to the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/fixedpoint/ref/rdivide.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erdivide\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e function) with the following differences:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethrows an error if\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eany\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of the input elements have a non-zero\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Imaginary_number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eimaginary component\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (and are therefore 'complex numbers' that are incapable of being correctly represented as real numbers);\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethrows an error if\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eany\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of the input elements are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/char.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003echaracter arrays\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eyields\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/nan.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eNaN\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e wherever the divisor (i.e. the denominator) is equal to zero.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis concept is analogous to the built in MATLAB function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/realsqrt.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"realsqrt\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe first error must generate an MException with the following properties: identifier = 'realDivision:complexInput', message = 'The realDivision function only operates on real inputs.'.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe second error must generate an MException with the following properties: identifier = 'realDivision:incompatibleInput', message = 'The realDivision function is not defined for character inputs.'.\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\u003eAll other behaviour should be identical to the mrdivide function. Any exceptions that would have been thrown by mrdivide should also be thrown by your function — with the same contents of the identifier and message fields.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNote that the difference in MATLAB between\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/error.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eerrors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/mexception-class.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eexceptions\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://au.mathworks.com/matlabcentral/answers/116197-there-seems-to-be-two-different-methods-of-error-handling-in-matlab-error-handling-and-exception\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esomewhat fraught\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":42846,"title":"Wien's displacement law","description":"Given the black body temperature (in *Celsius*), output the weavelength (in *meters*) at which the radiation peaks, according to \u003chttps://en.wikipedia.org/wiki/Wien's_displacement_law Wien's Displacement Law\u003e.\r\n\r\nTo convert Celsius into Kelvin, use 273.15.","description_html":"\u003cp\u003eGiven the black body temperature (in \u003cb\u003eCelsius\u003c/b\u003e), output the weavelength (in \u003cb\u003emeters\u003c/b\u003e) at which the radiation peaks, according to \u003ca href = \"https://en.wikipedia.org/wiki/Wien's_displacement_law\"\u003eWien's Displacement Law\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eTo convert Celsius into Kelvin, use 273.15.\u003c/p\u003e","function_template":"function lambda = WienWavelength(T)\r\n   h  = 6.62607004081e-34; % Planck's constant [W]\r\n   c  = 299792458;         % Speed of light [m/s]\r\n   R  = 8.314459848;       % Gas constant [J/K/mol]\r\n   Na = 6.02214085774e23;  % Avogadro constant [1/mol]\r\n   kb = R/Na;              % Boltzmann constant [J/K]\r\n   x  = 4.965114231744276; % 5+lambertw(-5*exp(-5)); % Solution for Planck's law with wavelength.\r\n   b  = [];\r\n   lambda = [];\r\nend","test_suite":"%%\r\nT = 1;\r\nlambda_correct = 1.057002706519664e-05;\r\nassert(abs(WienWavelength(T)/lambda_correct-1)\u003c1e-5);\r\n\r\n%%\r\nT = 10;\r\nlambda_correct = 1.023405587117661e-05;\r\nassert(abs(WienWavelength(T)/lambda_correct-1)\u003c1e-5);\r\n\r\n%%\r\nT = 100;\r\nlambda_correct = 7.765705265774241e-06;\r\nassert(abs(WienWavelength(T)/lambda_correct-1)\u003c1e-5);\r\n\r\n%%\r\nT = 1000;\r\nlambda_correct = 2.276065601008253e-06;\r\nassert(abs(WienWavelength(T)/lambda_correct-1)\u003c1e-5);\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":12767,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":54,"test_suite_updated_at":"2016-05-05T13:22:21.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-05-05T12:13:29.000Z","updated_at":"2026-02-10T11:24:06.000Z","published_at":"2016-05-05T13:22:21.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven the black body temperature (in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCelsius\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e), output the weavelength (in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emeters\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e) at which the radiation peaks, according to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Wien's_displacement_law\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWien's Displacement Law\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTo convert Celsius into Kelvin, use 273.15.\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":2959,"title":"Divide by 4","description":"Given the variable x as your input, divide it by four and put the result in y.","description_html":"\u003cp\u003eGiven the variable x as your input, divide it by four and put the result in y.\u003c/p\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = (x/4);\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 1/4;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":11,"comments_count":19,"created_by":33997,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1215,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-02-06T23:33:00.000Z","updated_at":"2026-03-17T15:40:46.000Z","published_at":"2015-02-06T23:33:03.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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 the variable x as your input, divide it by four and put the result in y.\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":60836,"title":"Integer Division Without Remainder","description":"Write a function that takes two positive integers, a and b, and returns the result of integer division (quotient) without remainder. The function should return floor(a / b), meaning the largest integer that does not exceed the division result.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 66.2px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 352px 33.1px; transform-origin: 352px 33.1px; vertical-align: baseline; \"\u003e\u003cdiv style=\"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: 329px 33.1px; text-align: left; transform-origin: 329px 33.1px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function that takes two positive integers, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, and returns the result of integer division (quotient) without remainder. The function should return \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003efloor(a / b)\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, meaning the largest integer that does not exceed the division result.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function q = intDiv(a, b)\r\n    % Your code here\r\nend","test_suite":"%% Test 1: Exact division\r\na = 10; b = 2;\r\ny_correct = 5; % 10 / 2 = 5\r\nassert(isequal(intDiv(a, b), y_correct))\r\n\r\n%% Test 2: Division with remainder\r\na = 7; b = 3;\r\ny_correct = 2; % 7 / 3 = 2.33, floor(2.33) = 2\r\nassert(isequal(intDiv(a, b), y_correct))\r\n\r\n%% Test 3: Division resulting in zero\r\na = 2; b = 5;\r\ny_correct = 0; % 2 / 5 = 0.4, floor(0.4) = 0\r\nassert(isequal(intDiv(a, b), y_correct))\r\n\r\n%% Test 4: Large numbers\r\na = 100; b = 7;\r\ny_correct = 14; % 100 / 7 = 14.28, floor(14.28) = 14\r\nassert(isequal(intDiv(a, b), y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":4857104,"edited_by":4857104,"edited_at":"2025-03-31T05:19:01.000Z","deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2025-03-31T05:19:01.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2025-03-31T05:18:22.000Z","updated_at":"2026-02-17T09:04:47.000Z","published_at":"2025-03-31T05:19:01.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 that takes two positive integers, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and returns the result of integer division (quotient) without remainder. The function should return \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efloor(a / b)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, meaning the largest integer that does not exceed the division result.\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":44331,"title":"Matrix Ax=B problem","description":"Take a incoming A and B vector, and solve for x","description_html":"\u003cp\u003eTake a incoming A and B vector, and solve for x\u003c/p\u003e","function_template":"function y = your_fcn_name(x, x1)\r\n  y = ...;\r\nend","test_suite":"%%\r\nx = [1 2; 3 4]; x1 = [4 3]';\r\ny_correct =  x\\x1;\r\nassert(isequal(your_fcn_name(x, x1),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":12852,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":107,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-09-14T17:42:15.000Z","updated_at":"2026-02-17T14:40:21.000Z","published_at":"2017-09-14T17:42:15.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTake a incoming A and B vector, and solve for x\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":42590,"title":"Divide elements by sum of elements","description":"In this problem, I ask you to write a function which will divide the elements of each column by the sum of the elements of the same column.\r\n\r\nResults should have 2 significant digits.\r\n\r\nYou cannot use for/while loops.","description_html":"\u003cp\u003eIn this problem, I ask you to write a function which will divide the elements of each column by the sum of the elements of the same column.\u003c/p\u003e\u003cp\u003eResults should have 2 significant digits.\u003c/p\u003e\u003cp\u003eYou cannot use for/while loops.\u003c/p\u003e","function_template":"function y = divideElements(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('divideElements.m');\r\nassert(isempty(strfind(filetext, 'for')))\r\nassert(isempty(strfind(filetext, 'while')))\r\n\r\n%%\r\nx = magic(3);\r\ny_correct = [0.53 0.07 0.4;\r\n0.20 0.33 0.47;\r\n0.27 0.60 0.13];\r\nassert(isequal(divideElements(x),y_correct))\r\n\r\n%%\r\nx = magic(4);\r\ny_correct = [0.47\t0.06\t0.09\t0.38\r\n0.15\t0.32\t0.29\t0.24\r\n0.26\t0.21\t0.18\t0.35\r\n0.12\t0.41\t0.44\t0.03];\r\nassert(isequal(divideElements(x),y_correct))\r\n\r\n%%\r\nx = ones(2);\r\ny_correct = repmat(0.5,2,2);\r\nassert(isequal(divideElements(x),y_correct))\r\n\r\n%%\r\nx = [1 0.5; 2 1];\r\ny_correct = [0.33 0.33; 0.67 0.67];\r\nassert(isequal(divideElements(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":142,"test_suite_updated_at":"2015-09-09T15:27:51.000Z","rescore_all_solutions":false,"group_id":24,"created_at":"2015-09-09T14:33:16.000Z","updated_at":"2026-04-02T10:12:10.000Z","published_at":"2015-09-09T14:33:16.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\u003eIn this problem, I ask you to write a function which will divide the elements of each column by the sum of the elements of the same 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eResults should have 2 significant digits.\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\u003eYou cannot use for/while loops.\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":43154,"title":"Basics - not so easy division","description":"Please make a function whcih divides x/y, but pay attention for some exceptions with NaN,0,Inf. Sometimes return \"ERROR\" instead of result.","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: 42px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 21px; transform-origin: 407px 21px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 355px 8px; transform-origin: 355px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ePlease make a function whcih divides x/y, but pay attention for some exceptions with NaN,0,Inf. Sometimes return \"ERROR\" instead of result.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function z = dividing(x,y)\r\n  z = y/x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny=1;\r\nz_correct = 1;\r\nassert(isequal(dividing(x,y),z_correct))\r\n\r\n%%\r\nx = 4;\r\ny=2;\r\nz_correct = 2;\r\nassert(isequal(dividing(x,y),z_correct))\r\n\r\n%%\r\nx = 1;\r\ny=0;\r\nz_correct = 'ERROR';\r\nassert(isequal(dividing(x,y),z_correct))\r\n\r\n%%\r\nx = Inf;\r\ny=-Inf;\r\nz_correct = 'ERROR';\r\nassert(isequal(dividing(x,y),z_correct))\r\n\r\n%%\r\nx = 1;\r\ny=NaN;\r\nz_correct = 'ERROR';\r\nassert(isequal(dividing(x,y),z_correct))","published":true,"deleted":false,"likes_count":23,"comments_count":2,"created_by":90955,"edited_by":223089,"edited_at":"2022-11-16T07:57:14.000Z","deleted_by":null,"deleted_at":null,"solvers_count":145,"test_suite_updated_at":"2022-11-16T07:57:14.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-07T12:36:12.000Z","updated_at":"2026-03-16T12:19:04.000Z","published_at":"2016-10-07T12:36:12.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\u003ePlease make a function whcih divides x/y, but pay attention for some exceptions with NaN,0,Inf. Sometimes return \\\"ERROR\\\" instead of result.\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":45767,"title":"Prime number check (★★)","description":"One way to see if a number x is prime is to compute the remainders obtained when dividing x by all integers from 2 to √(x). If x is prime, then all remainders will be non-zero.\r\n\r\nFor example, if x = 35 then √(x)=5.916, and the set of divisors from 2 to √(x) are [2 3 4 5]. The remainders obtained when dividing 35 by 2,3,4,5 are 1,2,3,0 respectively. Since one of the remainders is 0, the number x is not prime.\r\n\r\nWrite a function that will compute the remainders obtained when dividing x by all integers from 2 to √(x). ","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: 153px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 76.5px; transform-origin: 407px 76.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 384px 10.5px; transform-origin: 384px 10.5px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOne way to see if a number x is prime is to compute the remainders obtained when dividing x by all integers from 2 to √(x). If x is prime, then all remainders will be non-zero.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 375.067px 10.5px; transform-origin: 375.067px 10.5px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor example, if x = 35 then √(x)=5.916, and the set of divisors from 2 to √(x) are [2 3 4 5]. The remainders obtained when dividing 35 by 2,3,4,5 are 1,2,3,0 respectively. Since one of the remainders is 0, the number x is not prime.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 319.733px 10.5px; transform-origin: 319.733px 10.5px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function that will compute the remainders obtained when dividing x by all integers from 2 to √(x).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 84.4167px 10.5px; transform-origin: 84.4167px 10.5px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAvoid using for/while loops.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 35;\r\ny_correct = [1   2   3   0];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 31;\r\ny_correct = [1   1   3   1];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 21;\r\ny_correct = [1   0   1];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nfiletext = fileread('your_fcn_name.m');\r\nassert(isempty(strfind(filetext, 'for')),'for forbidden')\r\nassert(isempty(strfind(filetext, 'while')),'while forbidden')","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":428668,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":"2020-10-17T01:55:26.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-06-05T23:51:27.000Z","updated_at":"2026-03-31T14:53:04.000Z","published_at":"2020-06-05T23:51:27.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOne way to see if a number x is prime is to compute the remainders obtained when dividing x by all integers from 2 to √(x). If x is prime, then all remainders will be non-zero.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, if x = 35 then √(x)=5.916, and the set of divisors from 2 to √(x) are [2 3 4 5]. The remainders obtained when dividing 35 by 2,3,4,5 are 1,2,3,0 respectively. Since one of the remainders is 0, the number x is not prime.\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\u003eWrite a function that will compute the remainders obtained when dividing x by all integers from 2 to √(x).\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\u003eAvoid using for/while loops.\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":43619,"title":"Divide polynomial p1 by p2.","description":"Divide polynomial p1 by p2 given as vectors. Return result q and r vectors which corresponds the quotient and remainder of division respectively.\r\n\r\nExample\r\n\r\np1=[3     2     5     1     0     2 ] \r\n\r\np2=[1     2     0     5     0     3]\r\n\r\nThen q=[3] r=[0    -4     5   -14     0    -7]","description_html":"\u003cp\u003eDivide polynomial p1 by p2 given as vectors. Return result q and r vectors which corresponds the quotient and remainder of division respectively.\u003c/p\u003e\u003cp\u003eExample\u003c/p\u003e\u003cp\u003ep1=[3     2     5     1     0     2 ]\u003c/p\u003e\u003cp\u003ep2=[1     2     0     5     0     3]\u003c/p\u003e\u003cp\u003eThen q=[3] r=[0    -4     5   -14     0    -7]\u003c/p\u003e","function_template":"function [q,r] = DivPol(p1,p2)\r\n  y = x;\r\nend","test_suite":"%%\r\np1=[3 2 5 1 0 2 ]\r\np2=[1 2 0 5 0 3]\r\n\r\nq_correct=[3] \r\nr_correct=[0 -4 5 -14 0 -7]\r\n[q,r]=DivPol(p1,p2)\r\n\r\nassert(isequal(q,q_correct))\r\nassert(isequal(r,r_correct))\r\n%%\r\np1=[-2 0 3 -5 -6 5 -1 0 16 8]\r\np2=[1 0 -1 2 4]\r\n\r\nq_correct=[-2     0     1    -1     3     2] \r\nr_correct=[0 0 0 0 0 0 0 0 0 0]\r\n[q,r]=DivPol(p1,p2)\r\n\r\nassert(isequal(q,q_correct))\r\nassert(isequal(r,r_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":90467,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":62,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-24T23:36:33.000Z","updated_at":"2025-12-07T16:44:49.000Z","published_at":"2016-10-24T23:36:33.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDivide polynomial p1 by p2 given as vectors. Return result q and r vectors which corresponds the quotient and remainder of division respectively.\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\u003ep1=[3 2 5 1 0 2 ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ep2=[1 2 0 5 0 3]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThen q=[3] r=[0 -4 5 -14 0 -7]\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":336,"title":"Similar Triangles - find the height of the tree","description":"Given the height, h1, of a power pole, shorter than a tree, a given distance, x2 away, please find h2, height of the tree. Please note that the angle, phi, is the acute angle measured from the ground to an observer's line of sight aimed to the sucessive peaks of the power pole and the tree, in that order. Also the distance from the observer to the power pole is x1, also a given. x2 is the distance between the tree and the power pole. In all tests x1 is always a multiple of x2.\r\n\r\n\r\nInputs: h1, x1, x2\r\n\r\nOutput: h2\r\n\r\nHINT: find phi, given h1 and x1. Phi may be measured in degrees or radians. Note that default trig functions in MATLAB operate in radians.\r\n\r\nEX:\r\nx1 = 4;\r\nx2 = 4;\r\nh1 = 3;\r\n\r\n\u003e\u003eh2=findHeight(x1,x2,h1)\r\n\r\nh2=6\r\n\r\n\u003e\u003e","description_html":"\u003cp\u003eGiven the height, h1, of a power pole, shorter than a tree, a given distance, x2 away, please find h2, height of the tree. Please note that the angle, phi, is the acute angle measured from the ground to an observer's line of sight aimed to the sucessive peaks of the power pole and the tree, in that order. Also the distance from the observer to the power pole is x1, also a given. x2 is the distance between the tree and the power pole. In all tests x1 is always a multiple of x2.\u003c/p\u003e\u003cp\u003eInputs: h1, x1, x2\u003c/p\u003e\u003cp\u003eOutput: h2\u003c/p\u003e\u003cp\u003eHINT: find phi, given h1 and x1. Phi may be measured in degrees or radians. Note that default trig functions in MATLAB operate in radians.\u003c/p\u003e\u003cp\u003eEX:\r\nx1 = 4;\r\nx2 = 4;\r\nh1 = 3;\u003c/p\u003e\u003cp\u003e\u003e\u003eh2=findHeight(x1,x2,h1)\u003c/p\u003e\u003cp\u003eh2=6\u003c/p\u003e\u003cp\u003e\u003e\u003e\u003c/p\u003e","function_template":"function h2 = findHeight(x1,x2,h1)\r\n  h2 = heightoftree\r\nend","test_suite":"%%\r\nx1 = 4;\r\nx2 = 4;\r\nh1 = 3;\r\ny_correct = 6;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 8;\r\nh1 = 3;\r\ny_correct = 9;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 12;\r\nh1 = 3;\r\ny_correct = 12;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 16;\r\nh1 = 3;\r\ny_correct = 15;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 20;\r\nh1 = 3;\r\ny_correct = 18;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 24;\r\nh1 = 3;\r\ny_correct = 21;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 12;\r\nh1 = 5;\r\ny_correct = 20;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 16;\r\nh1 = 10;\r\ny_correct = 50;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 2;\r\nx2 = 4;\r\nh1 = 5;\r\ny_correct = 15;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 3;\r\nx2 = 6;\r\nh1 = 4;\r\ny_correct = 12;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":6,"created_by":1103,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":469,"test_suite_updated_at":"2012-02-18T04:42:47.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-02-17T22:52:21.000Z","updated_at":"2026-03-13T05:26:44.000Z","published_at":"2012-02-18T04:42:47.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 the height, h1, of a power pole, shorter than a tree, a given distance, x2 away, please find h2, height of the tree. Please note that the angle, phi, is the acute angle measured from the ground to an observer's line of sight aimed to the sucessive peaks of the power pole and the tree, in that order. Also the distance from the observer to the power pole is x1, also a given. x2 is the distance between the tree and the power pole. In all tests x1 is always a multiple of x2.\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\u003eInputs: h1, x1, x2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: h2\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\u003eHINT: find phi, given h1 and x1. Phi may be measured in degrees or radians. Note that default trig functions in MATLAB operate in radians.\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\u003eEX: x1 = 4; x2 = 4; h1 = 3;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003e\u003eh2=findHeight(x1,x2,h1)\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\u003eh2=6\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003e\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":54020,"title":"Circle Division","description":"A circle can be divided into 2 sections, by placing 2 points in arbitrary locations along its circumference and drawing a straight line between them. By adding more points and drawing a straight line from each point to every other point, the circle can be divided into more sections. For example, 3 points would divide the circle into 4 sections and 4 points into 8 sections.\r\nGiven a positive integer, n, representing the number of arbitrarily placed points on the circumference of a circle, return d, i and s, the number of straight lines, the number of intersections and the number of sections into which the circle is divided, respectively.\r\nThe only restriction on the positions of the points is that they must be placed such that no 3 lines can share a single intersection.\r\nn will always be greater than 3.\r\nExample:\r\nn = 4;\r\nd = 6\r\ni = 1\r\ns = 8\r\nExample:\r\nn = 5;\r\nd = 10\r\ni = 5\r\ns = 16","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 460.5px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 230.25px; transform-origin: 407px 230.25px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eA circle can be divided into 2 sections, by placing 2 points in arbitrary locations along its circumference and drawing a straight line between them. By adding more points and drawing a straight line from each point to every other point, the circle can be divided into more sections. For example, 3 points would divide the circle into 4 sections and 4 points into 8 sections.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eGiven a positive integer, n, representing the number of arbitrarily placed points on the circumference of a circle, return d, i and s, the number of straight lines, the number of intersections and the number of sections into which the circle is divided, respectively.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eThe only restriction on the positions of the points is that they must be placed such that no 3 lines can share a single intersection.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003en will always be greater than 3.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.75px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.875px; transform-origin: 404px 40.875px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003en = 4;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ed = 6\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ei = 1\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003es = 8\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.75px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.875px; transform-origin: 404px 40.875px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003en = 5;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ed = 10\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ei = 5\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2188px; transform-origin: 404px 10.2188px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003es = 16\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [d,i,s] = your_fcn_name(n)\r\n    d = 1;\r\n    i = 1;\r\n    s = 1;\r\nend","test_suite":"%%\r\nfiletext = fileread('your_fcn_name.m');\r\nassert(isempty(strfind(filetext,'eval')))\r\nassert(isempty(strfind(filetext,'echo')))\r\nassert(isempty(strfind(filetext,'switch')))\r\nassert(isempty(strfind(filetext,'regexp')))\r\n\r\n%%\r\n[d,i,s] = your_fcn_name(4);\r\nassert(isequal([d i s],[6 1 8]))\r\n\r\n%%\r\n[d,i,s] = your_fcn_name(5);\r\nassert(isequal([d i s],[10 5 16]))\r\n\r\n%%\r\n[d,i,s] = your_fcn_name(7);\r\nassert(isequal([d i s],[21 35 57]))\r\n\r\n%%\r\n[d,i,s] = your_fcn_name(13);\r\nassert(isequal([d i s],[78 715 794]))\r\n\r\n%%\r\n[d,i,s] = your_fcn_name(53);\r\nassert(isequal([d i s],[1378 292825 294204]))\r\n\r\n%%\r\n[d,i,s] = your_fcn_name(100);\r\nassert(isequal([d i s],[4950 3921225 3926176]))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":15521,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":8,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-02-18T20:04:46.000Z","updated_at":"2025-12-02T20:17:27.000Z","published_at":"2022-02-18T20:04:46.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA circle can be divided into 2 sections, by placing 2 points in arbitrary locations along its circumference and drawing a straight line between them. By adding more points and drawing a straight line from each point to every other point, the circle can be divided into more sections. For example, 3 points would divide the circle into 4 sections and 4 points into 8 sections.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a positive integer, n, representing the number of arbitrarily placed points on the circumference of a circle, return d, i and s, the number of straight lines, the number of intersections and the number of sections into which the circle is divided, respectively.\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 only restriction on the positions of the points is that they must be placed such that no 3 lines can share a single intersection.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en will always be greater than 3.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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[n = 4;\\nd = 6\\ni = 1\\ns = 8]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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[n = 5;\\nd = 10\\ni = 5\\ns = 16]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":42316,"title":"Fraction of a fraction of a ...","description":"One sort of brainteaser problem is a math problem wherein you are asked what the given fraction of a fraction of a ... number is. For example,\r\n\r\n* What is one-seventh of two-ninths of 630?\r\n\r\nYou will be supplied with various strings of this format (minus the \"What is\" at the beginning and the question mark at the end. Write a function to translate the string and calculate the value. Hyphens will always be present between top and bottom values of fractions while \"of\" can be replaced by a multiplication symbol. Also, make sure you capture singular and plural fractions. In this case, the translated string might look something like this:\r\n\r\n* 1/7 * 2/9 * 630\r\n\r\nwhich, when evaluated, will yield 20. See the test suite for more examples.","description_html":"\u003cp\u003eOne sort of brainteaser problem is a math problem wherein you are asked what the given fraction of a fraction of a ... number is. For example,\u003c/p\u003e\u003cul\u003e\u003cli\u003eWhat is one-seventh of two-ninths of 630?\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou will be supplied with various strings of this format (minus the \"What is\" at the beginning and the question mark at the end. Write a function to translate the string and calculate the value. Hyphens will always be present between top and bottom values of fractions while \"of\" can be replaced by a multiplication symbol. Also, make sure you capture singular and plural fractions. In this case, the translated string might look something like this:\u003c/p\u003e\u003cul\u003e\u003cli\u003e1/7 * 2/9 * 630\u003c/li\u003e\u003c/ul\u003e\u003cp\u003ewhich, when evaluated, will yield 20. See the test suite for more examples.\u003c/p\u003e","function_template":"function [val] = fraction_of_a(frac_str)\r\n\r\nval = 1;\r\n\r\nend\r\n","test_suite":"%%\r\nfrac_str = 'two-sevenths of five-ninths of three-eighths of 168';\r\nassert(isequal(round(fraction_of_a(frac_str)),10))\r\n\r\n%%\r\nfrac_str = 'one-fifth of four-halfs of three-fourths of 100';\r\nassert(isequal(round(fraction_of_a(frac_str)),30))\r\n\r\n%%\r\nfrac_str = 'two-thirds of three-fourths of one-fifth of 150';\r\nassert(isequal(round(fraction_of_a(frac_str)),15))\r\n\r\n%%\r\nfrac_str = 'five-sevenths of four-fifths of three-halfs of two-sixths of one-fourth of 210';\r\nassert(isequal(round(fraction_of_a(frac_str)),15))\r\n\r\n%%\r\nfrac_str = 'one-seventh of two-ninths of 630';\r\nassert(isequal(round(fraction_of_a(frac_str)),20))\r\n\r\n%%\r\nfrac_str = 'one-half of three-fifths of two-thirds of three-fourths of 1000';\r\nassert(isequal(round(fraction_of_a(frac_str)),150))\r\n\r\n%%\r\nfrac_str = 'one-half of two-thirds of three-fourths of four-fifths of five-sixths of six-sevenths of seven-eighths of eight-ninths of 36288';\r\nassert(isequal(round(fraction_of_a(frac_str)),4032))\r\n\r\n%%\r\nfrac_str = 'one-ninth of two-eighths of three-sevenths of four-sixths of five-fifths of six-fourths of seven-thirds of eight-halfs of 36288';\r\nassert(isequal(round(fraction_of_a(frac_str)),4032))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tfrac_str = 'two-sevenths of five-ninths of three-eighths of 168';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),10))\r\n\tcase 2\r\n\t\tfrac_str = 'one-fifth of four-halfs of three-fourths of 100';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),30))\r\n\tcase 3\r\n\t\tfrac_str = 'two-thirds of three-fourths of one-fifth of 150';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),15))\r\n\tcase 4\r\n\t\tfrac_str = 'one-ninth of two-eighths of three-sevenths of four-sixths of five-fifths of six-fourths of seven-thirds of eight-halfs of 36288';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),4032))\r\nend\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tfrac_str = 'one-half of two-thirds of three-fourths of four-fifths of five-sixths of six-sevenths of seven-eighths of eight-ninths of 36288';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),4032))\r\n\tcase 2\r\n\t\tfrac_str = 'one-fifth of four-halfs of three-fourths of 100';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),30))\r\n\tcase 3\r\n\t\tfrac_str = 'one-seventh of two-ninths of 630';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),20))\r\n\tcase 4\r\n\t\tfrac_str = 'two-thirds of three-fourths of one-fifth of 150';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),15))\r\nend\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tfrac_str = 'one-fifth of four-halfs of three-fourths of 100';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),30))\r\n\tcase 2\r\n\t\tfrac_str = 'two-sevenths of five-ninths of three-eighths of 168';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),10))\r\n\tcase 3\r\n\t\tfrac_str = 'one-half of two-thirds of three-fourths of four-fifths of five-sixths of six-sevenths of seven-eighths of eight-ninths of 36288';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),4032))\r\n\tcase 4\r\n\t\tfrac_str = 'one-seventh of two-ninths of 630';\r\n\t\tassert(isequal(round(fraction_of_a(frac_str)),20))\r\nend\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":19,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-05-17T01:22:29.000Z","updated_at":"2025-11-03T11:31:32.000Z","published_at":"2015-05-17T01:22:29.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eOne sort of brainteaser problem is a math problem wherein you are asked what the given fraction of a fraction of a ... number is. For example,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWhat is one-seventh of two-ninths of 630?\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will be supplied with various strings of this format (minus the \\\"What is\\\" at the beginning and the question mark at the end. Write a function to translate the string and calculate the value. Hyphens will always be present between top and bottom values of fractions while \\\"of\\\" can be replaced by a multiplication symbol. Also, make sure you capture singular and plural fractions. In this case, the translated string might look something like this:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1/7 * 2/9 * 630\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\u003ewhich, when evaluated, will yield 20. See the test suite for more examples.\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":44357,"title":"Back to basics:  throwing errors / exceptions","description":"*Throwing and handling errors (or exceptions) is an important part of practical programming.*  \r\n\r\nHere your task is to provide an alternative to the built in elementwise division operator *./* (equivalent to the \u003chttp://au.mathworks.com/help/fixedpoint/ref/rdivide.html rdivide\u003e function) with the following differences:\r\n\r\n# throws an error if _any_ of the input elements have a non-zero \u003chttps://en.wikipedia.org/wiki/Imaginary_number imaginary component\u003e (and are therefore 'complex numbers' that are incapable of being correctly represented as real numbers);\r\n# throws an error if _any_ of the input elements are \u003chttp://au.mathworks.com/help/matlab/ref/char.html character arrays\u003e;\r\n# yields \u003chttp://au.mathworks.com/help/matlab/ref/nan.html NaN\u003e wherever the divisor (i.e. the denominator) is equal to zero.\r\n\r\nThis concept is analogous to the built in MATLAB function \u003chttp://au.mathworks.com/help/matlab/ref/realsqrt.html \"realsqrt\"\u003e.\r\n\r\nThe first error must generate an MException with the following properties: identifier = 'realDivision:complexInput',  message = 'The realDivision function only operates on real inputs.'.\r\n\r\nThe second error must generate an MException with the following properties: identifier = 'realDivision:incompatibleInput',  message = 'The realDivision function is not defined for character inputs.'.\r\n\r\nAll other behaviour should be identical to the mrdivide function.  Any exceptions that would have been thrown by mrdivide should also be thrown by your function — with the same contents of the identifier and message fields.  \r\n\r\nNote that the difference in MATLAB between \u003chttp://au.mathworks.com/help/matlab/ref/error.html errors\u003e and \u003chttp://au.mathworks.com/help/matlab/ref/mexception-class.html exceptions\u003e is \u003chttps://au.mathworks.com/matlabcentral/answers/116197-there-seems-to-be-two-different-methods-of-error-handling-in-matlab-error-handling-and-exception somewhat fraught\u003e.  ","description_html":"\u003cp\u003e\u003cb\u003eThrowing and handling errors (or exceptions) is an important part of practical programming.\u003c/b\u003e\u003c/p\u003e\u003cp\u003eHere your task is to provide an alternative to the built in elementwise division operator \u003cb\u003e./\u003c/b\u003e (equivalent to the \u003ca href = \"http://au.mathworks.com/help/fixedpoint/ref/rdivide.html\"\u003erdivide\u003c/a\u003e function) with the following differences:\u003c/p\u003e\u003col\u003e\u003cli\u003ethrows an error if \u003ci\u003eany\u003c/i\u003e of the input elements have a non-zero \u003ca href = \"https://en.wikipedia.org/wiki/Imaginary_number\"\u003eimaginary component\u003c/a\u003e (and are therefore 'complex numbers' that are incapable of being correctly represented as real numbers);\u003c/li\u003e\u003cli\u003ethrows an error if \u003ci\u003eany\u003c/i\u003e of the input elements are \u003ca href = \"http://au.mathworks.com/help/matlab/ref/char.html\"\u003echaracter arrays\u003c/a\u003e;\u003c/li\u003e\u003cli\u003eyields \u003ca href = \"http://au.mathworks.com/help/matlab/ref/nan.html\"\u003eNaN\u003c/a\u003e wherever the divisor (i.e. the denominator) is equal to zero.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eThis concept is analogous to the built in MATLAB function \u003ca href = \"http://au.mathworks.com/help/matlab/ref/realsqrt.html\"\u003e\"realsqrt\"\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eThe first error must generate an MException with the following properties: identifier = 'realDivision:complexInput',  message = 'The realDivision function only operates on real inputs.'.\u003c/p\u003e\u003cp\u003eThe second error must generate an MException with the following properties: identifier = 'realDivision:incompatibleInput',  message = 'The realDivision function is not defined for character inputs.'.\u003c/p\u003e\u003cp\u003eAll other behaviour should be identical to the mrdivide function.  Any exceptions that would have been thrown by mrdivide should also be thrown by your function — with the same contents of the identifier and message fields.\u003c/p\u003e\u003cp\u003eNote that the difference in MATLAB between \u003ca href = \"http://au.mathworks.com/help/matlab/ref/error.html\"\u003eerrors\u003c/a\u003e and \u003ca href = \"http://au.mathworks.com/help/matlab/ref/mexception-class.html\"\u003eexceptions\u003c/a\u003e is \u003ca href = \"https://au.mathworks.com/matlabcentral/answers/116197-there-seems-to-be-two-different-methods-of-error-handling-in-matlab-error-handling-and-exception\"\u003esomewhat fraught\u003c/a\u003e.\u003c/p\u003e","function_template":"function q = realDivision(a, b)\r\n    q = realsqrt(a, b);\r\nend","test_suite":"%% Test 1\r\na = 10;\r\nb = 5;\r\n%disp(a ./ b)\r\nq_correct = 2;\r\nq = realDivision(a, b);\r\nassert( isequal(q, q_correct) )\r\n\r\n\r\n%% Test 2\r\na = [100:2:300; 400:2:600];\r\nb = 2;\r\n%disp(a ./ b)\r\nq_correct = [50:150; 200:300];\r\nq = realDivision(a, b);\r\nassert( isequal(q, q_correct) )\r\n\r\n\r\n%% Test 3\r\na = 24;\r\nb = [1 2 3 4 6 8 12 24];\r\n%disp(a ./ b)\r\nq_correct = [24 12 8 6 4 3 2 1];\r\nq = realDivision(a, b);\r\nassert( isequal(q, q_correct) )\r\n\r\n\r\n%% Test 4\r\na = sqrt(-4);\r\nb = 2;\r\n%disp(a ./ b)\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    %disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\ne_correct.identifier = 'realDivision:complexInput';\r\ne_correct.message = 'The realDivision function only operates on real inputs.';\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 5\r\na = 12 * randi(8, 10);\r\nb = randi(4, 10);\r\nrNum = randi(10);\r\ncNum = randi(10);\r\ncplx = 12 * randi(8) * sqrt(-1);\r\nif rand() \u003c 0.5, \r\n    a(rNum, cNum) = a(rNum, cNum) + cplx;\r\nelse\r\n    b(rNum, cNum) = b(rNum, cNum) - cplx;\r\nend;\r\n%disp(a ./ b)\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    %disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\ne_correct.identifier = 'realDivision:complexInput';\r\ne_correct.message = 'The realDivision function only operates on real inputs.';\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 6\r\na = 'MATLAB';\r\nb = 'coding';\r\n%disp(a ./ b)\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    %disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\ne_correct.identifier = 'realDivision:incompatibleInput';\r\ne_correct.message = 'The realDivision function is not defined for character inputs.';\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 7\r\na = 'MATLAB';\r\nb = 'Cody';\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\ne_correct.identifier = 'realDivision:incompatibleInput';\r\ne_correct.message = 'The realDivision function is not defined for character inputs.';\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 8\r\na = \"Computing\";\r\nb = \"Algorithm\";\r\ne_correct.identifier = 'MATLAB:UndefinedFunction';\r\ne_correct.message = char(\"Undefined function 'rdivide' for input arguments of type 'string'.\");\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 9\r\na = {1, 7, 3};\r\nb = {4, 8, 9};\r\ne_correct.identifier = 'MATLAB:UndefinedFunction';\r\ne_correct.message = char(\"Undefined function 'rdivide' for input arguments of type 'cell'.\");\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 10\r\na.itemOne = 10;\r\na.itemTwo = 20;\r\nb.itemOne = 5;\r\nb.itemTwo = 15;\r\ne_correct.identifier = 'MATLAB:UndefinedFunction';\r\ne_correct.message = char(\"Undefined function 'rdivide' for input arguments of type 'struct'.\");\r\ne = [];\r\ntry\r\n    realDivision(a, b)\r\ncatch err\r\n    disp(err); disp(err.stack);\r\n    e = err;\r\nend;\r\n%assert( isequal(e, e_correct) )\r\nassert( isequal(e.identifier, e_correct.identifier) )\r\nassert( isequal(e.message, e_correct.message) )\r\n\r\n\r\n%% Test 11\r\nratio = randi(11) + 1;\r\nb = randi(8, 10);\r\na = ratio * b;\r\nrNum = randi(10);\r\ncNum = randi(10);\r\nb(rNum, cNum) = nan;\r\n%disp(a ./ b)\r\nq_correct = ratio * ones(10);\r\nq_correct(rNum, cNum) = NaN;\r\nq = realDivision(a, b);\r\nassert( isequal(q(~isnan(q)), q_correct(~isnan(q_correct))) )\r\nassert( isequal(size(q), size(q_correct)) )\r\nassert( isequal(isnan(q), isnan(q_correct)) )\r\n\r\n\r\n%% Test 12\r\nratio = randi(11) + 1;\r\nb = randi(8, 10);\r\na = ratio * b;\r\nrNum = randi(10);\r\ncNum = randi(10);\r\nb(rNum, cNum) = 0;\r\n%disp(a ./ b)\r\nq_correct = ratio * ones(10);\r\nq_correct(rNum, cNum) = nan;\r\nq = realDivision(a, b);\r\nassert( isequal(q(~isnan(q)), q_correct(~isnan(q_correct))) )\r\nassert( isequal(size(q), size(q_correct)) )\r\nassert( isequal(isnan(q), isnan(q_correct)) )\r\n\r\n\r\n%% Test 13\r\nratio = randi(11) + 1;\r\nb = randi(8, 10);\r\na = ratio * b;\r\nidxNum = randi(100, [1, 5]);\r\nb(idxNum) = complex( b(idxNum) );\r\n%disp(a ./ b)\r\nq_correct = ratio * ones(10);\r\nq = realDivision(a, b);\r\nassert( isequal(q, q_correct) )\r\n\r\n\r\n%%\r\n% The first error must generate an MException with the following properties: \r\n% identifier = 'realDivision:complexInput',  message = 'The realDivision function only operates on real inputs.'.\r\n% \r\n% The second error must generate an MException with the following properties: \r\n% identifier = 'realDivision:incompatibleInput',  message = 'The realDivision function is not defined for character inputs.'.\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":6,"test_suite_updated_at":"2017-10-05T10:41:09.000Z","rescore_all_solutions":false,"group_id":677,"created_at":"2017-10-03T13:05:21.000Z","updated_at":"2019-05-02T17:03:22.000Z","published_at":"2017-10-04T05:08:09.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eThrowing and handling errors (or exceptions) is an important part of practical programming.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHere your task is to provide an alternative to the built in elementwise division operator\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e./\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (equivalent to the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/fixedpoint/ref/rdivide.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erdivide\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e function) with the following differences:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethrows an error if\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eany\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of the input elements have a non-zero\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Imaginary_number\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eimaginary component\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (and are therefore 'complex numbers' that are incapable of being correctly represented as real numbers);\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethrows an error if\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eany\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of the input elements are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/char.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003echaracter arrays\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eyields\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/nan.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eNaN\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e wherever the divisor (i.e. the denominator) is equal to zero.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis concept is analogous to the built in MATLAB function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/realsqrt.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"realsqrt\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe first error must generate an MException with the following properties: identifier = 'realDivision:complexInput', message = 'The realDivision function only operates on real inputs.'.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe second error must generate an MException with the following properties: identifier = 'realDivision:incompatibleInput', message = 'The realDivision function is not defined for character inputs.'.\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\u003eAll other behaviour should be identical to the mrdivide function. Any exceptions that would have been thrown by mrdivide should also be thrown by your function — with the same contents of the identifier and message fields.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNote that the difference in MATLAB between\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/error.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eerrors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/mexception-class.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eexceptions\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://au.mathworks.com/matlabcentral/answers/116197-there-seems-to-be-two-different-methods-of-error-handling-in-matlab-error-handling-and-exception\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esomewhat fraught\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"division\"","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:\"division\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"division\"","","\"","division","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f250d05d0c8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f250d05d028\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f250d05c768\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f250d05d488\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f250d05d3e8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f250d05d2a8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f250d05d168\u003e":"tag:\"division\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f250d05d168\u003e":"tag:\"division\""},"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:\"division\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"division\"","","\"","division","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f250d05d0c8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f250d05d028\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f250d05c768\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f250d05d488\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f250d05d3e8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f250d05d2a8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f250d05d168\u003e":"tag:\"division\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f250d05d168\u003e":"tag:\"division\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":42846,"difficulty_rating":"easy"},{"id":2959,"difficulty_rating":"easy"},{"id":60836,"difficulty_rating":"easy"},{"id":44331,"difficulty_rating":"easy"},{"id":42590,"difficulty_rating":"easy"},{"id":43154,"difficulty_rating":"easy"},{"id":45767,"difficulty_rating":"easy-medium"},{"id":43619,"difficulty_rating":"easy-medium"},{"id":336,"difficulty_rating":"easy-medium"},{"id":54020,"difficulty_rating":"easy-medium"},{"id":42316,"difficulty_rating":"medium"},{"id":44357,"difficulty_rating":"medium"}]}}