Skip to content

Instantly share code, notes, and snippets.

@dreanmer
Last active August 15, 2017 15:01
Show Gist options
  • Save dreanmer/9ce8f70b6312a799516e2e6939867f35 to your computer and use it in GitHub Desktop.
Save dreanmer/9ce8f70b6312a799516e2e6939867f35 to your computer and use it in GitHub Desktop.
Fizz Buzz solution zero if
<?php
$result = array_diff( range( 0, 100, 1 ), range( 0, 100, 3 ), range( 0, 100, 5 ) ) +
array_fill_keys( range( 0, 100, 15 ), 'FizzBuzz' ) +
array_fill_keys( range( 0, 100, 5 ), 'Buzz' ) +
array_fill_keys( range( 0, 100, 3 ), 'Fizz' );
ksort( $result );
unset( $result[ 0 ] );
echo implode( "\n", $result );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment