Created
June 12, 2014 16:28
-
-
Save TimWolla/ef23b01756a90e65a45f to your computer and use it in GitHub Desktop.
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 | |
$results = []; | |
for ($i = 0; $i < 100000; $i++) mt_rand(); | |
for ($i = 0; $i < 70000; $i++) { | |
do { | |
$items = [ | |
1 => 1, | |
2 => 2, | |
3 => 3, | |
4 => 4, | |
5 => 5, | |
6 => 6, | |
7 => 7, | |
]; | |
while (count($items) > 6) { | |
foreach ($items as $key => $item) { | |
if (!in_array(mt_rand(1, 6), [ 2, 3, 5 ])) { | |
unset($items[$key]); | |
} | |
} | |
} | |
} | |
while (count($items) == 0); | |
do { $number = mt_rand(1, 6); } | |
while ($number > count($items)); | |
@$results[$items[array_keys($items)[$number - 1]]]++; | |
} | |
ksort($results); | |
var_dump($results); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment