Determine for each cell if it's part of the stream or an island. Each number is part of a single island of horizontally and vertically connected cells, which size is equal to that number. Islands can't touch eachother horizontally or vertically. The cells not part of an island form the stream. The stream is a single connected area, which doesn't cover any 2x2 areas anywhere.