my $digs= 3; my $fact= 1; $fact *= $_ for 2..$digs; my %h; my $getDigits= nestedLoops( [ [0..9], ##[1..9], ( sub { [ $_[-1] .. 9 ] } ) x ($digs-1), ##( sub { [ $_[-1]+1 .. 9 ] } ) x ($digs-1), ] ); my @list; while( @list= $getDigits->() ) { my @p; do { push @p, join "", @list; } while( nextPermute( @list ) ); nestedLoops( [ [0..$#p], ( sub { [ $_[-1]+1 .. $#p ] } ) x ($fact-1), ], { OnlyWhen => 1, Code => sub { my $expr= join "+", @p[@_]; my $noOct= $expr; $noOct =~ s/(? length($h{$b}) ## || $a <=> $b } keys %h ) { for my $k ( sort { $a <=> $b } keys %h ) { print "$k$h{$k}\n" if 1990 < $k and $k < 2010; ##if $h{$k} =~ /\d/ && index($h{$k},"()") < 0; }