counting each number now
This commit is contained in:
parent
55f05e4f16
commit
625cb4986f
2 changed files with 23 additions and 36 deletions
BIN
2/puzzle2p2
Executable file
BIN
2/puzzle2p2
Executable file
Binary file not shown.
|
|
@ -36,47 +36,34 @@ int main(){
|
||||||
curListIt++; //point to second item in list
|
curListIt++; //point to second item in list
|
||||||
auto RevCurListIt = currentLevels.rbegin();
|
auto RevCurListIt = currentLevels.rbegin();
|
||||||
RevCurListIt++; //points to second to last item
|
RevCurListIt++; //points to second to last item
|
||||||
enum Direction dir;
|
enum Direction dir;
|
||||||
bool dirSet =false;
|
|
||||||
bool listDirty =false;
|
bool listDirty =false;
|
||||||
|
list<int>changeFromPrevLevel;
|
||||||
|
list<int>levelGoesUp;
|
||||||
|
list<int>levelGoDown;
|
||||||
|
list<int>levelStaysSame;
|
||||||
|
int totalChange=0;
|
||||||
|
|
||||||
|
changeFromPrevLevel.push_front(0);
|
||||||
|
auto frontIt = currentLevels.begin();
|
||||||
|
frontIt++;
|
||||||
|
auto backIt = currentLevels.begin();
|
||||||
|
|
||||||
//check first number, second number and last number to see if they all acend or deced
|
for(int index = 1;frontIt!=currentLevels.end();index++){
|
||||||
//if not check second number, third number and last number to see if they accend or decend
|
int change = (*backIt)-(*frontIt);
|
||||||
//then check first number, second number and second to last to see if they accend or decend
|
totalChange+=change;
|
||||||
|
changeFromPrevLevel.push_back(change);
|
||||||
//set direction
|
frontIt++;
|
||||||
if ((currentLevels.front()>currentLevels.back())&&(*curListIt) > currentLevels.back()){
|
backIt++;
|
||||||
dir = DOWN;
|
if (change>0){
|
||||||
dirSet=true;
|
levelGoesUp.push_front(index);
|
||||||
} else if((currentLevels.front()<currentLevels.back())&&((*curListIt)<currentLevels.back())){
|
} else if(change<0){
|
||||||
dir= UP;
|
levelGoDown.push_front(index);
|
||||||
dirSet=true;
|
} else {
|
||||||
}
|
levelStaysSame.push_front(index);
|
||||||
//check ends first.
|
|
||||||
if(!dirSet){
|
|
||||||
int secondItem = (*curListIt);
|
|
||||||
curListIt++; //points to thirdlist item from front
|
|
||||||
int secondToLastItem = (*RevCurListIt);
|
|
||||||
RevCurListIt++;//points to 3rd to last item
|
|
||||||
if((secondItem>(*curListIt)&&(secondItem>currentLevels.back()))){
|
|
||||||
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
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
float averageChange = totalChange/(currentLevels.size()-1);
|
||||||
//need to pull the first one to have something to compare to
|
//need to pull the first one to have something to compare to
|
||||||
|
|
||||||
int prevlevel = currentLevels.front();
|
int prevlevel = currentLevels.front();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue