Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save themonster2015/a214297c77b034363f472ca33009fe95 to your computer and use it in GitHub Desktop.
Save themonster2015/a214297c77b034363f472ca33009fe95 to your computer and use it in GitHub Desktop.
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