started working on detecting if the front or back number is the problem.
This commit is contained in:
parent
08c10aecd5
commit
55f05e4f16
1 changed files with 26 additions and 6 deletions
|
|
@ -10,7 +10,8 @@ using namespace std;
|
|||
|
||||
enum Direction {
|
||||
UP,
|
||||
DOWN
|
||||
DOWN,
|
||||
UNSET
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
|
@ -32,9 +33,13 @@ int main(){
|
|||
int numOfLevelsInLine = currentLevels.size();
|
||||
int numOfLevelsProcessed = 0;
|
||||
auto curListIt = currentLevels.begin();
|
||||
curListIt++; //point to second item in list
|
||||
curListIt++; //point to second item in list
|
||||
auto RevCurListIt = currentLevels.rbegin();
|
||||
RevCurListIt++; //points to second to last item
|
||||
enum Direction dir;
|
||||
bool dirSet =false;
|
||||
bool listDirty =false;
|
||||
|
||||
|
||||
//check first number, second number and last number to see if they all acend or deced
|
||||
//if not check second number, third number and last number to see if they accend or decend
|
||||
|
|
@ -48,13 +53,28 @@ int main(){
|
|||
dir= UP;
|
||||
dirSet=true;
|
||||
}
|
||||
//first item bad
|
||||
//check ends first.
|
||||
if(!dirSet){
|
||||
int secondItem = (*curListIt);
|
||||
curListIt++; //points to thirdlist item
|
||||
curListIt++; //points to thirdlist item from front
|
||||
int secondToLastItem = (*RevCurListIt);
|
||||
RevCurListIt++;//points to 3rd to last item
|
||||
if((secondItem>(*curListIt)&&(secondItem>currentLevels.back()))){
|
||||
currentLevels.pop_front()//remove first item
|
||||
dir=DOWN;
|
||||
dirSet=true;
|
||||
currentLevels.pop_front();//remove first item
|
||||
listDirty=true;
|
||||
} else if((secondItem<(*curListIt)&&(secondItem<currentLevels.back()))){
|
||||
dir = UP;
|
||||
dirSet= true;
|
||||
currentLevels.pop_front();
|
||||
listDirty=true;
|
||||
} else if ((currentLevels.front()>currentLevels.back()&&(currentLevels.front()>secondToLastItem))){
|
||||
dir = DOWN;
|
||||
dirSet= true;
|
||||
}
|
||||
//check if the back item is the problem
|
||||
|
||||
}
|
||||
|
||||
//need to pull the first one to have something to compare to
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue