Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Identify Block by m.kurapov
figures={(1,2,3,4):'I',(1,5,9,13):'I',
(1,2,3,7):'J',(2,6,9,10):'J',(1,5,6,7):'J',(1,2,5,9):'J',
(1,2,3,5):'L',(1,5,9,10):'L',(3,5,6,7):'L',(1,2,6,10):'L',
(1,2,5,6):'O',
(2,3,5,6):'S',(1,5,6,10):'S',
(1,2,3,6):'T',(1,5,6,9):'T',(2,5,6,7):'T',(2,5,6,10):'T',
(1,2,6,7):'Z',(2,5,6,9):'Z'
}
def move(f):
dy=min([(x-1) for x in f])//4
dx=min([(x+3)%4 for x in f])
return tuple(sorted([p-dx-dy*4 for p in f]))
def identify_block(numbers):
moved = move(numbers)
return None if moved not in figures else figures[moved]
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert identify_block({10, 13, 14, 15}) == 'T', 'T'
assert identify_block({1, 5, 9, 6}) == 'T', 'T'
assert identify_block({2, 3, 7, 11}) == 'L', 'L'
assert identify_block({4, 8, 12, 16}) == 'I', 'I'
assert identify_block({3, 1, 5, 8}) == None, 'None'
print('"Run" is good. How is "Check"?')
Jan. 1, 2020
Comments: