in reply to Re: (Golf) Per Mutations
in thread (Golf) Per Mutations
Non-recursive, handles repeated elements?
77 chars...sub permute{ @r=[];$e=$_,@r=map{@a=@$_;map{@b=@a;splice(@b,$_,0,$e);[@b]}0..@a}@r f +or@_;@r }
UPDATE
75...
sub permute{ @r=[];$e=$_,@r=map{@a=@$_;map[@a[0..$_-1],$e,@a[$_..$#a]],0..@a}@r for +@_;@r }
|
---|
In Section
Meditations