From ca83d5724f04a269fa8f2c6407a1f73ab60911c1 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Fri, 20 Feb 2026 00:07:42 +0100 Subject: [PATCH] fix BlockIterator always starting at pos 0 (even if there's no Block there) --- include/klotski.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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); }