title: Python Permutation with Limits and Directionality
body: <p>So I have a problem that I can't get my head around, so I can only give you pseudocode at best.</p>
  
  <pre><code>lista=(a,b,c)
  listb=(a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3)
  </code></pre>
  
  <p>I need a way to limit the results of the permutations of listsb to the following criteria:
  <p>A tuple of only items contained in lista
  <p>The order of lista needs to be retained
  <p>The permutations can only look to the right
  <p>lista and list b can be any length</p>
  
  <p><p>For example:</p>
  
  <p>Acceptable:</p>
  
  <p><p>a1,b1,c1</p>
    <p>a2,b3,c3</p></p>
  
  <p>Unacceptable:</p>
  
  <p><p>a1,b1,d1</p>
    <p>a2,b1,c3</p>
    <p>b2,a2,c3</p></p>
  
  <p>Any ideas you have will be most appreciated!
  Thanks</p>