it's not "more than one puddle"; it's that i don't count the second puddle because i don't ever "close" it by encountering it's level again. if i go off the edge, i should close it as best i can.
Ah, right. Now that I actually read your code, that's the real bug :p
The issue with this "state machine" approach is you don't have "lookahead".
In the two pass approach (approach from one side, then the other), you essentially have two machines, one implicitly serving as the "lookahead" for the other.
The issue with this "state machine" approach is you don't have "lookahead".
In the two pass approach (approach from one side, then the other), you essentially have two machines, one implicitly serving as the "lookahead" for the other.