22 lines
513 B
PHP
22 lines
513 B
PHP
|
<?php
|
||
|
|
||
|
$numbers = array_map('intval', explode("\n", file_get_contents('input.txt')));
|
||
|
|
||
|
foreach ($numbers as $i => $number_1) {
|
||
|
foreach ($numbers as $j => $number_2) {
|
||
|
if ($j <= $i) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if ($number_1 + $number_2 >= 2020) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
$number_to_2020 = 2020 - $number_1 - $number_2;
|
||
|
|
||
|
if (in_array($number_to_2020, $numbers, true)) {
|
||
|
echo $number_to_2020 * $number_1 * $number_2;
|
||
|
exit;
|
||
|
}
|
||
|
}
|
||
|
}
|