Created
March 13, 2018 00:58
-
-
Save themonster2015/a214297c77b034363f472ca33009fe95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pairElement(str) { | |
arr = str.split(''); | |
arr2 = []; | |
for (i = 0; i < arr.length-1; i++) { | |
for (k =1; k < arr.length; k++) { | |
if(arr[i] != arr[k]){ | |
arr2.push([arr[i],arr[k]]); | |
} | |
} | |
} | |
for (i = arr.length-1; i >0 ; i--) { | |
for (k =arr.length-2; k >=0 ; k--) { | |
if(arr[i] != arr[k]){ | |
arr2.push([arr[i],arr[k]]); | |
} | |
} | |
} | |
return arr2; | |
} | |
pairElement("GCG"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment