Python 3 (or Python 2), 153 bytes
lambda p,e=enumerate:[{sum(b[i+n%3-1][j+2*n%7%3-1]for n in range(8,16))for b,a in zip(p,p[1:])for i,r in e(b)for j,s in e(r)if s^d<a[i][j]}for d in(0,1)]
An unnamed function that accepts the pattern, p, and returns the minimal B and S as a list of two sets.
Jonathan Allan
- 115.4k
- 8
- 68
- 293