All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Permutations (Posted on 2003-07-02) Difficulty: 3 of 5
Find an algorithm (subroutine) that when called repeatedly with the same character-string variable that is initialized with n characters, all different, will cycle through all the permutations of those n characters, so that for example, when called 24 times with a string of length 4, will have cycled that string through all 24 permutations and returned it to its initial state.

See The Solution Submitted by Charlie    
Rating: 4.0000 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Another Solution | Comment 13 of 14 |

Here's a solution which requires a separate tracking array:


AllPermutations(DataArray(), TrackingArray())( 

	/* Written by Erik Oosterwal */


	While(TrackingArray(i)== i+1)( 

	Mirror(DataArray(0), i+2) 

	for(j=0, j<i+1, j++)(

	return(DataArray(), TrackingArray())

  Posted by Erik on 2004-06-02 09:10:10
Please log in:
Remember me:
Sign up! | Forgot password

Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (2)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Copyright © 2002 - 2018 by Animus Pactum Consulting. All rights reserved. Privacy Information