def check(n):
a = [(n>>i) & 1 for i in range(8)]
a.insert(4, 0) # make the 3x3 unit
# if up, down, left, right all are 1, you cannot make a hole
if a[1] & a[3] & a[5] & a[7]:return False
#if sum(a)==1: return False
a = np.array(a).reshape((3,3))
# segments
n = label(a, strc)[1]
# if sum is 0, it is a isolate point, you cannot remove it.
# if number of segments > 2, you cannot split them.
return n<2
return a.sum()>1 and n<2
if a.sum()==1 or n>2: return 2
if a.sum()>1 and n<2: return 1
return 0
评论列表
文章目录