Perl Source Code
# Author: Hannes du Plooy
# Date: 8 October 2013
# Objective: To solve the following
# ONE
# ONE
# ONE
# +ONE
# ----
# TEN
for($O=1;$O<10;$O++) {
for($E=0;$E<10;$E++) {
if ($O != $E) {
$tmp = $E*4;
$N = $tmp % 10;
$carry = ($tmp-$N)/10;
if ($N == O || $N == E) {
next;
}
$tmp = $carry + $N*4;
$E2 = $tmp % 10;
$carry = ($tmp-$E2)/10;
if ($E2 != $E) {
next;
}
$T = $carry + $O*4;
if ($T >= 10) {
next;
}
if ($T == $O || $T == $E || $T == $N) {
next;
}
print "Answer is \n\n";
print " " . $O . $N . $E . "\n";
print " " . $O . $N . $E . "\n";
print " " . $O . $N . $E . "\n";
print "+" . $O . $N . $E . "\n";
print "----\n";
print " " . $T . $E . $N . "\n";
exit;
}
}
}