Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
numpy.roll solution in 3rd party category for Rolling 🎲! by kurosawa4434
from numpy import roll
def rolling_dice(moves: str) -> int:
v = [1, 2, 6, 5]
h = [1, 3, 6, 4]
for m in moves:
match m:
case 'N':
v = roll(v, -1)
case 'S':
v = roll(v, 1)
case 'W':
h = roll(h, -1)
case 'E':
h = roll(h, 1)
match m:
case 'N' | 'S':
h[0], h[2] = v[0], v[2]
case 'W' | 'E':
v[0], v[2] = h[0], h[2]
return v[0]
April 28, 2023
Comments: