Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
infinite rotations solution in 3rd party category for Identify Block by flpo
B = {
'T': {(0, 0), (0, 1), (0, 2), (1, 1)},
'I': {(0, 0), (1, 0), (2, 0), (3, 0)},
'O': {(0, 0), (0, 1), (1, 0), (1, 1)},
'L': {(0, 0), (1, 0), (2, 0), (2, 1)},
'J': {(0, 1), (1, 1), (2, 0), (2, 1)},
'S': {(0, 1), (0, 2), (1, 0), (1, 1)},
'Z': {(0, 0), (0, 1), (1, 1), (1, 2)},
}
def identify_block(tile):
from itertools import product as P
from numpy import reshape, rot90
def rot():
g = reshape(range(1, 17), (4, 4))
while 1:
g = rot90(g)
yield g, sorted((x, y) for x,y in P(range(4), range(4)) if g[x, y] in tile)
return next((
n for (g, t), ((n, c), r) in zip(rot(), P(B.items(), range(4)))
if len(set((b[0]-t[0], b[1]-t[1]) for b, t in zip(sorted(c), t))) == 1
), None)
Sept. 6, 2017