functionPermalone (str) {if(Str.length = = 1)returnstr; varA = STR.SUBSTR (0, 1), one = [a], count = 0, toggle =true; for(vari = 0; i< str.length-1; i++) { vartemp = str[i+1];//Remove the letters that need to be insertedone =cha (one, temp)}//determine if the array has consecutive duplicates for(vark = 0; k<one.length; k++) {//gets each item in the array for(varL = 0; l<one[k].length-1; l++) {//string that iterates through each item if(One[k][l] = = one[k][l+1]) {//If there are two consecutive letters equal to each other //decision variables to determine eligibilityToggle =false; Break; } Else{Toggle=true; } } //determine if toggle is true if(toggle) count++; } returncount; } permalone (' Abfdefa '); /*interpolation algorithm str: the array to be inserted V: the letter to be inserted*/ functioncha (str, v) {varlen = str.length;//Get Array length vararr = []//the last array to return for(vari = 0; i<len; i++) { for(varj = 0; j<str[i].length+1; J + +) {//the number of times you need to insert equals the string length plus one varStar = str[i].substring (0, J)varEnd =str[i].substring (J, Str[i].length); varOK = star + V +end; Arr.push (OK); } } returnarr; }
W3cshool--permutation combination de-weight algorithm challenge