Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Rolling 🎲! by Serg900vd
def dice_next(dice: dict, direct: str) -> dict:
directs = {'N': {'T': dice['S'], 'B': dice['N'], 'N': dice['T'], 'S': dice['B'], 'W': dice['W'], 'E': dice['E']},
'S': {'T': dice['N'], 'B': dice['S'], 'N': dice['B'], 'S': dice['T'], 'W': dice['W'], 'E': dice['E']},
'W': {'T': dice['E'], 'B': dice['W'], 'N': dice['N'], 'S': dice['S'], 'W': dice['T'], 'E': dice['B']},
'E': {'T': dice['W'], 'B': dice['E'], 'N': dice['N'], 'S': dice['S'], 'W': dice['B'], 'E': dice['T']},
}
return directs[direct]
def rolling_dice(moves: str) -> int:
dice = {'T': 1, 'B': 6, 'N': 5, 'S': 2, 'W': 4, 'E': 3}
for m in moves:
dice = dice_next(dice, m)
return dice['T']
April 30, 2023
Comments: