started d2p2
This commit is contained in:
parent
f5551d2de2
commit
08c10aecd5
1 changed files with 27 additions and 2 deletions
|
|
@ -31,9 +31,34 @@ int main(){
|
||||||
|
|
||||||
int numOfLevelsInLine = currentLevels.size();
|
int numOfLevelsInLine = currentLevels.size();
|
||||||
int numOfLevelsProcessed = 0;
|
int numOfLevelsProcessed = 0;
|
||||||
|
auto curListIt = currentLevels.begin();
|
||||||
|
curListIt++; //point to second item in list
|
||||||
|
enum Direction dir;
|
||||||
|
bool dirSet =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
|
||||||
|
//then check first number, second number and second to last to see if they accend or decend
|
||||||
|
|
||||||
|
//set direction
|
||||||
|
if ((currentLevels.front()>currentLevels.back())&&(*curListIt) > currentLevels.back()){
|
||||||
|
dir = DOWN;
|
||||||
|
dirSet=true;
|
||||||
|
} else if((currentLevels.front()<currentLevels.back())&&((*curListIt)<currentLevels.back())){
|
||||||
|
dir= UP;
|
||||||
|
dirSet=true;
|
||||||
|
}
|
||||||
|
//first item bad
|
||||||
|
if(!dirSet){
|
||||||
|
int secondItem = (*curListIt);
|
||||||
|
curListIt++; //points to thirdlist item
|
||||||
|
if((secondItem>(*curListIt)&&(secondItem>currentLevels.back()))){
|
||||||
|
currentLevels.pop_front()//remove first item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//need to pull the first one to have something to compare to
|
//need to pull the first one to have something to compare to
|
||||||
enum Direction dir;
|
|
||||||
int prevlevel = currentLevels.front();
|
int prevlevel = currentLevels.front();
|
||||||
currentLevels.pop_front();
|
currentLevels.pop_front();
|
||||||
numOfLevelsProcessed++;
|
numOfLevelsProcessed++;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue