Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Uncategorized category for Identify Block by vvm70
def identify_block(numbers):
letters = {
'I': ({1, 2, 3, 4}, {1, 5, 9, 13}),
'J': ({2, 6, 9, 10}, {1, 2, 5, 9}, {1, 5, 6, 7}, {1, 2, 3, 7}),
'L': ({1, 5, 9, 10}, {1, 2, 6, 10}, {3, 5, 6, 7}, {1, 2, 3, 5}),
'O': ({1, 2, 5, 6},),
'S': ({2, 3, 5, 6}, {1, 5, 6, 10}),
'T': ({1, 5, 6, 9}, {2, 5, 6, 10}, {2, 5, 6, 7}, {1, 2, 3, 6}),
'Z': ({1, 2, 6, 7}, {2, 5, 6, 9})
}
delta = (min(numbers) - 1) // 4 * 4 + min((x - 1) % 4 for x in numbers)
numbers = {x - delta for x in numbers}
return ''.join(key for key in letters.keys() if numbers in letters[key]) or None
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({7, 8, 11, 12}) == 'O', 'O'
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"?')
Nov. 2, 2020