handled same number appearing twice

This commit is contained in:
Seth Samuel 2024-12-09 15:48:24 +13:00
parent 04d7f1305c
commit 2a57da02a9
6 changed files with 15 additions and 4 deletions

View file

@ -32,7 +32,6 @@ int main(){
}
list<int> currentLevelsBackup = currentLevels;
int numOfLevelsInLine = currentLevels.size();
int numOfLevelsProcessed = 0;
auto curListIt = currentLevels.begin();
curListIt++; //point to second item in list
@ -75,12 +74,23 @@ int main(){
dir = DOWN;
}
if (dir==UP&&levelGoDown.size()>2){ //if the overall direction goes up and more then 2 leves go down the list is bad
if (dir==UP&&levelGoDown.size()>1){ //if the overall direction goes up and more then 1 level go down the list is bad
currentLevels.clear();
} else if (dir==DOWN&&levelGoesUp.size()>2){ //same as above but opiosite dirrection
} else if (dir==DOWN&&levelGoesUp.size()>1){ //same as above but opiosite dirrection
currentLevels.clear();
}
if (levelStaysSame.size()>1){ //cant have more then 1 number the same or the list is bad
currentLevels.clear();
}
if (!currentLevels.empty()&&levelStaysSame.size()==1){
auto itNumberToDelete = currentLevels.begin();
advance(itNumberToDelete,levelStaysSame.front());
currentLevels.erase(itNumberToDelete);
listDirty = true;
}
if (!currentLevels.empty()){
if (dir==UP&&levelGoDown.size()==1){
list<int>::iterator itNumberToDelete = currentLevels.begin();
@ -93,6 +103,8 @@ int main(){
currentLevels.erase(itNumberToDelete);
listDirty=true;
}
int numOfLevelsInLine = currentLevels.size();
//need to pull the first one to have something to compare to
int prevlevel = currentLevels.front();
@ -101,7 +113,6 @@ int main(){
for (int level = currentLevels.front(); !currentLevels.empty();level=currentLevels.front()){
if (abs(prevlevel-level)>3) {currentLevels.clear();break;}
if(prevlevel==level){ currentLevels.clear();break;}
prevlevel=currentLevels.front();
currentLevels.pop_front();

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.