import { Matrix } from '../../types' ; export const penalizeSquaresInRow = ( matrix , y ) => { if ( y === matrix . length - 1 ) { return 0 ; } let penalty = 0 ; for ( let x = 0 ; x < matrix . length - 1 ; ++ x ) { const color = matrix [ y ] [ x ] ; if ( matrix [ y + 1 ] [ x ] === color && matrix [ y ] [ x + 1 ] === color && matrix [ y + 1 ] [ x + 1 ] === color ) { penalty += 3 ; } } return penalty ; } ;