functiongo_for_a_walk(int$distance){if($distance%2==1){thrownewException("There's no place like home. Unfortunately, you won't return home with an odd number of steps.");}$steps=[];$directions=['n','e','s','w'];while($distance>0){$index=array_rand($directions);$steps[]=$directions[$index];$steps[]=$directions[($index+2)%4];$distance-=2;}shuffle($steps);return$steps;}echoimplode(', ',go_for_a_walk(10)).PHP_EOL;
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
PHP