function simulate($vx, $vy, $t) {
[$x, $y] = [0, 0];
$maxy = 0;
$my = min($t[2], $t[3]);
while (true) {
$x += $vx;
$y += $vy;
$maxy = max($maxy, $y);
if ($x >= $t[0] && $x <= $t[1] && $y >= $t[2] && $y <= $t[3]) {
return [$maxy, $vx, $vy];
}
if ($x > $t[1] || $y < $my) {
return false;
}
$vx = max(0, $vx - 1);
$vy -= 1;
}
}
$t = $input->numbers();
$ok = [];
foreach (range(0, $t[1]) as $vx) {
foreach (range ($t[2], $t[1]) as $vy) {
if ($maxy = simulate($vx, $vy, $t)) {
$ok[] = $maxy[0];
}
}
}
$solution_1 = max($ok);
$solution_2 = count($ok);