on Wed, 16 Apr 2003 
21:02:11 PDT 
> I did at first go to Google but was stymied by the massive number of 
> references, and was hoping that someone could simply suggest a "best" 
> algorithm.  The best reference I have found so far is "Permutations by 
> Interchanges" by B. R. Heath (1963) which Sedgewick claims is the 
> fastest known, but finding Heath's paper was a chore.  I have finally 
> located it (in TIF format!) at The Oxford University Press in England. 
I just looked at Knuth to see what he has to say and there is a description on 
page 44.  So I whipped out a quick and dirty REXX to do it.  If you need this 
for a much larger number of objects you may want to optimize this code. 
/* REXX permutations.cmd */ 
item.1 = 'item 1' 
item.2 = 'item 2' 
item.3 = 'item 3' 
/* pick first item for this pass */ 
do i = 1 to 3 
   /* pick second item for this pass */ 
   do k = 1 to 3 
      if i = k then iterate 
      /* pick third item for this pass */ 
      do j = 1 to 3       
         if i = j then iterate 
         if k = j then iterate 
         say item.i item.k item.j 
      end  /* do j = 1 to 3 */ 
   end  /* do k = 1 to 3 */ 
end  /* do i = 1 to 3 */ 
exit 
--  
Robert Blair 
===================================================== 
To unsubscribe from this list, send an email message 
to "steward@scoug.com". In the body of the message, 
put the command "unsubscribe scoug-programming". 
For problems, contact the list owner at 
"rollin@scoug.com". 
===================================================== 
<< Previous Message << 
 >> Next Message >>
Return to [ 16 | 
April | 
2003 ]
The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA  92799-6904, USA
Copyright 2001 the Southern California OS/2 User Group.  ALL RIGHTS 
RESERVED. 
SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of International 
Business Machines Corporation.
All other trademarks remain the property of their respective owners.