{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-16T00:12:35.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-04-16T00: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":44675,"title":"Find prime number couples","description":"Given a vector a, which will always contain at least one pair of prime numbers couple, return a matrix called 'couple' in which each row contains one pair of prime couples. A prime number couple pair are two prime numbers with a difference of two between them. Keep in mind that the numbers 2, 3, 5, and 7 are prime numbers.\r\n\r\nFor example, if a=[1 2 3 6 11 13 101 103], the output should be couple=[11 13; 101 103].","description_html":"\u003cp\u003eGiven a vector a, which will always contain at least one pair of prime numbers couple, return a matrix called 'couple' in which each row contains one pair of prime couples. A prime number couple pair are two prime numbers with a difference of two between them. Keep in mind that the numbers 2, 3, 5, and 7 are prime numbers.\u003c/p\u003e\u003cp\u003eFor example, if a=[1 2 3 6 11 13 101 103], the output should be couple=[11 13; 101 103].\u003c/p\u003e","function_template":"function couple = find_prime_couples(a)\r\n\r\nend","test_suite":"%%\r\na=[1 4 6 7 8 11 13 16 23 29 31];\r\ncouple=[11 13; 29 31];\r\nassert(isequal(find_prime_couples(a),couple))\r\n%%\r\na=[16\t97\t88\t49\t41\t13\t93\t1\t19\t33\t6\t15\t73\t49\t34\t24\t46\t19\t33\t27\t84\t70\t34\t59\t29\t27\t26\t68\t52\t8\t6\t26\t44\t29\t68\t95\t78\t64\t76\t75\t59\t78\t40\t61\t25\t30\t2\t35\t15\t42\t16\t83\t74\t10\t83\t23\t11\t67\t96\t82\t63\t33\t28\t44\t36\t88\t1\t70\t34\t31\t65\t93\t90\t100\t8\t13\t99\t10\t69\t93\t15\t89\t2\t35\t24\t99\t85\t80\t91\t79\t84\t33\t75\t67\t29\t34\t91\t4\t70\t21];\r\ncouple=[11 13; 29 31; 59 61];\r\nassert(isequal(find_prime_couples(a),couple))\r\n%%\r\na=[2 3\t5 7\t11\t13\t17\t19\t23\t29\t31\t37\t41\t43\t47\t53\t59\t61\t67\t71\t73\t79\t83\t89\t97\t101\t103\t107\t109\t113\t127\t131\t137\t139\t149\t151\t157\t163\t167\t173\t179\t181\t191\t193\t197\t199];\r\ncouple=[3\t5;\r\n5\t7;\r\n11\t13;\r\n17\t19;\r\n29\t31;\r\n41\t43;\r\n59\t61;\r\n71\t73;\r\n101\t103;\r\n107\t109;\r\n137\t139;\r\n149\t151;\r\n179\t181;\r\n191\t193;\r\n197\t199];\r\nassert(isequal(find_prime_couples(a),couple))","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":183778,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":27,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-06-06T14:10:53.000Z","updated_at":"2026-04-14T13:14:48.000Z","published_at":"2018-06-06T14:10:53.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a vector a, which will always contain at least one pair of prime numbers couple, return a matrix called 'couple' in which each row contains one pair of prime couples. A prime number couple pair are two prime numbers with a difference of two between them. Keep in mind that the numbers 2, 3, 5, and 7 are prime numbers.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, if a=[1 2 3 6 11 13 101 103], the output should be couple=[11 13; 101 103].\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":1509,"title":"Fast Fourier transform algorithm","description":"Your task is to implement the Fast Fourier transform algorithm, without using builtin MATLAB fft commands e.g. fft, fft2, or hardcoded numeric answers in the test case. The test suite employs regular expression matching to reject such solutions.\r\nCreative hacking attempts are appreciated. While I will update the test case accordingly, I'll send you some MathWorks swag if you're the first to demonstrate a new way to get the Test Suite to pass (maybe a t-shirt or coffee mug, you'll have to try and see :-) Jose', yours is on the way.\r\nreference: http://en.wikipedia.org/wiki/Fast_Fourier_transform","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: 144px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 72px; transform-origin: 407px 72px; 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: 381.5px 8px; transform-origin: 381.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eYour task is to implement the Fast Fourier transform algorithm, without using builtin MATLAB fft commands e.g. fft, fft2, or hardcoded numeric answers in the test case. The test suite employs regular expression matching to reject such solutions.\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: 373.5px 8px; transform-origin: 373.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCreative hacking attempts are appreciated. While I will update the test case accordingly, I'll send you some MathWorks swag if you're the first to demonstrate a new way to get the Test Suite to pass (maybe a t-shirt or coffee mug, you'll have to try and see :-) Jose', yours is on the way.\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: 32.5px 8px; transform-origin: 32.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ereference:\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/1509-fast-fourier-transform-algorithm/edit#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ehttp://en.wikipedia.org/wiki/Fast_Fourier_transform\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = fast_fourier(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(exist('fast_fourier.m'),2))\r\n%%\r\n%%\r\nfiletext = fileread('fast_fourier.m');\r\nassert(isempty(strfind(filetext, 'fft')))\r\nassert(isempty(strfind(filetext, 'regexp')))\r\n\r\n%%\r\nfor k=5:50\r\n  x = [11;k;2];\r\n  y_correct = fft(x);\r\n  assert(all(abs(fast_fourier(x)-y_correct)\u003c1e-4))\r\nend","published":true,"deleted":false,"likes_count":0,"comments_count":3,"created_by":5657,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2022-01-02T19:35:37.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-05-14T14:47:34.000Z","updated_at":"2022-01-02T19:35:37.000Z","published_at":"2013-05-14T14:47:34.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\u003eYour task is to implement the Fast Fourier transform algorithm, without using builtin MATLAB fft commands e.g. fft, fft2, or hardcoded numeric answers in the test case. The test suite employs regular expression matching to reject such solutions.\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\u003eCreative hacking attempts are appreciated. While I will update the test case accordingly, I'll send you some MathWorks swag if you're the first to demonstrate a new way to get the Test Suite to pass (maybe a t-shirt or coffee mug, you'll have to try and see :-) Jose', yours is on the way.\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\u003ereference:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://en.wikipedia.org/wiki/Fast_Fourier_transform\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1032,"title":"compare strings","description":"Given 2 strings and 3 actions (Insert,delete,replace) on characters. Find the difference between two strings.\r\n\r\nExample:\r\n\r\nstring1 = 'spring'\r\n\r\nstring2 = 'strange'\r\n\r\nreplace(p,t), replace(i,a), insert(e) = 3 actions = 3 differences\r\n\r\nso the answer is 3","description_html":"\u003cp\u003eGiven 2 strings and 3 actions (Insert,delete,replace) on characters. Find the difference between two strings.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003estring1 = 'spring'\u003c/p\u003e\u003cp\u003estring2 = 'strange'\u003c/p\u003e\u003cp\u003ereplace(p,t), replace(i,a), insert(e) = 3 actions = 3 differences\u003c/p\u003e\u003cp\u003eso the answer is 3\u003c/p\u003e","function_template":"function d = findDifference(str1,str2)\r\n  d = length(str1)-length(str2);\r\nend","test_suite":"%%\r\nstr1 = 'spring';\r\nstr2 = 'strange';\r\nd_correct = 3;\r\nassert(isequal(findDifference(str1,str2),d_correct))\r\n%%\r\nstr1 = 'this';\r\nstr2 = 'has';\r\nd_correct = 2;\r\nassert(isequal(findDifference(str1,str2),d_correct))\r\n%%\r\nstr1 = 'acgtacgtacgt';\r\nstr2 = 'acatacttgtact';\r\nd_correct = 4;\r\nassert(isequal(findDifference(str1,str2),d_correct))\r\n%%\r\nstr1 = 'fractapertornisem';\r\nstr2 = 'alfracchaperitonism';\r\nd_correct = 7;\r\nassert(isequal(findDifference(str1,str2),d_correct))\r\n%%\r\nstr1 = 'spring';\r\nstr2 = 'spring';\r\nd_correct = 0;\r\nassert(isequal(findDifference(str1,str2),d_correct))\r\n%%\r\nstr1 = 'qazwsxedcrfvtgb';\r\nstr2 = 'qazwsmedcvfr';\r\nd_correct = 6;\r\nassert(isequal(findDifference(str1,str2),d_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":4320,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":32,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-11-14T11:22:25.000Z","updated_at":"2025-12-14T16:53:53.000Z","published_at":"2012-11-14T11:22:25.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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 2 strings and 3 actions (Insert,delete,replace) on characters. Find the difference between two strings.\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\u003estring1 = 'spring'\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\u003estring2 = 'strange'\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\u003ereplace(p,t), replace(i,a), insert(e) = 3 actions = 3 differences\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\u003eso the answer is 3\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":2191,"title":"Order of things - 3","description":"This problem is closely related to \u003chttp://www.mathworks.nl/matlabcentral/cody/problems/2189-order-of-things-1 Problem 2189, Order of things - 1\u003e and \u003chttp://www.mathworks.nl/matlabcentral/cody/problems/2190-order-of-things-2 Problem 2190, Order of things - 2\u003e. For the details, see the description for those problems. Basically, we have to find the order in which to execute tasks of which the results and prerequisites depend on each other. \r\n\r\n* However, this time the tasks are grouped, and groups of tasks should be executed at once.\r\n* It may (still) be impossible to find a solution, since dependencies may be cyclic. But this may now also be due to the grouping of tasks. In any case, return an empty vector if no order is found.\r\n* There are still multiple orders possible, return them as multiple rows of the output vector.\r\n* The tasks within a group should of course be specified in the right order, when interdependent.\r\n\r\nThe dependencies of the tasks on each other is expressed in a matrix, where each row corresponds to the execution of a task, and each column to the dependency. \r\n\r\n   A  B  C  D  E\r\nA  0  0  0  0  0\r\nB  0  0  0  0  0\r\nC  0  1  0  0  0\r\nD  0  1  1  0  0\r\nE  1  0  0  0  0\r\n\r\nThe |1| on row |C|, column |B|, indicates that task |C| depends on task |B|. \r\n\r\nThe grouping of tasks is expressed as an input vector with groups assigned an integer value \u003e 0, e.g.\r\n\r\n [ 1 1 2 3 3 ] \r\n\r\nReturn the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. If multiple orders exist, return them all as rows of a matrix. In this example:\r\n\r\n [ \r\n   1 2 3 4 5\r\n   1 2 3 5 4\r\n   2 1 3 4 5\r\n   2 1 3 5 4\r\n ]\r\n\r\nIf no order fulfilling the dependencies exists, return an empty vector.","description_html":"\u003cp\u003eThis problem is closely related to \u003ca href = \"http://www.mathworks.nl/matlabcentral/cody/problems/2189-order-of-things-1\"\u003eProblem 2189, Order of things - 1\u003c/a\u003e and \u003ca href = \"http://www.mathworks.nl/matlabcentral/cody/problems/2190-order-of-things-2\"\u003eProblem 2190, Order of things - 2\u003c/a\u003e. For the details, see the description for those problems. Basically, we have to find the order in which to execute tasks of which the results and prerequisites depend on each other.\u003c/p\u003e\u003cul\u003e\u003cli\u003eHowever, this time the tasks are grouped, and groups of tasks should be executed at once.\u003c/li\u003e\u003cli\u003eIt may (still) be impossible to find a solution, since dependencies may be cyclic. But this may now also be due to the grouping of tasks. In any case, return an empty vector if no order is found.\u003c/li\u003e\u003cli\u003eThere are still multiple orders possible, return them as multiple rows of the output vector.\u003c/li\u003e\u003cli\u003eThe tasks within a group should of course be specified in the right order, when interdependent.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe dependencies of the tasks on each other is expressed in a matrix, where each row corresponds to the execution of a task, and each column to the dependency.\u003c/p\u003e\u003cpre\u003e   A  B  C  D  E\r\nA  0  0  0  0  0\r\nB  0  0  0  0  0\r\nC  0  1  0  0  0\r\nD  0  1  1  0  0\r\nE  1  0  0  0  0\u003c/pre\u003e\u003cp\u003eThe \u003ctt\u003e1\u003c/tt\u003e on row \u003ctt\u003eC\u003c/tt\u003e, column \u003ctt\u003eB\u003c/tt\u003e, indicates that task \u003ctt\u003eC\u003c/tt\u003e depends on task \u003ctt\u003eB\u003c/tt\u003e.\u003c/p\u003e\u003cp\u003eThe grouping of tasks is expressed as an input vector with groups assigned an integer value \u0026gt; 0, e.g.\u003c/p\u003e\u003cpre\u003e [ 1 1 2 3 3 ] \u003c/pre\u003e\u003cp\u003eReturn the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. If multiple orders exist, return them all as rows of a matrix. In this example:\u003c/p\u003e\u003cpre\u003e [ \r\n   1 2 3 4 5\r\n   1 2 3 5 4\r\n   2 1 3 4 5\r\n   2 1 3 5 4\r\n ]\u003c/pre\u003e\u003cp\u003eIf no order fulfilling the dependencies exists, return an empty vector.\u003c/p\u003e","function_template":"function order = calculation_order(dependencies,groups)\r\n  order  = 1:size(dependencies,1);\r\nend","test_suite":"%%\r\ndependencies = [\r\n0  0  0  0  1\r\n0  0  1  1  0\r\n0  0  0  0  0\r\n0  0  1  0  0\r\n0  0  0  0  0\r\n];\r\ngroups = [ 3  3  1  2  1 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n5  3  4  2  1\r\n5  3  4  1  2\r\n4  3  5  2  1\r\n4  3  5  1  2\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n0  1  0  0  0\r\n0  0  1  0  0\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n1  0  0  1  0\r\n];\r\ngroups = [ 2  2  2  1  2 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n4  3  2  1  5\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n0  1  0  0  0\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n1  0  0  0  1\r\n0  0  1  0  0\r\n];\r\ngroups = [ 1  1  2  3  2 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n2  1  3  5  4\r\n4  3  1  5  2\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n0  0  0  0  0\r\n0  0  1  0  0\r\n0  1  0  0  0\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n];\r\ngroups = [ 5  1  2  3  4 ];\r\norder = calculation_order(dependencies,groups);\r\nassert(isempty(order));\r\n\r\n%%\r\ndependencies = [\r\n0  0  0  0  0\r\n1  0  0  0  0\r\n0  0  0  1  0\r\n0  1  0  0  0\r\n0  0  1  0  0\r\n];\r\ngroups = [ 1  1  2  3  2 ];\r\norder = calculation_order(dependencies,groups);\r\nassert(isempty(order));\r\n\r\n%%\r\ndependencies = [\r\n0  0  0  0  1\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n1  0  0  0  0\r\n];\r\ngroups = [ 2  2  3  1  1 ];\r\norder = calculation_order(dependencies,groups);\r\nassert(isempty(order));\r\n\r\n%%\r\ndependencies_ = ones(10+randi(10));\r\ndependencies_ = dependencies_-triu(dependencies_);\r\norder_ = randperm(size(dependencies_,1));\r\ndependencies = dependencies_(order_,order_);\r\norder_ = 0;\r\norder = calculation_order(dependencies,1:size(dependencies_,1));\r\nordered = dependencies(order,order);\r\nassert(~nnz(triu(ordered-diag(diag(ordered)))));\r\norder = calculation_order(dependencies,ones(1,size(dependencies_,1)));\r\nordered = dependencies(order,order);\r\nassert(~nnz(triu(ordered-diag(diag(ordered)))));\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":6556,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1,"test_suite_updated_at":"2014-02-21T15:59:05.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-02-18T08:50:55.000Z","updated_at":"2014-02-21T15:59:05.000Z","published_at":"2014-02-21T09:38:58.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is closely related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.nl/matlabcentral/cody/problems/2189-order-of-things-1\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2189, Order of things - 1\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://www.mathworks.nl/matlabcentral/cody/problems/2190-order-of-things-2\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2190, Order of things - 2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. For the details, see the description for those problems. Basically, we have to find the order in which to execute tasks of which the results and prerequisites depend on each other.\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\u003eHowever, this time the tasks are grouped, and groups of tasks should be executed at once.\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\u003eIt may (still) be impossible to find a solution, since dependencies may be cyclic. But this may now also be due to the grouping of tasks. In any case, return an empty vector if no order is found.\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\u003eThere are still multiple orders possible, return them as multiple rows of the output vector.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe tasks within a group should of course be specified in the right order, when interdependent.\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 dependencies of the tasks on each other is expressed in a matrix, where each row corresponds to the execution of a task, and each column to the dependency.\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[   A  B  C  D  E\\nA  0  0  0  0  0\\nB  0  0  0  0  0\\nC  0  1  0  0  0\\nD  0  1  1  0  0\\nE  1  0  0  0  0]]\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\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e on row\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eC\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, column\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eB\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, indicates that task\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eC\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e depends on task\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eB\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe grouping of tasks is expressed as an input vector with groups assigned an integer value \u0026gt; 0, e.g.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ [ 1 1 2 3 3 ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. If multiple orders exist, return them all as rows of a matrix. In this example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ [ \\n   1 2 3 4 5\\n   1 2 3 5 4\\n   2 1 3 4 5\\n   2 1 3 5 4\\n ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf no order fulfilling the dependencies exists, return an empty vector.\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":2192,"title":"Order of things - 4","description":"*This is the last assignment in the _Order of Things_-series. If that past incompleteness kept you from solving it, you may start now.* Open that bottle of wine, and spend an entertaining evening coding.\r\n\r\nThis problem is closely related to \u003chttp://www.mathworks.nl/matlabcentral/cody/problems/2189-order-of-things-1 Problem 2189, Order of things - 1\u003e, \u003chttp://www.mathworks.nl/matlabcentral/cody/problems/2190-order-of-things-2 Problem 2190, Order of things - 2\u003e, and \u003chttp://www.mathworks.nl/matlabcentral/cody/problems/2191-order-of-things-3 Problem 2191, Order of things - 3\u003e. For the details, see the description for those problems. Basically, we have to find the order in which to execute tasks of which the results and prerequisites depend on each other. \r\n\r\nHowever, this is the most complex case, as \r\n* Calculations are preferably grouped, but may, due to their dependencies, not all be clustered. So groups of events may be split over different clusters. The number of clusters per group should be kept to a minimum. \r\n\r\nThe same complications as in problem 3 may apply:\r\n* It may (still) be impossible to find a solution, since dependencies may be cyclic. But this is now no longer due to the grouping of tasks, as you may, if necessary, break the rule of grouping. In any case, return an empty vector if no order is found.\r\n* There are still multiple orders possible, return them as multiple rows of the output vector.\r\n* The tasks within a group should of course be specified in the right order, when interdependent.\r\n\r\nThe dependencies of the tasks on each other is expressed in a matrix, where each row corresponds to the execution of a task, and each column to the dependency. \r\n\r\n   A  B  C  D  E\r\nA  0  0  0  0  0\r\nB  0  0  1  0  0\r\nC  1  0  0  0  0\r\nD  0  0  1  0  0\r\nE  1  0  0  0  0\r\n\r\nThe |1| on row |C|, column |B|, indicates that task |C| depends on task |B|. \r\n\r\nThe grouping of tasks is expressed as an input vector with groups assigned an integer value \u003e 0, for every task, e.g. \r\n\r\n [ 1 1 2 2 3 ] \r\n\r\nReturn the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. If multiple orders exist, return them all as rows of a matrix. In this example:\r\n\r\n [ \r\n   1 3 4 2 5\r\n   1 3 4 5 2\r\n   1 5 3 4 2\r\n ]\r\n\r\nIf no order fulfilling the dependencies exists, return an empty vector.","description_html":"\u003cp\u003e\u003cb\u003eThis is the last assignment in the \u003ci\u003eOrder of Things\u003c/i\u003e-series. If that past incompleteness kept you from solving it, you may start now.\u003c/b\u003e Open that bottle of wine, and spend an entertaining evening coding.\u003c/p\u003e\u003cp\u003eThis problem is closely related to \u003ca href = \"http://www.mathworks.nl/matlabcentral/cody/problems/2189-order-of-things-1\"\u003eProblem 2189, Order of things - 1\u003c/a\u003e, \u003ca href = \"http://www.mathworks.nl/matlabcentral/cody/problems/2190-order-of-things-2\"\u003eProblem 2190, Order of things - 2\u003c/a\u003e, and \u003ca href = \"http://www.mathworks.nl/matlabcentral/cody/problems/2191-order-of-things-3\"\u003eProblem 2191, Order of things - 3\u003c/a\u003e. For the details, see the description for those problems. Basically, we have to find the order in which to execute tasks of which the results and prerequisites depend on each other.\u003c/p\u003e\u003cp\u003eHowever, this is the most complex case, as \r\n* Calculations are preferably grouped, but may, due to their dependencies, not all be clustered. So groups of events may be split over different clusters. The number of clusters per group should be kept to a minimum.\u003c/p\u003e\u003cp\u003eThe same complications as in problem 3 may apply:\r\n* It may (still) be impossible to find a solution, since dependencies may be cyclic. But this is now no longer due to the grouping of tasks, as you may, if necessary, break the rule of grouping. In any case, return an empty vector if no order is found.\r\n* There are still multiple orders possible, return them as multiple rows of the output vector.\r\n* The tasks within a group should of course be specified in the right order, when interdependent.\u003c/p\u003e\u003cp\u003eThe dependencies of the tasks on each other is expressed in a matrix, where each row corresponds to the execution of a task, and each column to the dependency.\u003c/p\u003e\u003cpre\u003e   A  B  C  D  E\r\nA  0  0  0  0  0\r\nB  0  0  1  0  0\r\nC  1  0  0  0  0\r\nD  0  0  1  0  0\r\nE  1  0  0  0  0\u003c/pre\u003e\u003cp\u003eThe \u003ctt\u003e1\u003c/tt\u003e on row \u003ctt\u003eC\u003c/tt\u003e, column \u003ctt\u003eB\u003c/tt\u003e, indicates that task \u003ctt\u003eC\u003c/tt\u003e depends on task \u003ctt\u003eB\u003c/tt\u003e.\u003c/p\u003e\u003cp\u003eThe grouping of tasks is expressed as an input vector with groups assigned an integer value \u0026gt; 0, for every task, e.g.\u003c/p\u003e\u003cpre\u003e [ 1 1 2 2 3 ] \u003c/pre\u003e\u003cp\u003eReturn the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. If multiple orders exist, return them all as rows of a matrix. In this example:\u003c/p\u003e\u003cpre\u003e [ \r\n   1 3 4 2 5\r\n   1 3 4 5 2\r\n   1 5 3 4 2\r\n ]\u003c/pre\u003e\u003cp\u003eIf no order fulfilling the dependencies exists, return an empty vector.\u003c/p\u003e","function_template":"function order = calculation_order(dependencies,groups)\r\n  order  = 1:size(dependencies,1);\r\nend","test_suite":"dependencies = [\r\n0  1  0  0  0\r\n0  0  0  0  0\r\n0  0  0  0  1\r\n0  0  0  0  1\r\n0  1  0  0  0\r\n];\r\ngroups = [ 3  1  2  1  2 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n3  2  5  4  1\r\n3  5  2  4  1\r\n5  4  2  3  1\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n0  1  0  0  0\r\n0  0  0  0  0\r\n0  0  0  1  0\r\n0  1  0  0  0\r\n0  0  0  1  0\r\n];\r\ngroups = [ 3  1  1  2  2 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n3  4  2  5  1\r\n3  4  5  2  1\r\n5  3  4  2  1\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n0  0  1  0  0\r\n0  0  0  1  0\r\n0  0  0  1  0\r\n0  0  0  0  0\r\n0  0  1  0  0\r\n];\r\ngroups = [ 1  3  2  1  2 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n2  1  4  5  3\r\n5  1  4  2  3\r\n4  1  3  2  5\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n    0 0 0 0 0\r\n    0 0 0 0 0\r\n    0 1 0 0 0\r\n    0 0 1 0 0\r\n    1 0 0 1 0\r\n    ];\r\ngroups = [1 2 2 2 2];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n    1 2 3 4 5\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n0  0  0  1  0\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n1  0  0  0  0\r\n0  0  0  0  0\r\n];\r\ngroups = [ 1  3  4  2  5 ];\r\norder = calculation_order(dependencies,groups);\r\nassert(isempty(order));\r\n\r\n%%\r\ndependencies = [\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n0  0  0  1  0\r\n0  0  1  0  0\r\n0  0  0  0  0\r\n];\r\ngroups = [ 1  3  2  1  2 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n1  2  4  5  3\r\n1  2  3  5  4\r\n1  5  4  2  3\r\n1  5  3  2  4\r\n1  4  3  2  5\r\n1  3  4  2  5\r\n5  4  3  2  1\r\n5  3  4  2  1\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies_ = ones(randi(10));\r\ndependencies_ = dependencies_-triu(dependencies_);\r\norder_ = randperm(size(dependencies_,1));\r\ndependencies = dependencies_(order_,order_);\r\norder_ = 0;\r\norder = calculation_order(dependencies,1:size(dependencies_,1));\r\nordered = dependencies(order,order);\r\nassert(~nnz(triu(ordered-diag(diag(ordered)))));\r\norder = calculation_order(dependencies,ones(1,size(dependencies_,1)));\r\nordered = dependencies(order,order);\r\nassert(~nnz(triu(ordered-diag(diag(ordered)))));\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":6556,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-02-18T08:57:21.000Z","updated_at":"2014-03-04T07:49:56.000Z","published_at":"2014-03-04T07:49:56.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\u003eThis is the last assignment in the\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:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOrder of Things\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e-series. If that past incompleteness kept you from solving it, you may start now.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Open that bottle of wine, and spend an entertaining evening coding.\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 problem is closely related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.nl/matlabcentral/cody/problems/2189-order-of-things-1\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2189, Order of things - 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.nl/matlabcentral/cody/problems/2190-order-of-things-2\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2190, Order of things - 2\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://www.mathworks.nl/matlabcentral/cody/problems/2191-order-of-things-3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2191, Order of things - 3\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. For the details, see the description for those problems. Basically, we have to find the order in which to execute tasks of which the results and prerequisites depend on each other.\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\u003eHowever, this is the most complex case, as * Calculations are preferably grouped, but may, due to their dependencies, not all be clustered. So groups of events may be split over different clusters. The number of clusters per group should be kept to a minimum.\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 same complications as in problem 3 may apply: * It may (still) be impossible to find a solution, since dependencies may be cyclic. But this is now no longer due to the grouping of tasks, as you may, if necessary, break the rule of grouping. In any case, return an empty vector if no order is found. * There are still multiple orders possible, return them as multiple rows of the output vector. * The tasks within a group should of course be specified in the right order, when interdependent.\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 dependencies of the tasks on each other is expressed in a matrix, where each row corresponds to the execution of a task, and each column to the dependency.\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[   A  B  C  D  E\\nA  0  0  0  0  0\\nB  0  0  1  0  0\\nC  1  0  0  0  0\\nD  0  0  1  0  0\\nE  1  0  0  0  0]]\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\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e on row\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eC\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, column\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eB\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, indicates that task\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eC\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e depends on task\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eB\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe grouping of tasks is expressed as an input vector with groups assigned an integer value \u0026gt; 0, for every task, e.g.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ [ 1 1 2 2 3 ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. If multiple orders exist, return them all as rows of a matrix. In this example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ [ \\n   1 3 4 2 5\\n   1 3 4 5 2\\n   1 5 3 4 2\\n ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf no order fulfilling the dependencies exists, return an empty vector.\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":44675,"title":"Find prime number couples","description":"Given a vector a, which will always contain at least one pair of prime numbers couple, return a matrix called 'couple' in which each row contains one pair of prime couples. A prime number couple pair are two prime numbers with a difference of two between them. Keep in mind that the numbers 2, 3, 5, and 7 are prime numbers.\r\n\r\nFor example, if a=[1 2 3 6 11 13 101 103], the output should be couple=[11 13; 101 103].","description_html":"\u003cp\u003eGiven a vector a, which will always contain at least one pair of prime numbers couple, return a matrix called 'couple' in which each row contains one pair of prime couples. A prime number couple pair are two prime numbers with a difference of two between them. Keep in mind that the numbers 2, 3, 5, and 7 are prime numbers.\u003c/p\u003e\u003cp\u003eFor example, if a=[1 2 3 6 11 13 101 103], the output should be couple=[11 13; 101 103].\u003c/p\u003e","function_template":"function couple = find_prime_couples(a)\r\n\r\nend","test_suite":"%%\r\na=[1 4 6 7 8 11 13 16 23 29 31];\r\ncouple=[11 13; 29 31];\r\nassert(isequal(find_prime_couples(a),couple))\r\n%%\r\na=[16\t97\t88\t49\t41\t13\t93\t1\t19\t33\t6\t15\t73\t49\t34\t24\t46\t19\t33\t27\t84\t70\t34\t59\t29\t27\t26\t68\t52\t8\t6\t26\t44\t29\t68\t95\t78\t64\t76\t75\t59\t78\t40\t61\t25\t30\t2\t35\t15\t42\t16\t83\t74\t10\t83\t23\t11\t67\t96\t82\t63\t33\t28\t44\t36\t88\t1\t70\t34\t31\t65\t93\t90\t100\t8\t13\t99\t10\t69\t93\t15\t89\t2\t35\t24\t99\t85\t80\t91\t79\t84\t33\t75\t67\t29\t34\t91\t4\t70\t21];\r\ncouple=[11 13; 29 31; 59 61];\r\nassert(isequal(find_prime_couples(a),couple))\r\n%%\r\na=[2 3\t5 7\t11\t13\t17\t19\t23\t29\t31\t37\t41\t43\t47\t53\t59\t61\t67\t71\t73\t79\t83\t89\t97\t101\t103\t107\t109\t113\t127\t131\t137\t139\t149\t151\t157\t163\t167\t173\t179\t181\t191\t193\t197\t199];\r\ncouple=[3\t5;\r\n5\t7;\r\n11\t13;\r\n17\t19;\r\n29\t31;\r\n41\t43;\r\n59\t61;\r\n71\t73;\r\n101\t103;\r\n107\t109;\r\n137\t139;\r\n149\t151;\r\n179\t181;\r\n191\t193;\r\n197\t199];\r\nassert(isequal(find_prime_couples(a),couple))","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":183778,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":27,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-06-06T14:10:53.000Z","updated_at":"2026-04-14T13:14:48.000Z","published_at":"2018-06-06T14:10:53.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a vector a, which will always contain at least one pair of prime numbers couple, return a matrix called 'couple' in which each row contains one pair of prime couples. A prime number couple pair are two prime numbers with a difference of two between them. Keep in mind that the numbers 2, 3, 5, and 7 are prime numbers.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, if a=[1 2 3 6 11 13 101 103], the output should be couple=[11 13; 101 103].\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":1509,"title":"Fast Fourier transform algorithm","description":"Your task is to implement the Fast Fourier transform algorithm, without using builtin MATLAB fft commands e.g. fft, fft2, or hardcoded numeric answers in the test case. The test suite employs regular expression matching to reject such solutions.\r\nCreative hacking attempts are appreciated. While I will update the test case accordingly, I'll send you some MathWorks swag if you're the first to demonstrate a new way to get the Test Suite to pass (maybe a t-shirt or coffee mug, you'll have to try and see :-) Jose', yours is on the way.\r\nreference: http://en.wikipedia.org/wiki/Fast_Fourier_transform","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: 144px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 72px; transform-origin: 407px 72px; 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: 381.5px 8px; transform-origin: 381.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eYour task is to implement the Fast Fourier transform algorithm, without using builtin MATLAB fft commands e.g. fft, fft2, or hardcoded numeric answers in the test case. The test suite employs regular expression matching to reject such solutions.\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: 373.5px 8px; transform-origin: 373.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCreative hacking attempts are appreciated. While I will update the test case accordingly, I'll send you some MathWorks swag if you're the first to demonstrate a new way to get the Test Suite to pass (maybe a t-shirt or coffee mug, you'll have to try and see :-) Jose', yours is on the way.\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: 32.5px 8px; transform-origin: 32.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ereference:\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/1509-fast-fourier-transform-algorithm/edit#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ehttp://en.wikipedia.org/wiki/Fast_Fourier_transform\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = fast_fourier(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(exist('fast_fourier.m'),2))\r\n%%\r\n%%\r\nfiletext = fileread('fast_fourier.m');\r\nassert(isempty(strfind(filetext, 'fft')))\r\nassert(isempty(strfind(filetext, 'regexp')))\r\n\r\n%%\r\nfor k=5:50\r\n  x = [11;k;2];\r\n  y_correct = fft(x);\r\n  assert(all(abs(fast_fourier(x)-y_correct)\u003c1e-4))\r\nend","published":true,"deleted":false,"likes_count":0,"comments_count":3,"created_by":5657,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2022-01-02T19:35:37.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-05-14T14:47:34.000Z","updated_at":"2022-01-02T19:35:37.000Z","published_at":"2013-05-14T14:47:34.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\u003eYour task is to implement the Fast Fourier transform algorithm, without using builtin MATLAB fft commands e.g. fft, fft2, or hardcoded numeric answers in the test case. The test suite employs regular expression matching to reject such solutions.\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\u003eCreative hacking attempts are appreciated. While I will update the test case accordingly, I'll send you some MathWorks swag if you're the first to demonstrate a new way to get the Test Suite to pass (maybe a t-shirt or coffee mug, you'll have to try and see :-) Jose', yours is on the way.\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\u003ereference:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://en.wikipedia.org/wiki/Fast_Fourier_transform\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1032,"title":"compare strings","description":"Given 2 strings and 3 actions (Insert,delete,replace) on characters. Find the difference between two strings.\r\n\r\nExample:\r\n\r\nstring1 = 'spring'\r\n\r\nstring2 = 'strange'\r\n\r\nreplace(p,t), replace(i,a), insert(e) = 3 actions = 3 differences\r\n\r\nso the answer is 3","description_html":"\u003cp\u003eGiven 2 strings and 3 actions (Insert,delete,replace) on characters. Find the difference between two strings.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003estring1 = 'spring'\u003c/p\u003e\u003cp\u003estring2 = 'strange'\u003c/p\u003e\u003cp\u003ereplace(p,t), replace(i,a), insert(e) = 3 actions = 3 differences\u003c/p\u003e\u003cp\u003eso the answer is 3\u003c/p\u003e","function_template":"function d = findDifference(str1,str2)\r\n  d = length(str1)-length(str2);\r\nend","test_suite":"%%\r\nstr1 = 'spring';\r\nstr2 = 'strange';\r\nd_correct = 3;\r\nassert(isequal(findDifference(str1,str2),d_correct))\r\n%%\r\nstr1 = 'this';\r\nstr2 = 'has';\r\nd_correct = 2;\r\nassert(isequal(findDifference(str1,str2),d_correct))\r\n%%\r\nstr1 = 'acgtacgtacgt';\r\nstr2 = 'acatacttgtact';\r\nd_correct = 4;\r\nassert(isequal(findDifference(str1,str2),d_correct))\r\n%%\r\nstr1 = 'fractapertornisem';\r\nstr2 = 'alfracchaperitonism';\r\nd_correct = 7;\r\nassert(isequal(findDifference(str1,str2),d_correct))\r\n%%\r\nstr1 = 'spring';\r\nstr2 = 'spring';\r\nd_correct = 0;\r\nassert(isequal(findDifference(str1,str2),d_correct))\r\n%%\r\nstr1 = 'qazwsxedcrfvtgb';\r\nstr2 = 'qazwsmedcvfr';\r\nd_correct = 6;\r\nassert(isequal(findDifference(str1,str2),d_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":4320,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":32,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-11-14T11:22:25.000Z","updated_at":"2025-12-14T16:53:53.000Z","published_at":"2012-11-14T11:22:25.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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 2 strings and 3 actions (Insert,delete,replace) on characters. Find the difference between two strings.\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\u003estring1 = 'spring'\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\u003estring2 = 'strange'\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\u003ereplace(p,t), replace(i,a), insert(e) = 3 actions = 3 differences\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\u003eso the answer is 3\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":2191,"title":"Order of things - 3","description":"This problem is closely related to \u003chttp://www.mathworks.nl/matlabcentral/cody/problems/2189-order-of-things-1 Problem 2189, Order of things - 1\u003e and \u003chttp://www.mathworks.nl/matlabcentral/cody/problems/2190-order-of-things-2 Problem 2190, Order of things - 2\u003e. For the details, see the description for those problems. Basically, we have to find the order in which to execute tasks of which the results and prerequisites depend on each other. \r\n\r\n* However, this time the tasks are grouped, and groups of tasks should be executed at once.\r\n* It may (still) be impossible to find a solution, since dependencies may be cyclic. But this may now also be due to the grouping of tasks. In any case, return an empty vector if no order is found.\r\n* There are still multiple orders possible, return them as multiple rows of the output vector.\r\n* The tasks within a group should of course be specified in the right order, when interdependent.\r\n\r\nThe dependencies of the tasks on each other is expressed in a matrix, where each row corresponds to the execution of a task, and each column to the dependency. \r\n\r\n   A  B  C  D  E\r\nA  0  0  0  0  0\r\nB  0  0  0  0  0\r\nC  0  1  0  0  0\r\nD  0  1  1  0  0\r\nE  1  0  0  0  0\r\n\r\nThe |1| on row |C|, column |B|, indicates that task |C| depends on task |B|. \r\n\r\nThe grouping of tasks is expressed as an input vector with groups assigned an integer value \u003e 0, e.g.\r\n\r\n [ 1 1 2 3 3 ] \r\n\r\nReturn the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. If multiple orders exist, return them all as rows of a matrix. In this example:\r\n\r\n [ \r\n   1 2 3 4 5\r\n   1 2 3 5 4\r\n   2 1 3 4 5\r\n   2 1 3 5 4\r\n ]\r\n\r\nIf no order fulfilling the dependencies exists, return an empty vector.","description_html":"\u003cp\u003eThis problem is closely related to \u003ca href = \"http://www.mathworks.nl/matlabcentral/cody/problems/2189-order-of-things-1\"\u003eProblem 2189, Order of things - 1\u003c/a\u003e and \u003ca href = \"http://www.mathworks.nl/matlabcentral/cody/problems/2190-order-of-things-2\"\u003eProblem 2190, Order of things - 2\u003c/a\u003e. For the details, see the description for those problems. Basically, we have to find the order in which to execute tasks of which the results and prerequisites depend on each other.\u003c/p\u003e\u003cul\u003e\u003cli\u003eHowever, this time the tasks are grouped, and groups of tasks should be executed at once.\u003c/li\u003e\u003cli\u003eIt may (still) be impossible to find a solution, since dependencies may be cyclic. But this may now also be due to the grouping of tasks. In any case, return an empty vector if no order is found.\u003c/li\u003e\u003cli\u003eThere are still multiple orders possible, return them as multiple rows of the output vector.\u003c/li\u003e\u003cli\u003eThe tasks within a group should of course be specified in the right order, when interdependent.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe dependencies of the tasks on each other is expressed in a matrix, where each row corresponds to the execution of a task, and each column to the dependency.\u003c/p\u003e\u003cpre\u003e   A  B  C  D  E\r\nA  0  0  0  0  0\r\nB  0  0  0  0  0\r\nC  0  1  0  0  0\r\nD  0  1  1  0  0\r\nE  1  0  0  0  0\u003c/pre\u003e\u003cp\u003eThe \u003ctt\u003e1\u003c/tt\u003e on row \u003ctt\u003eC\u003c/tt\u003e, column \u003ctt\u003eB\u003c/tt\u003e, indicates that task \u003ctt\u003eC\u003c/tt\u003e depends on task \u003ctt\u003eB\u003c/tt\u003e.\u003c/p\u003e\u003cp\u003eThe grouping of tasks is expressed as an input vector with groups assigned an integer value \u0026gt; 0, e.g.\u003c/p\u003e\u003cpre\u003e [ 1 1 2 3 3 ] \u003c/pre\u003e\u003cp\u003eReturn the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. If multiple orders exist, return them all as rows of a matrix. In this example:\u003c/p\u003e\u003cpre\u003e [ \r\n   1 2 3 4 5\r\n   1 2 3 5 4\r\n   2 1 3 4 5\r\n   2 1 3 5 4\r\n ]\u003c/pre\u003e\u003cp\u003eIf no order fulfilling the dependencies exists, return an empty vector.\u003c/p\u003e","function_template":"function order = calculation_order(dependencies,groups)\r\n  order  = 1:size(dependencies,1);\r\nend","test_suite":"%%\r\ndependencies = [\r\n0  0  0  0  1\r\n0  0  1  1  0\r\n0  0  0  0  0\r\n0  0  1  0  0\r\n0  0  0  0  0\r\n];\r\ngroups = [ 3  3  1  2  1 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n5  3  4  2  1\r\n5  3  4  1  2\r\n4  3  5  2  1\r\n4  3  5  1  2\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n0  1  0  0  0\r\n0  0  1  0  0\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n1  0  0  1  0\r\n];\r\ngroups = [ 2  2  2  1  2 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n4  3  2  1  5\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n0  1  0  0  0\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n1  0  0  0  1\r\n0  0  1  0  0\r\n];\r\ngroups = [ 1  1  2  3  2 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n2  1  3  5  4\r\n4  3  1  5  2\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n0  0  0  0  0\r\n0  0  1  0  0\r\n0  1  0  0  0\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n];\r\ngroups = [ 5  1  2  3  4 ];\r\norder = calculation_order(dependencies,groups);\r\nassert(isempty(order));\r\n\r\n%%\r\ndependencies = [\r\n0  0  0  0  0\r\n1  0  0  0  0\r\n0  0  0  1  0\r\n0  1  0  0  0\r\n0  0  1  0  0\r\n];\r\ngroups = [ 1  1  2  3  2 ];\r\norder = calculation_order(dependencies,groups);\r\nassert(isempty(order));\r\n\r\n%%\r\ndependencies = [\r\n0  0  0  0  1\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n1  0  0  0  0\r\n];\r\ngroups = [ 2  2  3  1  1 ];\r\norder = calculation_order(dependencies,groups);\r\nassert(isempty(order));\r\n\r\n%%\r\ndependencies_ = ones(10+randi(10));\r\ndependencies_ = dependencies_-triu(dependencies_);\r\norder_ = randperm(size(dependencies_,1));\r\ndependencies = dependencies_(order_,order_);\r\norder_ = 0;\r\norder = calculation_order(dependencies,1:size(dependencies_,1));\r\nordered = dependencies(order,order);\r\nassert(~nnz(triu(ordered-diag(diag(ordered)))));\r\norder = calculation_order(dependencies,ones(1,size(dependencies_,1)));\r\nordered = dependencies(order,order);\r\nassert(~nnz(triu(ordered-diag(diag(ordered)))));\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":6556,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1,"test_suite_updated_at":"2014-02-21T15:59:05.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-02-18T08:50:55.000Z","updated_at":"2014-02-21T15:59:05.000Z","published_at":"2014-02-21T09:38:58.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is closely related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.nl/matlabcentral/cody/problems/2189-order-of-things-1\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2189, Order of things - 1\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://www.mathworks.nl/matlabcentral/cody/problems/2190-order-of-things-2\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2190, Order of things - 2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. For the details, see the description for those problems. Basically, we have to find the order in which to execute tasks of which the results and prerequisites depend on each other.\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\u003eHowever, this time the tasks are grouped, and groups of tasks should be executed at once.\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\u003eIt may (still) be impossible to find a solution, since dependencies may be cyclic. But this may now also be due to the grouping of tasks. In any case, return an empty vector if no order is found.\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\u003eThere are still multiple orders possible, return them as multiple rows of the output vector.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe tasks within a group should of course be specified in the right order, when interdependent.\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 dependencies of the tasks on each other is expressed in a matrix, where each row corresponds to the execution of a task, and each column to the dependency.\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[   A  B  C  D  E\\nA  0  0  0  0  0\\nB  0  0  0  0  0\\nC  0  1  0  0  0\\nD  0  1  1  0  0\\nE  1  0  0  0  0]]\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\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e on row\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eC\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, column\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eB\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, indicates that task\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eC\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e depends on task\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eB\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe grouping of tasks is expressed as an input vector with groups assigned an integer value \u0026gt; 0, e.g.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ [ 1 1 2 3 3 ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. If multiple orders exist, return them all as rows of a matrix. In this example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ [ \\n   1 2 3 4 5\\n   1 2 3 5 4\\n   2 1 3 4 5\\n   2 1 3 5 4\\n ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf no order fulfilling the dependencies exists, return an empty vector.\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":2192,"title":"Order of things - 4","description":"*This is the last assignment in the _Order of Things_-series. If that past incompleteness kept you from solving it, you may start now.* Open that bottle of wine, and spend an entertaining evening coding.\r\n\r\nThis problem is closely related to \u003chttp://www.mathworks.nl/matlabcentral/cody/problems/2189-order-of-things-1 Problem 2189, Order of things - 1\u003e, \u003chttp://www.mathworks.nl/matlabcentral/cody/problems/2190-order-of-things-2 Problem 2190, Order of things - 2\u003e, and \u003chttp://www.mathworks.nl/matlabcentral/cody/problems/2191-order-of-things-3 Problem 2191, Order of things - 3\u003e. For the details, see the description for those problems. Basically, we have to find the order in which to execute tasks of which the results and prerequisites depend on each other. \r\n\r\nHowever, this is the most complex case, as \r\n* Calculations are preferably grouped, but may, due to their dependencies, not all be clustered. So groups of events may be split over different clusters. The number of clusters per group should be kept to a minimum. \r\n\r\nThe same complications as in problem 3 may apply:\r\n* It may (still) be impossible to find a solution, since dependencies may be cyclic. But this is now no longer due to the grouping of tasks, as you may, if necessary, break the rule of grouping. In any case, return an empty vector if no order is found.\r\n* There are still multiple orders possible, return them as multiple rows of the output vector.\r\n* The tasks within a group should of course be specified in the right order, when interdependent.\r\n\r\nThe dependencies of the tasks on each other is expressed in a matrix, where each row corresponds to the execution of a task, and each column to the dependency. \r\n\r\n   A  B  C  D  E\r\nA  0  0  0  0  0\r\nB  0  0  1  0  0\r\nC  1  0  0  0  0\r\nD  0  0  1  0  0\r\nE  1  0  0  0  0\r\n\r\nThe |1| on row |C|, column |B|, indicates that task |C| depends on task |B|. \r\n\r\nThe grouping of tasks is expressed as an input vector with groups assigned an integer value \u003e 0, for every task, e.g. \r\n\r\n [ 1 1 2 2 3 ] \r\n\r\nReturn the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. If multiple orders exist, return them all as rows of a matrix. In this example:\r\n\r\n [ \r\n   1 3 4 2 5\r\n   1 3 4 5 2\r\n   1 5 3 4 2\r\n ]\r\n\r\nIf no order fulfilling the dependencies exists, return an empty vector.","description_html":"\u003cp\u003e\u003cb\u003eThis is the last assignment in the \u003ci\u003eOrder of Things\u003c/i\u003e-series. If that past incompleteness kept you from solving it, you may start now.\u003c/b\u003e Open that bottle of wine, and spend an entertaining evening coding.\u003c/p\u003e\u003cp\u003eThis problem is closely related to \u003ca href = \"http://www.mathworks.nl/matlabcentral/cody/problems/2189-order-of-things-1\"\u003eProblem 2189, Order of things - 1\u003c/a\u003e, \u003ca href = \"http://www.mathworks.nl/matlabcentral/cody/problems/2190-order-of-things-2\"\u003eProblem 2190, Order of things - 2\u003c/a\u003e, and \u003ca href = \"http://www.mathworks.nl/matlabcentral/cody/problems/2191-order-of-things-3\"\u003eProblem 2191, Order of things - 3\u003c/a\u003e. For the details, see the description for those problems. Basically, we have to find the order in which to execute tasks of which the results and prerequisites depend on each other.\u003c/p\u003e\u003cp\u003eHowever, this is the most complex case, as \r\n* Calculations are preferably grouped, but may, due to their dependencies, not all be clustered. So groups of events may be split over different clusters. The number of clusters per group should be kept to a minimum.\u003c/p\u003e\u003cp\u003eThe same complications as in problem 3 may apply:\r\n* It may (still) be impossible to find a solution, since dependencies may be cyclic. But this is now no longer due to the grouping of tasks, as you may, if necessary, break the rule of grouping. In any case, return an empty vector if no order is found.\r\n* There are still multiple orders possible, return them as multiple rows of the output vector.\r\n* The tasks within a group should of course be specified in the right order, when interdependent.\u003c/p\u003e\u003cp\u003eThe dependencies of the tasks on each other is expressed in a matrix, where each row corresponds to the execution of a task, and each column to the dependency.\u003c/p\u003e\u003cpre\u003e   A  B  C  D  E\r\nA  0  0  0  0  0\r\nB  0  0  1  0  0\r\nC  1  0  0  0  0\r\nD  0  0  1  0  0\r\nE  1  0  0  0  0\u003c/pre\u003e\u003cp\u003eThe \u003ctt\u003e1\u003c/tt\u003e on row \u003ctt\u003eC\u003c/tt\u003e, column \u003ctt\u003eB\u003c/tt\u003e, indicates that task \u003ctt\u003eC\u003c/tt\u003e depends on task \u003ctt\u003eB\u003c/tt\u003e.\u003c/p\u003e\u003cp\u003eThe grouping of tasks is expressed as an input vector with groups assigned an integer value \u0026gt; 0, for every task, e.g.\u003c/p\u003e\u003cpre\u003e [ 1 1 2 2 3 ] \u003c/pre\u003e\u003cp\u003eReturn the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. If multiple orders exist, return them all as rows of a matrix. In this example:\u003c/p\u003e\u003cpre\u003e [ \r\n   1 3 4 2 5\r\n   1 3 4 5 2\r\n   1 5 3 4 2\r\n ]\u003c/pre\u003e\u003cp\u003eIf no order fulfilling the dependencies exists, return an empty vector.\u003c/p\u003e","function_template":"function order = calculation_order(dependencies,groups)\r\n  order  = 1:size(dependencies,1);\r\nend","test_suite":"dependencies = [\r\n0  1  0  0  0\r\n0  0  0  0  0\r\n0  0  0  0  1\r\n0  0  0  0  1\r\n0  1  0  0  0\r\n];\r\ngroups = [ 3  1  2  1  2 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n3  2  5  4  1\r\n3  5  2  4  1\r\n5  4  2  3  1\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n0  1  0  0  0\r\n0  0  0  0  0\r\n0  0  0  1  0\r\n0  1  0  0  0\r\n0  0  0  1  0\r\n];\r\ngroups = [ 3  1  1  2  2 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n3  4  2  5  1\r\n3  4  5  2  1\r\n5  3  4  2  1\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n0  0  1  0  0\r\n0  0  0  1  0\r\n0  0  0  1  0\r\n0  0  0  0  0\r\n0  0  1  0  0\r\n];\r\ngroups = [ 1  3  2  1  2 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n2  1  4  5  3\r\n5  1  4  2  3\r\n4  1  3  2  5\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n    0 0 0 0 0\r\n    0 0 0 0 0\r\n    0 1 0 0 0\r\n    0 0 1 0 0\r\n    1 0 0 1 0\r\n    ];\r\ngroups = [1 2 2 2 2];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n    1 2 3 4 5\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies = [\r\n0  0  0  1  0\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n1  0  0  0  0\r\n0  0  0  0  0\r\n];\r\ngroups = [ 1  3  4  2  5 ];\r\norder = calculation_order(dependencies,groups);\r\nassert(isempty(order));\r\n\r\n%%\r\ndependencies = [\r\n0  0  0  0  0\r\n0  0  0  0  0\r\n0  0  0  1  0\r\n0  0  1  0  0\r\n0  0  0  0  0\r\n];\r\ngroups = [ 1  3  2  1  2 ];\r\norder = calculation_order(dependencies,groups);\r\norder_correct = [\r\n1  2  4  5  3\r\n1  2  3  5  4\r\n1  5  4  2  3\r\n1  5  3  2  4\r\n1  4  3  2  5\r\n1  3  4  2  5\r\n5  4  3  2  1\r\n5  3  4  2  1\r\n];\r\nassert(isequal(sortrows(order_correct),sortrows(order)));\r\n\r\n%%\r\ndependencies_ = ones(randi(10));\r\ndependencies_ = dependencies_-triu(dependencies_);\r\norder_ = randperm(size(dependencies_,1));\r\ndependencies = dependencies_(order_,order_);\r\norder_ = 0;\r\norder = calculation_order(dependencies,1:size(dependencies_,1));\r\nordered = dependencies(order,order);\r\nassert(~nnz(triu(ordered-diag(diag(ordered)))));\r\norder = calculation_order(dependencies,ones(1,size(dependencies_,1)));\r\nordered = dependencies(order,order);\r\nassert(~nnz(triu(ordered-diag(diag(ordered)))));\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":6556,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-02-18T08:57:21.000Z","updated_at":"2014-03-04T07:49:56.000Z","published_at":"2014-03-04T07:49:56.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\u003eThis is the last assignment in the\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:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOrder of Things\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e-series. If that past incompleteness kept you from solving it, you may start now.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Open that bottle of wine, and spend an entertaining evening coding.\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 problem is closely related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.nl/matlabcentral/cody/problems/2189-order-of-things-1\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2189, Order of things - 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.nl/matlabcentral/cody/problems/2190-order-of-things-2\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2190, Order of things - 2\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://www.mathworks.nl/matlabcentral/cody/problems/2191-order-of-things-3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2191, Order of things - 3\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. For the details, see the description for those problems. Basically, we have to find the order in which to execute tasks of which the results and prerequisites depend on each other.\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\u003eHowever, this is the most complex case, as * Calculations are preferably grouped, but may, due to their dependencies, not all be clustered. So groups of events may be split over different clusters. The number of clusters per group should be kept to a minimum.\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 same complications as in problem 3 may apply: * It may (still) be impossible to find a solution, since dependencies may be cyclic. But this is now no longer due to the grouping of tasks, as you may, if necessary, break the rule of grouping. In any case, return an empty vector if no order is found. * There are still multiple orders possible, return them as multiple rows of the output vector. * The tasks within a group should of course be specified in the right order, when interdependent.\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 dependencies of the tasks on each other is expressed in a matrix, where each row corresponds to the execution of a task, and each column to the dependency.\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[   A  B  C  D  E\\nA  0  0  0  0  0\\nB  0  0  1  0  0\\nC  1  0  0  0  0\\nD  0  0  1  0  0\\nE  1  0  0  0  0]]\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\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e on row\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eC\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, column\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eB\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, indicates that task\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eC\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e depends on task\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eB\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe grouping of tasks is expressed as an input vector with groups assigned an integer value \u0026gt; 0, for every task, e.g.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ [ 1 1 2 2 3 ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn the new row/column order as a numeric row-vector, referring to the rows/columns of the input matrix. If multiple orders exist, return them all as rows of a matrix. In this example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ [ \\n   1 3 4 2 5\\n   1 3 4 5 2\\n   1 5 3 4 2\\n ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf no order fulfilling the dependencies exists, return an empty vector.\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:\"algorithms\"","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:\"algorithms\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"algorithms\"","","\"","algorithms","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f0f5468b720\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f0f5468b680\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f0f5468adc0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f0f5468b9a0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f0f5468b900\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f0f5468b860\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f0f5468b7c0\u003e":"tag:\"algorithms\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f0f5468b7c0\u003e":"tag:\"algorithms\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"cody-search","password":"78X075ddcV44","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"algorithms\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"algorithms\"","","\"","algorithms","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f0f5468b720\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f0f5468b680\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f0f5468adc0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f0f5468b9a0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f0f5468b900\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f0f5468b860\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f0f5468b7c0\u003e":"tag:\"algorithms\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f0f5468b7c0\u003e":"tag:\"algorithms\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":44675,"difficulty_rating":"easy-medium"},{"id":1509,"difficulty_rating":"easy-medium"},{"id":1032,"difficulty_rating":"medium"},{"id":2191,"difficulty_rating":"unrated"},{"id":2192,"difficulty_rating":"unrated"}]}}