Last active
March 7, 2017 16:44
-
-
Save moolen/fd2709353ed7d09199c184f78c0a0b4a to your computer and use it in GitHub Desktop.
brute-force seed for fizzbuzz
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
<?php | |
for($i = PHP_INT_MIN; $i <= PHP_INT_MAX; $i++){ | |
echo "$i".PHP_EOL; | |
srand($i); | |
if( magic() ){ | |
echo "lucky number is #$i"; | |
exit; | |
} | |
} | |
echo "no luck. yer' dead"; | |
function magic(){ | |
$yep = [0,0,1,0,2,1,0,0,1,2,0,1,0,0,3]; | |
for($i=0; $i<15; $i++){ | |
if( $yep[$i] !== rand(0,3) ){ | |
return false; | |
} | |
} | |
return true; | |
} |
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
<?php | |
$lucky = 1781773465; | |
$words = ['','fizz','buzz', 'fizzbuzz']; | |
for($i=1; $i<=100;$i++){ | |
if( $i%15 == 1 ){ | |
srand($lucky); | |
} | |
echo "$i: ".$words[rand(0,3)] . PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment