home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 3,080 of 4,675   
   aen@nospicedham.spamtrap.com to terje.mathisen@nospicedham.tmsw.no   
   Re: more cyles   
   23 Nov 17 17:15:40   
   
   On Thu, 23 Nov 2017 11:26:53 +0100, Terje Mathisen   
    wrote:   
   >...   
   >Can you please post some (pseudo) code that explains the algorithm you   
   >are using?   
   >   
   This is the algorithm from TAOCP Vol. 4A, Page 336.   
   (Sorry the reference to Vol 2 was wrong).   
   ###   
   Algorithm C (Permutation generation by cyclic shifts). This algorithm   
   visits all permutations a_1 ... a_n of the distinct elements {x_1,...,   
   x_n}.   
      
   C1. [Initialize.] Set a_j <- x_j for 1 <= j <= n.   
   C2. [Visit.] Visit the permutation a_1 ... a_n, and set k <- n.   
   C3. [Shift.] Replace a_1a_2...a_k& by the cyclic shift a_2...a_ka_1,   
   and return to C2 if a_k != x_k.   
   C4. [Decrease k.] Set k <— k — 1, and go back to C3 if k > 1. |   
      
   For example, the successive permutations of {1, 2, 3,4} generated when   
   n = 4 are   
   1234, 2341, 3412, 4123, (1234),   
   2314, 3142, 1423, 4231, (2314),   
   3124, 1243, 2431, 4312, (3124), (1234),   
   2134, 1342, 3421, 4213, (2134),   
   1324, 3241, 2413, 4132, (1324),   
   3214, 2143, 1432, 4321, (3214), (2134), (1234),   
   ###   
   When I call the program up with edb I set a breakpoint at visit, and   
   can conviently watch how it progresses in the register window on the   
   right, by looking at XMM0.   
   --   
   aen   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca