func neighbourCount(a []bool, width, height, x, y int) int {
	c := 0
	for j := -1; j <= 1; j++ {
		for i := -1; i <= 1; i++ {
			if i == 0 && j == 0 {
				continue
			}
			x2 := x + i
			y2 := y + j
			if x2 < 0 || y2 < 0 || width <= x2 || height <= y2 {
				continue
			}
			if a[y2*width+x2] {
				c++
			}
		}
	}
	return c
}
func neighbourCount(a []bool, width, height, x, y int) int {
	c := 0
	for j := -1; j <= 1; j++ {
		for i := -1; i <= 1; i++ {
			if i == 0 && j == 0 {
				continue
			}
			x2 := x + i
			y2 := y + j
			if x2 < 0 || y2 < 0 || width <= x2 || height <= y2 {
				continue
			}
			if a[y2*width+x2] {
				c++
			}
		}
	}
	return c
}
func neighbourCount ( a [ ] bool , width , height , x , y int ) int { c := 0 for j := - 1 ; j <= 1 ; j ++ { for i := - 1 ; i <= 1 ; i ++ { if i == 0 && j == 0 { continue } x2 := x + i y2 := y + j if x2 < 0 || y2 < 0 || width <= x2 || height <= y2 { continue } if a [ y2 * width + x2 ] { c ++ } } } return c }
// neighbourCount calculates the Moore neighborhood of (x, y).
neighbourCount calculates the Moore neighborhood of ( x y ) .