diff --git a/2/puzzle2p2 b/2/puzzle2p2 new file mode 100755 index 0000000..5a9460b Binary files /dev/null and b/2/puzzle2p2 differ diff --git a/2/puzzle2p2.cpp b/2/puzzle2p2.cpp index e436701..b3271a0 100644 --- a/2/puzzle2p2.cpp +++ b/2/puzzle2p2.cpp @@ -36,47 +36,34 @@ int main(){ curListIt++; //point to second item in list auto RevCurListIt = currentLevels.rbegin(); RevCurListIt++; //points to second to last item - enum Direction dir; - bool dirSet =false; + enum Direction dir; bool listDirty =false; + listchangeFromPrevLevel; + listlevelGoesUp; + listlevelGoDown; + listlevelStaysSame; + 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 - //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()(*curListIt)&&(secondItem>currentLevels.back()))){ - dir=DOWN; - dirSet=true; - currentLevels.pop_front();//remove first item - listDirty=true; - } else if((secondItem<(*curListIt)&&(secondItemcurrentLevels.back()&&(currentLevels.front()>secondToLastItem))){ - dir = DOWN; - dirSet= true; + for(int index = 1;frontIt!=currentLevels.end();index++){ + int change = (*backIt)-(*frontIt); + totalChange+=change; + changeFromPrevLevel.push_back(change); + frontIt++; + backIt++; + if (change>0){ + levelGoesUp.push_front(index); + } else if(change<0){ + levelGoDown.push_front(index); + } else { + levelStaysSame.push_front(index); } - //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 int prevlevel = currentLevels.front();