miguelangel.rodel
BAN USEROkey, here we go
So the idea is to "sit couples together".... That requiere comparing sits of couples and generating some expensive calculations in special cases (such as where couples are separated by a single space and require to be cascade-reacomodated in order to be all couples together) so....... I think this problem can be "re-focused", if we approach as "sitting the I.T. guys between couples"... so, the algorithm will be something like:
public static void reacomodation() {
int i;
char myCandidate2; // my candidate belong to a couple
char myCandidate1; // my candidate are alone
String myPeople = "AABHCCDEFFGBH" // original people
String myPeople = "AABHCCdeFFgBH" // people where LowerCase are single guys
for (i=1; i<=myPeople.length; i++) { // cycle to re-acomodate single people
if (myPeople[i].isUpper)
if (myPeople[i-1].isUpper && myPeople[i+1].isUpper) myCandidate2=i;
if (myPeople[i].isLower) {
myCandidate1=i;
swap(myCandidate1, myCandidate2);
}
}
for (i=1; i<=myPeople.length; i++) { // cycle to join together couples
// in the case there are Uppers alone, try to join together them.
}
}
Hoping your replys
As I understand, is ambigus to think wich means "one character of difference", thus "banana" and "bananas" can be considerated as 1 char diff.
- miguelangel.rodel October 13, 2015