diff --git a/include/klotski.hpp b/include/klotski.hpp index f6bc291..5c8bcba 100644 --- a/include/klotski.hpp +++ b/include/klotski.hpp @@ -237,7 +237,13 @@ public: bool operator!=(const State &other) const { return !(*this == other); } - BlockIterator begin() const { return BlockIterator(*this); } + BlockIterator begin() const { + BlockIterator it = BlockIterator(*this); + if (!(*it).IsValid()) { + ++it; + } + return it; + } BlockIterator end() const { return BlockIterator(*this, width * height); }