I found 301 years with a unique solution in the range 2000
till 3000. I used a different, IMO, simpler program than
the one you describe. I think you are referring to 2001 and
2005 as candidates in the counter puzzle.
Anyway, my program is after the readmore tag.
Abigail
#!/usr/bin/perl
use strict;
use warnings;
my $from = 2000;
my $till = 3000;
my @nums;
for my $x (0 .. 9) {
for my $y ($x .. 9) {
for my $z ($y .. 9) {
my %seen;
push @nums => [grep {!$seen {$_} ++}
map {s/^0{1,2}//; $_} "$x$y$z", "$x$z$y",
+"$y$x$z",
"$y$z$x", "$z$x$y",
+"$z$y$x"]
}
}
}
sub all_sub_sets;
sub all_sub_sets {
return unless @_;
my $f = shift;
my @r = all_sub_sets @_;
@r => [$f] => map {[$f => @$_]} @r
}
my %answers;
foreach my $num (@nums) {
my @sets = all_sub_sets @$num;
foreach my $set (@sets) {
local $" = " + ";
my $sum = eval "@$set";
if ($sum >= $from && $sum < $till) {
push @{$answers {$sum}} => $set;
}
}
}
for my $sum ($from .. $till - 1) {
local $" = " + ";
print "$sum = @{$answers{$sum}[0]}\n"
if $answers {$sum} && 1 == @{$answers {$sum}};
}