Efficient Robot Movement Disclaimer: The story told within this question is entirely fictional, and invented solely for the purpose of providing an intro.  


My boss has gotten a new toy robot, and he wants me to help program it.  He wants to be able to enter simple arrow instructions to get it to move.  These instructions are: ^ (for move forward) &lt; (for turn left), and > (for turn right).  However, now that I've programmed the robot, he wants additional functionality.  He wants me to transform any sequence of arrows he inputs, so that rather than having the robot take the path indicated, it moves to the desired location, indicated by the place it would end up if it had taken the inputted path, as efficiently as possible.  I appeal to you, the members of PP&amp;CG, to help me with this task.  

Your Task:

Write a program or function to convert a string made up of arrows into a string that will get to the location indicated by the input as quickly as possible.  Turning takes exactly as long as moving backwards or forwards.  

Input:

A string of arrows, as indicated above.  If you wish, different characters may be substituted for the arrows, but be sure to include the fact that you do so in your answer.  All test cases use the arrows normally.  

Output:

A string of arrows (or your equivalent characters), that take the robot to the desired destination as efficiently as possible.  

Test Cases:

Note that the solutions offered are only possibilities, and that other solutions may be valid.  

&gt;^&lt;&lt;^^&gt;^^    -&gt; ^^&lt;^
^^^^&gt;^^^^    -&gt; ^^^^&gt;^^^^
&gt;&gt;&gt;^^^^^^    -&gt; &lt;^^^^^^
&gt;^&gt;^&gt;^&gt;^     -&gt; (empty string)
^&lt;^^&lt;^^&lt;^^^^ -&gt; &gt;^^&gt;^


Scoring:

The robot's memory is limited, so your program must have the lowest byte count possible.
Retina, 103 74 71 bytes

&lt;
&gt;&gt;&gt;
+`(&gt;(\^*&gt;){3})\^
^$1
+`\^(&gt;\^*&gt;)\^
$1
&gt;&gt;(\^*)&gt;(\^+)
&lt;$2&lt;$1
&lt;?&gt;*$



Try it online! Link includes test cases. Explanation:

&lt;
&gt;&gt;&gt;


Turn left turns into triple right turns.

+`(&gt;(\^*&gt;){3})\^
^$1


Reduce all turns modulo 4.

+`\^(&gt;\^*&gt;)\^
$1


Cancel out movements in opposite directions.

&gt;&gt;(\^*)&gt;(\^+)
&lt;$2&lt;$1


Turn a triple right turn back into a left turn. This also handles the case of &gt;&gt;^&gt;^ which needs to become &lt;^&lt;^.

&lt;?&gt;*$


Delete unnecessary trailing turns.