Skip to content

Instantly share code, notes, and snippets.

@joan0fsnark
Last active May 27, 2021 18:41
Show Gist options
  • Save joan0fsnark/648553e0e01a44e47dc13abf277d9faa to your computer and use it in GitHub Desktop.
Save joan0fsnark/648553e0e01a44e47dc13abf277d9faa to your computer and use it in GitHub Desktop.
CodeWars: Take a Ten-Minute Walk (Python)
def is_valid_walk(walk):
ns = 0
ew = 0
if len(walk) == 10:
for step in walk:
if step == 'n':
ns += 1
if step == 's':
ns -= 1
if step == 'w':
ew += 1
if step == 'e':
ew -= 1
else:
return False
return ns == 0 and ew == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment