Skip to content

Instantly share code, notes, and snippets.

@les-peters
Created November 2, 2020 20:41
Show Gist options
  • Save les-peters/a89ebea40a8e6e2b38fcc8485ab310df to your computer and use it in GitHub Desktop.
Save les-peters/a89ebea40a8e6e2b38fcc8485ab310df to your computer and use it in GitHub Desktop.
Safe-to-Jump
from functools import reduce
def characterJump(jump_length, road):
return True if reduce((lambda x, y: x + y), list(map(lambda x: road[x], list(filter(lambda x: x % jump_length == 0, range(0, len(road))))))) == 0 else False
print(characterJump(3, [0,1,0,0,0,1,0]))
print(characterJump(4, [0,1,1,0,1,0,0,0,0]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment