Skip to content

Instantly share code, notes, and snippets.

@OutOfBrain
Created March 1, 2016 21:20
Show Gist options
  • Select an option

  • Save OutOfBrain/e74aefcfbaca5cba449d to your computer and use it in GitHub Desktop.

Select an option

Save OutOfBrain/e74aefcfbaca5cba449d to your computer and use it in GitHub Desktop.
<?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