title: Rearrangement with bounded element movement
body: <p>I want to rearrange (or permute) the elements of an array, by the condition that:</p>
  
  <blockquote>
    <p>Each element should not move more than <code>k</code> position from its original position</p>
  </blockquote>
  
  <p>Then I want to iterate over all such rearrangement efficiently.</p>
  
  <p>What is the fastest way <strong>to generate</strong> the rearrangement?</p>
  
  <p>I understand that the complexity would be less than <code>O((2k+1)^n)</code>, I'm looking for the most efficient implementation of such algorithm.</p>
  
  <p>I'm looking for a solution that can beat the naive algorithm which considers every permutation and do a check on the condition.</p>