{"id":319,"date":"2023-08-04T20:59:48","date_gmt":"2023-08-05T02:59:48","guid":{"rendered":"https:\/\/kop.lat\/blog\/?p=319"},"modified":"2023-08-04T22:31:09","modified_gmt":"2023-08-05T04:31:09","slug":"permutation-algorithm","status":"publish","type":"post","link":"https:\/\/kop.lat\/blog\/permutation-algorithm\/","title":{"rendered":"Permutation algorithm"},"content":{"rendered":"\n<p>Returns an array that actually represents the permutation algorithm.<\/p>\n\n\n\n<p>It receives an array, and has to return an array of indexes, of the values that are in the index indicated by p(x), where x: 1 &lt; x &lt; n;<\/p>\n\n\n\n<div class=\"dm-code-snippet dark dm-normal-version default no-background-mobile\" snippet-height=\"\" style=\"background-color:#abb8c3\"><div class=\"control-language\"><div class=\"dm-buttons\"><div class=\"dm-buttons-left\"><div class=\"dm-button-snippet red-button\"><\/div><div class=\"dm-button-snippet orange-button\"><\/div><div class=\"dm-button-snippet green-button\"><\/div><\/div><div class=\"dm-buttons-right\"><a id=\"dm-copy-raw-code\"><span class=\"dm-copy-text\">Copy Code<\/span><span class=\"dm-copy-confirmed\" style=\"display:none\">Copied<\/span><span class=\"dm-error-message\" style=\"display:none\">Use a different Browser<\/span><\/a><\/div><\/div><pre class=\" line-numbers\"><code id=\"dm-code-raw\" class=\" no-wrap language-javascript\">function perm(initialArray) {\n    const maxLength = initialArray.length;\n    let arrayTemp = [];\n    \n    for (let i = 1; i &lt;= maxLength; i++)\n    {\n        for(let j = 0; j &lt; maxLength; j++){\n            if ( initialArray[j] === i )\n            {\n                for (let k = 0; k &lt; maxLength; k++){\n                    if ( initialArray[k] === j+1 ){\n                        arrayTemp.push(k+1);\n                    }\n                }\n            }\n        }\n    }\n    \n    return arrayTemp;\n}<\/code><\/pre><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Returns an array that actually represents the permutation algorithm. It receives an array, and has to return an array of indexes, of the values that are in the index indicated by p(x), where x: 1 &lt; x &lt; n;<\/p>\n","protected":false},"author":1,"featured_media":236,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[36,32,35,7],"tags":[38,23,37],"_links":{"self":[{"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/posts\/319"}],"collection":[{"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/comments?post=319"}],"version-history":[{"count":2,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":321,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/posts\/319\/revisions\/321"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/media\/236"}],"wp:attachment":[{"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/media?parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/categories?post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/tags?post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}