Python 3, 151 bytes
...or Python 2 150 by changing // to /.
lambda p,e=enumerate:[{sum(b[i+2*n%3-1][j+2*n//5-1]for n in range(8))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