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
Similar Kata:
Stats:
Created | Jan 15, 2019 |
Published | Jan 15, 2019 |
Warriors Trained | 186 |
Total Skips | 4 |
Total Code Submissions | 402 |
Total Times Completed | 99 |
Ruby Completions | 99 |
Total Stars | 2 |
% of votes with a positive feedback rating | 87% of 34 |
Total "Very Satisfied" Votes | 27 |
Total "Somewhat Satisfied" Votes | 5 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 11 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |