Created
March 1, 2016 21:20
-
-
Save OutOfBrain/e74aefcfbaca5cba449d to your computer and use it in GitHub Desktop.
solving the riddle of https://www.youtube.com/watch?v=cpwSGsb-rTs
This file contains hidden or 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 | |
| const MALE = 1; | |
| const FEMALE = 0; | |
| $leftFemale = 0; | |
| $rightFemale = 0; | |
| $i = 0; | |
| while (true) { | |
| $frogLeft1 = rand(0,1); | |
| $frogLeft2 = rand(0,1); | |
| $frogRight = rand(0,1); | |
| if ($frogLeft1 == MALE || $frogLeft2 == MALE) { | |
| $i++; | |
| if ($i >= 100000) { | |
| break; | |
| } | |
| if ($frogLeft1 == FEMALE || $frogLeft2 == FEMALE) { | |
| $leftFemale++; | |
| } | |
| if ($frogRight == FEMALE) { | |
| $rightFemale++; | |
| } | |
| } | |
| } | |
| var_dump($leftFemale, $rightFemale); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment