7 kyu

Bob's Treasure Map

Description:

Intro

Bob found a map with directions to lead him to a magnificient treasure, but he is kind of dumb and need your help to find the treasure!

Actual usefull information

Your task is to return the coordinate of the treasure so Bob can easily find it, or, if the map is fake, return nil since there is no treasure to be found.

Directions are given by the means of a string like this: "WWSSNNEE" where:

  • N = North (Up)
  • S = South (Down)
  • E = East (Right)
  • W = West (Left)
  • Anything else that could be in the String is just there to confuse Bob.

If a map is not a String or is one with no valid direction, it means it's fake.

The coordinates must be return in an array like so: [x,y]

Examples

"NNNNN" => [0,5]  # Up 5 times.
"SSNSE" => [1,-2] # Down 2 times, up 1 time, then down once again and finish with 1 right.
"WBWWX" => [-3,0] # You aren't Bob so, don't get confused.
"AAAAA" => nil    # The map has no valid direction, so it's fake.
1234567 => nil    # The map is not a String, so it's fake.
Fundamentals

Stats:

CreatedJan 15, 2019
PublishedJan 15, 2019
Warriors Trained186
Total Skips4
Total Code Submissions402
Total Times Completed99
Ruby Completions99
Total Stars2
% of votes with a positive feedback rating87% of 34
Total "Very Satisfied" Votes27
Total "Somewhat Satisfied" Votes5
Total "Not Satisfied" Votes2
Total Rank Assessments11
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • user3254461 Avatar
  • Blind4Basics Avatar
  • dfhwze Avatar
Ad