Skip to content

Instantly share code, notes, and snippets.

@TimWolla
Created June 12, 2014 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimWolla/ef23b01756a90e65a45f to your computer and use it in GitHub Desktop.
Save TimWolla/ef23b01756a90e65a45f to your computer and use it in GitHub Desktop.
<?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