title: How to compare two paths
body: <p>My data structure is a <em>path</em> represented by a list of cities. If, for example, the cities are </p>
  
  <pre><code>A, B, C, D
  </code></pre>
  
  <p>A possible configuration could be: <code>A, B, D, C</code> or <code>D, C, A, B</code>.</p>
  
  <p>I need two compare two paths in order to find the differences between these two, in such a way that the output of this procedure returns the set of swapping operations necessary to transform the second path into the first one.</p>
  
  <p>For example, given the following paths:</p>
  
  <pre><code>X = {A, B, D, C}
  Y = {D, C, A, B}
  indexes = {0, 1, 2, 3}
  </code></pre>
  
  <p>A possible way to transform the path <code>Y</code> into <code>X</code> would be the set of the following swaps: <code>{0-2, 1-3}</code>.</p>
  
  <pre><code>{D, C, A, B} --&gt; [0-2] --&gt; {A, C, D, B} --&gt; [1-3] --&gt; {A, B, D, C}
  </code></pre>
  
  <p>Is there any known (and fast) algorithm that allows to compute this set?</p>