Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Tower by eugene100372
def tower(cubes):
from collections import Counter
rot=[(0,1,3,2),(1,3,2,0),(3,2,0,1),(2,0,1,3),(0,4,3,5),(4,3,5,0),(3,5,0,4),
(5,0,4,3),(4,1,5,2),(1,5,2,4),(5,2,4,1),(2,4,1,5)]
L=[]
for cub in cubes:
L+=[tuple(cub[i] for i in pos) for pos in rot]
L+=[tuple(cub[i] for i in pos[-1::-1]) for pos in rot]
return max(Counter(L).values())
if __name__ == '__main__':
print("Example:")
print(tower(['GYVABW', 'AOCGYV', 'CABVGO', 'OVYWGA']))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert tower(['GYVABW', 'AOCGYV', 'CABVGO', 'OVYWGA']) == 3
assert tower(['ABCGYW', 'CAYRGO', 'OCYWBA', 'ACYVBR', 'GYVABW']) == 1
assert tower(['GYCABW', 'GYCABW', 'GYCABW', 'GYCABW', 'GYCABW']) == 5
print("Coding complete? Click 'Check' to earn cool rewards!")
Jan. 7, 2020