diff --git a/HW10/MakePermutationMatrix.cpp b/HW10/MakePermutationMatrix.cpp index fa03b77..683222e 100644 --- a/HW10/MakePermutationMatrix.cpp +++ b/HW10/MakePermutationMatrix.cpp @@ -11,7 +11,7 @@ std::vector MakePermutationMatrix::MakePermutation(std::vector sou std::vector returnVector; std::vector localCostVector; std::size_t counter = 0; - int vectorOffset = (source.size()+1)/2; + int vectorOffset = (source.size())/2; std::sort(source.begin(), source.end()); std::vector myPerm = source; std::vector nextPerm = source; @@ -20,7 +20,7 @@ std::vector MakePermutationMatrix::MakePermutation(std::vector sou returnVector.resize(source.size(), 0); //the "nextPerm" is the permutation to stop at. - std::rotate(nextPerm.begin(), nextPerm.begin()+(rank+1), nextPerm.end()); + std::rotate(nextPerm.begin(), nextPerm.begin()+(rank+vectorOffset), nextPerm.end()); //rotate my perm. std::rotate(myPerm.begin(), myPerm.begin()+rank,myPerm.end());