If I have a 3 didgit number - a 3 didgit number = a 3 didgit number but the numbers used are 1-9 and only can be used once what are the numbers?
please help me i have been trying all week
3 answers
impossible i reckon
surely not
There are lots of solutions, starting at
459 - 173 = 286
and ending at
981 - 746 = 235
There are lots of solutions, starting at
459 - 173 = 286
and ending at
981 - 746 = 235
perl code for the solutions:
for ($i = 123 ; $i <= 987 ; $i++) {
next if $i =~ /0/;
for ($j = 123; $j <= 987 ; $j++) {
next if $j >= $i;
next if $j =~ /0/;
$k = $i - $j;
next if $k =~ /0/;
next if $k < 100;
my %d = ();
$d{$_} = 1 foreach (split(//,"$i$j$k"));
my @d = keys %d;
next unless @d == 9;
print "$i - $j = $k\n";
}
}
not elegant, but does the job
for ($i = 123 ; $i <= 987 ; $i++) {
next if $i =~ /0/;
for ($j = 123; $j <= 987 ; $j++) {
next if $j >= $i;
next if $j =~ /0/;
$k = $i - $j;
next if $k =~ /0/;
next if $k < 100;
my %d = ();
$d{$_} = 1 foreach (split(//,"$i$j$k"));
my @d = keys %d;
next unless @d == 9;
print "$i - $j = $k\n";
}
}
not elegant, but does the job