Last active
May 1, 2017 21:32
-
-
Save jrmadsen67/5815505 to your computer and use it in GitHub Desktop.
Next time someone asks you to take a FizzBuzz Test...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$biggest =100; | |
$all_numbers = range(0,$biggest); | |
$threes = array_fill_keys(range(3, $biggest, 3), 'Fizz'); | |
$fives = array_fill_keys(range(5, $biggest, 5), 'Buzz'); | |
$fifteens = array_fill_keys(range(15, $biggest, 15), 'FizzBuzz'); | |
$all_numbers = array_replace($all_numbers, $threes, $fives, $fifteens); | |
var_dump($all_numbers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
note: make $fifteens work off http://php.net/manual/en/function.array-intersect-key.php