advent_of_code_2020/day_1/part_1.php

11 lines
271 B
PHP
Raw Permalink Normal View History

2020-12-03 12:27:30 +01:00
<?php
$numbers = array_map('intval', explode("\n", file_get_contents('input.txt')));
foreach ($numbers as $number) {
$number_to_2020 = 2020 - $number;
if (in_array($number_to_2020, $numbers, true)) {
echo $number_to_2020 * $number;
exit;
}
}