# Take a Ten Minute Walk
# Level: 6kyu
'''
Problem Description: You live in the city of Cartesia where all roads are laid out in a perfect grid. You arrived ten 
minutes too early to an appointment, so you decided to take the opportunity to go for a short walk. The city provides its 
citizens with a Walk Generating App on their phones -- everytime you press the button it sends you an array of one-letter 
strings representing directions to walk (eg. ['n', 's', 'w', 'e']). You know it takes you one minute to traverse one city 
block, so create a function that will return true if the walk the app gives you will take you exactly ten minutes (you 
don't want to be early or late!) and will, of course, return you to your starting point. Return false otherwise.

    Note: you will always receive a valid array containing a random assortment of direction letters 
    ('n', 's', 'e', or 'w' only). It will never give you an empty array (that's not a walk, that's standing still!).
'''


def isValidWalk(walk):
    if len(walk) != 10:
        return False
    else:
        x = y = 0
        for i in walk:
            if i == 'n':
                x += 1
            elif i == 's':
                x -= 1
            elif i == 'e':
                y += 1
            elif i == 'w':
                y -= 1
        if x == 0 and y == 0:
            return True
        else:
            return False

0e8fc1a2d94577d4b6fe4354077cff4840cfaeaf
<mask token>

<mask token>


def isValidWalk(walk):
    if len(walk) != 10:
        return False
    else:
        x = y = 0
        for i in walk:
            if i == 'n':
                x += 1
            elif i == 's':
                x -= 1
            elif i == 'e':
                y += 1
            elif i == 'w':
                y -= 1
        if x == 0 and y == 0:
            return True
        else:
            return False

# Take a Ten Minute Walk
# Level: 6kyu
'''
Problem Description: You live in the city of Cartesia where all roads are laid out in a perfect grid. You arrived ten 
minutes too early to an appointment, so you decided to take the opportunity to go for a short walk. The city provides its 
citizens with a Walk Generating App on their phones -- everytime you press the button it sends you an array of one-letter 
strings representing directions to walk (eg. ['n', 's', 'w', 'e']). You know it takes you one minute to traverse one city 
block, so create a function that will return true if the walk the app gives you will take you exactly ten minutes (you 
don't want to be early or late!) and will, of course, return you to your starting point. Return false otherwise.

    Note: you will always receive a valid array containing a random assortment of direction letters 
    ('n', 's', 'e', or 'w' only). It will never give you an empty array (that's not a walk, that's standing still!).
'''


def isValidWalk(walk):
    if len(walk) != 10:
        return False
    else:
        x = y = 0
        for i in walk:
            if i == 'n':
                x += 1
            elif i == 's':
                x -= 1
            elif i == 'e':
                y += 1
            elif i == 'w':
                y -= 1
        if x == 0 and y == 0:
            return True
        else:
            return False
