diff --git a/main.cc b/main.cc index 8046875..1cec77c 100644 --- a/main.cc +++ b/main.cc @@ -137,7 +137,9 @@ struct Grid { if (grid_[b + y(pos) * length_] != '.') { break; } ++b; } - return b - x(pos); + auto len = b - x(pos); + auto ye = std::min(y(pos) + len, length_); + return ye - y(pos); } /** Get the next position to check. n is the size of the square we just