code for segmenting partially solved squares