3v4l.org

run code in 300+ PHP versions simultaneously
<?php $assertions = [ 1 => 1, 4 => 4, 5 => 5, 6 => 4, 8 => 2, 9 => 1, 10 => 2, 11 => 3, 12 => 4, 13 => 5, 14 => 4, 15 => 3, 16 => 2, 17 => 1, 18 => 2, 19 => 3, 20 => 4, 21 => 5, 22 => 4, ]; /** * @param positive-int $count * @return positive-int */ function countFingerPingPong(int $count): int { $remainder = max(1, $count%5); $directionCircle = floor($count/5); var_dump($remainder); var_dump($directionCircle); return $directionCircle%2 === 0 ? $directionCircle -1 : 4 - $remainder; } foreach($assertions as $count => $assert) { if (countFingerPingPong($count) !== $assert) { throw new Exeption('Assesstions failed.'); } }
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
int(1) float(0) Fatal error: Uncaught Error: Class "Exeption" not found in /in/Qv09Q:42 Stack trace: #0 {main} thrown in /in/Qv09Q on line 42
Process exited with code 255.

preferences:
76.92 ms | 402 KiB | 61 Q