Given a string like ">>v<^^" representing a list of translations (you can imagine "^", "v", ">", "<" as arrows pointing up, down, right and left) in a two-dimensional space, we want to return the coordinates of the first point which is visited twice.
You start from the point of coordinates (0,0).
The function should return:
the coordinates of the first point that is visited twice in this format: "(x,y)" (string)
an empty string if no point is visited twice: ""
Notes:
^ is the caret symbol (above the 6 key if you have a US keyboard)
v is the letter V
Tests:
There are 7 different tests already set up to score your solution but only the first 2 tests are visible to you. You will get the maximum score if your solution passes all the tests, including the hidden ones. So sometimes, getting Tests passed: 2/2. won't be enough.
Feel free to create manually additional tests in 'Custom Tests' section, covering some edge cases for example.
Don't be afraid of creating and running tests as many times as you want, you won't be penalised for that. You will only be scored when you submit your final solution.
Example
translations = ">>v<^^"
would correspond to: right, right, down, left, up, up:
solution(">>v<^^") == "(1,0)" # example from above
solution(">>>>") == "" # no point is visited twice so we return empty coordinates
[execution time limit] 4 seconds (py3)
[input] string translations
string composed of those 4 characters only: "ˆ", "v", ">", "<"
len(translations) <= 1000
[output] string
string representing the space coordinates of the first point visited twice in this format "(x,y)", or empty string "" if no point is visited twice
[Python 3] Syntax Tips
def helloWorld(name):
print("This prints to the console when you Run Tests")
return "Hello, " + name