<?php error_reporting(E_ALL);
for ($TWOint = 100; $TWOint <= 999; $TWOint++) {
$THREEint = $TWOint * $TWOint;
if ($THREEint < 10000) continue;
if (99999 < $THREEint) break;
$TWO = strval($TWOint);
$THREE = strval($THREEint);
if ($TWO[0] != $THREE[0]) continue;
if ($THREE[3] != $THREE[4]) continue;
$EnumChar = str_split($TWO . $TWO . $THREE);
if (count(array_keys($EnumChar , $TWO[0])) != 3) continue; //Tは3つ
if (count(array_keys($EnumChar , $TWO[1])) != 2) continue; //Wは2つ
if (count(array_keys($EnumChar , $TWO[2])) != 2) continue; //Oは2つ
if (count(array_keys($EnumChar , $THREE[1])) != 1) continue; //Hは1つ
if (count(array_keys($EnumChar , $THREE[2])) != 1) continue; //Rは1つ
if (count(array_keys($EnumChar , $THREE[3])) != 2) continue; //Eは2つ
printf('%3d * %4d = %6d' . PHP_EOL , $TWOint , $TWOint , $THREEint);
}
for ($TWOint = 100; $TWOint <= 999; $TWOint++) {
for ($FIVEint = 1000; $FIVEint <= 9999; $FIVEint++) {
$ELEVENint = $TWOint * $FIVEint;
if ($ELEVENint < 100000) continue;
if (999999 < $ELEVENint) break;
$TWO = strval($TWOint);
$FIVE = strval($FIVEint);
$ELEVEN = strval($ELEVENint);
if ($FIVE[2] != $ELEVEN[3]) continue;
if ($FIVE[3] != $ELEVEN[0]) continue;
if ($FIVE[3] != $ELEVEN[2]) continue;
if ($FIVE[3] != $ELEVEN[4]) continue;
$EnumChar = str_split($TWO . $FIVE . $ELEVEN);
if (count(array_keys($EnumChar , $TWO[0])) != 1) continue; //Tは1つ
if (count(array_keys($EnumChar , $TWO[1])) != 1) continue; //Wは1つ
if (count(array_keys($EnumChar , $TWO[2])) != 1) continue; //Oは1つ
if (count(array_keys($EnumChar , $FIVE[0])) != 1) continue; //Fは1つ
if (count(array_keys($EnumChar , $FIVE[1])) != 1) continue; //Iは1つ
if (count(array_keys($EnumChar , $FIVE[2])) != 2) continue; //Vは2つ
if (count(array_keys($EnumChar , $FIVE[3])) != 4) continue; //Eは4つ
if (count(array_keys($EnumChar , $ELEVEN[1])) != 1) continue; //Lは1つ
if (count(array_keys($EnumChar , $ELEVEN[5])) != 1) continue; //Nは1つ
printf('%3d * %4d = %6d' . PHP_EOL , $TWOint , $FIVEint , $ELEVENint);
}
}