/permute

By jaytea on Apr 08, 2007

/*

lists all possible permutations of a given string

eg. /permute abc yields:

abc
acb
bac
bca
cab
cba

just a fun little snippet that i began shortening and it ended up quite tiny ;) uses indirect recursion

*/

alias permute {
  var %x 0,%y
  while ($regsub($1,(.{ $+ %x $+ })(.),\1,%y)) scon -r inc $(%x |,) $iif(? iswm $1,echo -a,permute %y) $2 $+ $regml(2)
}

Comments

Sign in to comment.
Epic   -  May 02, 2011

lol this snippit will help me with my trig homework ;) Ty jaytea

 Respond  
SimplicityX   -  Sep 03, 2010
//var %x 1 | while (%x <= $nick($active,0)) { permute $nick($active,%x) | inc %x }

\o/

 Respond  
Kirby   -  Dec 17, 2008

This can be exceptionally useful when solving acronyms.
But then again, small acronyms can be solved easily without this and longer acronyms would flood mIRC.
7/10 for the code, though.

 Respond  
Corrupt   -  Dec 17, 2008

I don't really get how it works but it's cool :D

 Respond  
Solo   -  Apr 22, 2007

Very nice snippet. Just buggy if one has ywo letters in the string. one gets results doubled up.
eg: /permute lol yields
lol
llo
oll
oll
llo
lol

 Respond  
sinnercreed   -  Apr 12, 2007

I like it Jaytea :), I\'d try to post something to help make it better but obviously I think you\'ve got it as good as it\'s going to get :P

 Respond  
DarkFlaze   -  Apr 11, 2007

wth is the point of that?

 Respond  
Solo   -  Apr 11, 2007

LOL, i tried
/permute 48A6831551E82FC61863EEF9F5B45E3F5F596DE76223B8599CCA331B76EEB28F

It actually crashed my mIRC :D very nice and concise snippet though.

 Respond  
RoninWarrior   -  Apr 09, 2007

Great job Jaytea

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.