bancon
$cycle_length = 2 * ($friends - 1); $effective_time = $time % $cycle_length; $current = 1; $direction = 1; for ($i = 0; $i < $effective_time; $i++) { $current += $direction; if ($current > $friends) { $direction = -1; $current = $friends - 1; } elseif ($current < 1) { $direction = 1; $current = 2; } } return [$current - $direction, $current]; add $effective_time == 0 = $cycle_length *2

$cycle_length = 2 * ($friends - 1);
$effective_time = $time % $cycle_length;
$current = 1;
$direction = 1;
for ($i = 0; $i < $effective_time; $i++) {
$current += $direction;
if ($current > $friends) {
$direction = -1;
$current = $friends - 1;
} elseif ($current < 1) {
$direction = 1;
$current = 2;
}
}
return [$current - $direction, $current];
add $effective_time == 0 = $cycle_length *2