A puzzle where a mathematical equation is written using letters instead of numbers. Each letter represents a digit from 0 to 9, and no two letters can represent the same digit.
TOO + TOO + TOO + TOO = GOOD
$i=0;
echo "<h1>A cryptarithmetic puzzle</h1>";
echo "<p>A puzzle where a mathematical equation is written using letters instead of numbers. Each letter represents a digit from 0 to 9, and no two letters can represent the same digit.</p>";
echo "<h4>TOO + TOO + TOO + TOO = GOOD</h4>";
echo "<table border=1><tr><td>Solutions</td></tr>";
for ($T = 0; $T < 10; $T++)
{
for ($O = 0; $O < 10; $O++)
{
for ($G = 0; $G < 10; $G++)
{
for ($D = 0; $D < 10; $D++)
{
if (($D == $G) || ($D == $O) || ($D == $T) || ($G == $O) || ($G == $T) || ($O == $T))
continue;
else if (400 * $T + 40 * $O + 4 * $O == 1000 * $G + 100 * $O + 10 * $O + $D)
{
$arrT[$i]=$T;
$arrO[$i]=$O;
$arrG[$i]=$G;
$arrD[$i]=$D;
echo "<tr><td>";
echo "T = ".$T."<br/>";
echo "O = ".$O."<br/>";
echo "G = ".$G."<br/>";
echo "D = ".$D."<br/>";
echo "</td></tr>";
$i=$i+1;
break;
}
}
}
}
}
echo "</table>";
echo "<h4>PROOF</h4>";
for ($j = 0; $j < $i; $j++) {
echo "<p>".$arrT[$j].$arrO[$j].$arrO[$j]." + ".$arrT[$j].$arrO[$j].$arrO[$j]." + ".$arrT[$j].$arrO[$j].$arrO[$j]." + ".$arrT[$j].$arrO[$j].$arrO[$j]." = ".$arrG[$j].$arrO[$j].$arrO[$j].$arrD[$j]."<p>";
}