Advent of code 2017/17
Ajax Direct

Answer 1885ms

Part 1 : 1173 Part 2 : 1930815
// ==================================================
// > PART 1
// ==================================================
$buffer = [0];
$pos    = 0;
for ($i = 1; $i <= 2017; $i++) {
    $pos = ($pos + $input->int) % count($buffer) + 1;
    array_splice($buffer, $pos, 0, $i);
}
$solution_1 = $buffer[$pos + 1];

// ==================================================
// > PART 2
// ==================================================
$size = 1;
$pos  = 0;
for ($i = 1; $i <= 50_000_000; $i++) {
    $pos = (($pos + $input->int) % $size++) + 1;
    if (($pos) == 1) $solution_2 = $i;
}