Company: Apple
Difficulty: medium
Objective Your avatar is in a strange world with two inter-dimensional, bidirectional portals. Write a program that returns the coordinates of your avatar given a series of moves and the location of the portals. How it works The map is represented by a grid of width squares wide and height squares high. The top left square is located at (0, 0) where the first integer represents the column and the second the row. The initial positions of your avatar and the two portals are given by arrays of two integers position , portalA , and portalB . moves , is a string composed of the characters U (top), D (down), R (right), L (left). If your avatar walks from a given square to a square with a portal, he teleports to the associated portal (and stays on that target square until he makes another move). If a movement would make your avatar move past the end of the map, he does not move nor teleport. Implementation Implement the function compute_final_position(width, height, position, portalA, portalB