#!/usr/bin/env php <?php $length = 25; $lines = explode("\n", file_get_contents("input")); $valid = 0; for($i=$length; $i<count($lines); $i++) { $ival = $lines[$i]; for($x=$i-$length; $x<$i; $x++) { $xval = $lines[$x]; for($y=$i-$length; $y<$x; $y++) { $yval = $lines[$y]; if(($xval + $yval) == $ival) { $valid = $i; } } } if($valid != $i) break; } echo "First number with bad property is {$lines[$valid + 1]}\n"; ?>