Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
simple shift solution in Clear category for Identify Block by kdim
def identify_block(numbers):
blocks = {
'T': ({1, 2, 3, 6}, {2, 5, 6, 7}, {2, 5, 6, 10}, {1, 5, 6, 9}),
'L': ({1, 5, 9, 10}, {3, 5, 6, 7}, {1, 2, 6, 10}, {1, 2, 3, 5}),
'I': ({1, 2, 3, 4}, {1, 5, 9, 13}),
'J': ({1, 2, 3, 7}, {2, 6, 9, 10}, {1, 5, 6, 7}, {1, 2, 5, 9}),
'O': ({1, 2, 5, 6},),
'S': ({2, 3, 5, 6}, {1, 5, 6, 10}),
'Z': ({1, 2, 6, 7}, {2, 6, 5, 9})
}
dx = min((i - 1) % 4 for i in numbers)
dy = min((i - 1) // 4 * 4 for i in numbers)
n = {i - dx - dy for i in numbers}
for k, v in blocks.items():
if n in v:
return k
return None
Feb. 21, 2021
Comments: