title: Rank and unrank permutation with special properties
body: <p>I want to <code>rank and unrank</code> permutations with special properties. How can i do this? The <code>both</code> properties of permutations in the set are:</p>
  
  <ol>
  <li>each permutation has <code>only 1 cycle</code></li>
  <li>each permutation consist of subsets of permutation elements, where the subsets are in some special ordering.</li>
  </ol>
  
  <p>For example:</p>
  
  <p>The permutations with <code>length 6 (N := 6)</code> has following permutation elements: <code>(1,2,3,4,5,6)</code> with subsets:</p>
  
  <p>Subset <code>S1 := (5,6)</code> </p>
  
  <p>Subset <code>S2 := (3,4)</code></p>
  
  <p>Subset <code>S3 := (1,2)</code></p>
  
  <p>Where the elements are <code>S1 &gt; S2 &gt; S3</code>.</p>
  
  <p>So the permutation has following Subset ordering: <code>L := (S3,S2,S1,S3,S2,S1)</code></p>
  
  <p>With the 1 cycle constraint, there exist just 3 permutations which fullfill <code>both</code> constraints. </p>
  
  <p><code>(5,3,1,6,4,2)</code>
  <code>(5,4,2,6,3,1)</code>
  <code>(6,4,1,5,3,2)</code></p>
  
  <p>Counter example:</p>
  
  <p><code>(6,4,2,5,3,1)</code> matches second constraint but not the first.</p>
  
  <p>How can i rank and unrank the permutations which fullfill <code>both</code> constraints.</p>
  
  <p>When I have as input parameters:</p>
  
  <p><code>N</code> as permutation length</p>
  
  <p><code>K</code> as count of subsets</p>
  
  <p><code>L</code> as list of subsets(<code>Si</code>) consisting permutation elements, where <code>L</code> defines the ordering of the subsets(<code>Si</code>).</p>
  
  <p>And as output parameter the Rank or the permutation if the Rank is given?</p>
  
  <p>Iam able to rank and unrank permutations with only the one constraint but not with <code>both</code> constraints. Thus the permutations will have a length bigger than 100 (<code>N &gt; 100</code>) It will <code>not work</code> to generate all permutations of one constraint and check against the other, to get the valid permutations to rank/unrank.</p>