Skip to main content
2 of 4
added 402 characters in body
ngm
  • 4.3k
  • 7
  • 29

R, 117 63 bytes

function(m)sum(colSums(as.matrix(dist(which(m==8,T)))<=2^.5)<2)

Try it online!

function(m,p=which(m==8,T))sum(sapply(split(p,1:nrow(p)),function(y)sum(apply(p,1,function(x)all((c(y-x)^2<2)))))==1)

Try it online!

ngm
  • 4.3k
  • 7
  • 29