modify getGapScore loop to know left/right piece boundary