title: Best way to hash ordered permutation of [1,9]
body: <p>I'm trying to implement a method to keep the visited states of the 8 puzzle from generating again.<br>
  My initial approach was to save each visited pattern in a list and do a linear check each time the algorithm wants to generate a child.<br>
  Now I want to do this in <code>O(1)</code> time through list access. Each pattern in 8 puzzle is an ordered permutation of numbers between 1 to 9 (9 being the blank block), for example 125346987 is:  </p>
  
  <blockquote>
    <p>1 2 5<br>
    3 4 6<br>
    _ 8 7</p>
  </blockquote>
  
  <p>The number of all of the possible permutation of this kind is around 363,000 (9!). what is the best way to hash these numbers to indexes of a list of that size?</p>