Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Identify Block by tokiojapan55
def identify_block(numbers):
BLOCKS = {
'I':[1,5,9,13],
'J':[2,6,9,10],
'L':[1,5,9,10],
'O':[1,2,5,6],
'S':[2,3,5,6],
'T':[1,2,3,6],
'Z':[1,2,6,7]}
for _ in range(4):
coordinates = [(n//4,-(n%4)) for n in range(16) if (n+1) in numbers]
mx,my = min([x for x,_ in coordinates]),min([y for _,y in coordinates])
coordinates = [(x-mx,y-my) for x,y in coordinates]
numbers = [n+1 for n in range(16) if (n%4,n//4) in coordinates]
for id in BLOCKS:
if BLOCKS[id]==numbers:
return id
return None
June 16, 2020
Comments: