<?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
{
return abs(((abs($count-5)%8))-4)+1;
}
foreach($assertions as $count => $assert) {
if (countFingerPingPong($count) !== $assert) {
throw new Exception('Assertions failed.');
}
}
echo 'Assertions passed.';
- Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- Assertions passed.
preferences:
76.02 ms | 402 KiB | 60 Q