Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
dice as a list solution in Clear category for Rolling 🎲! by kdim
def rolling_dice(moves: str) -> int:
dice = [1, 6, 3, 4, 2, 5]
GO = {'W': lambda x: x[2:4] + x[0:2][::-1] + x[4:6],
'E': lambda x: x[2:4][::-1] + x[0:2] + x[4:6],
'S': lambda x: x[4:6][::-1] + x[2:4] + x[0:2],
'N': lambda x: x[4:6] + x[2:4] + x[0:2][::-1]}
for step in moves:
dice = GO[step](dice)
return dice.pop(0)
May 8, 2023
Comments: