title: How to print the coordinates from the given string?
body: <p>I have encountered this question in one of the interviews that i have attended and i am stumped.</p>
  
  <p>Given an input string like the following we need to print the coordinates obtained at the last character of the string.</p>
  
  <p>Directions:</p>
  
  <pre><code>L-Left
  U-Up
  R-Right
  D-Down
  X-Delete the previous move.
  </code></pre>
  
  <p>Assumption: </p>
  
  <pre><code>start with the coordinates (0,0)
  </code></pre>
  
  <p>Here is how to calculate the output.</p>
  
  <p>Given Input:</p>
  
  <pre><code>3L5UR2DDX2LR
  </code></pre>
  
  <p>Let us do step by step.</p>
  
  <pre><code>3L - Move 3 points to the left of (0,0) i.e (-3,0)
  
  5U- Move 5 points upper to (-3,0) i.e (-3,5)
  
  R - Move 1 point to the right of (-3,5) i.e (-2,5)
  
  2D - Move 2 points down to (-2,5) i.e (-2,3)
  
  D - Move 1 point further down i.e (-2,2)
  
  x - Delete the previous move.(current value is (-2,3))
  
  2L -Move 2 left to (-2,3) i.e(-4,3)
  
  R- Move 1 Right to (-4,3) i.e (-3,3)
  </code></pre>
  
  <p>The final output is (-3,3)</p>
  
  <p>I am trying to put it in code However, i am not getting a starting point on how to break this.Any help would be highly appreciated.</p>