Question is:
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.
Test case: [n,n,n,s,n,s,n,s,n,s] is true.
I am having difficulty to understand how to ensure that the person reached his starting point.
I know it must be a simple shortest path mathematics.
But I am really not getting starting point reached logic.
Please help.
nandsare standing for north, south, etc. That is a bit confusing.