Created
November 2, 2020 20:41
-
-
Save les-peters/a89ebea40a8e6e2b38fcc8485ab310df to your computer and use it in GitHub Desktop.
Safe-to-Jump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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