in reply to (Golf as well): List of Partitions
Update: Same thing, but avoids repetitions: Total chars: 96sub P { $_[0]?map{my$c=$_;map[$c,@$_],P($_[0]-$c)}(1..$_[0]):[] }
sub P { my$b=$_[1]||$_[0]; $_[0]?map{my$c=$_;map[$c,@$_],P($_[0]-$c,$c)}grep{$_<=$b}(1..$_[0]):[] }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re (tilly) 2 (non-recursive): (Golf as well): List of Partitions
by tilly (Archbishop) on May 06, 2001 at 20:39 UTC |