Skip to content

Instantly share code, notes, and snippets.

@andydude
Created April 25, 2018 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andydude/a1b80973b5ca82a1ebdd34ff33a18a23 to your computer and use it in GitHub Desktop.
Save andydude/a1b80973b5ca82a1ebdd34ff33a18a23 to your computer and use it in GitHub Desktop.
def is_alt(side, side2):
side, side2 = side[0], side2[0]
return side == side2
def is_opp(side, side2):
side, side2 = side[0], side2[0]
if ord(side) > ord(side2):
side, side2 = side2, side
if side == 'D' and side2 == 'U':
return True
elif side == 'L' and side2 == 'R':
return True
elif side == 'B' and side2 == 'F':
return True
else:
return False
def speed(alg):
moves = alg.split(' ')
speed = [1 for _ in moves]
for i, move in enumerate(moves):
if 'U' in move:
speed[i] = 0.8
if 'D' in move:
speed[i] = 1.2
if '2' in move:
speed[i] *= 1.5
if i >= 2 and is_alt(move, moves[i - 2]):
speed[i] *= 0.6
if i >= 1 and is_opp(move, moves[i - 1]):
speed[i] *= 0.8
return sum(speed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment