Check out the Pastebin Gadgets Shop. We have thousands of fun, geeky & affordable gadgets on sale :-)Want more features on Pastebin? Sign Up, it's FREE!
tweet

# Untitled

By: a guest on May 22nd, 2013  |  syntax: None  |  size: 1.17 KB  |  views: 24  |  expires: Never
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
1. 123
2. 456
3. 789
4.
5. 123 -> 312
6. 456    456
7. 789    789
8.
9. 0 1 2 3  -->  0
10. 0 1 3 2  -->  1
11. 0 2 1 3  -->  2
12. ...
13. 1 0 2 3  -->  6
14. 1 0 3 2  -->  7
15. ...
16. 3 1 2 0  --> 21
17. 3 2 0 1  --> 22
18. 3 2 1 0  --> 23
19.
20. n = a_1 * 1! + a_2 * 2! + a_3 * 3! + a_4 * 4! + ...
21.
22. for i = 1 to s-1
23.     the i-th symbol becomes the (a_(s-i)+1)-th smallest unused symbol
24.  the last symbol is the left over one
25.
26. 4231 = 1 + 2*2115 :  a_1 = 1
27. 2115 = 0 + 3* 705 :  a_2 = 0
28.  705 = 1 + 4* 176 :  a_3 = 1
29.  176 = 1 + 5*  35 :  a_4 = 1
30.   35 = 5 + 6*   5 :  a_5 = 5
31.    5 = 5 + 7*   0 :  a_6 = 5
32.
33. coefficients      symbols       choice
34. 0,5,5,1,1,0,1  1,2,3,4,5,6,7,8     1
35.  5,5,1,1,0,1    2,3,4,5,6,7,8      7
36.   5,1,1,0,1      2,3,4,5,6,8       8
37.    1,1,0,1        2,3,4,5,6        3
38.     1,0,1          2,4,5,6         4
39.      0,1            2,5,6          2
40.       1              5,6           6
41.       -               5            5
42.