← Back to challenges

Back to Home?

PythonMediumlogicvalidationarraysstrings

Instructions

Mubashir has started his journey from home. Given a string of directions (N=North, W=West, S=South, E=East), he will walk for one minute in each direction. Determine whether a set of directions will lead him back to the starting position or not.

Examples

back_to_home("EEWE") ➞ False

back_to_home("NENESSWW") ➞ True

back_to_home("NEESSW") ➞ False

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Hashes and Pluses