@ 2019-02-02T18:39:21Z <?php
$lizards = [];
for ($i = 0; $i < 15; $i++) {
$lizards[] = 1;
}
for ($i = 0; $i < 7; $i++) {
$lizards[] = 2;
}
for ($i = 0; $i < 8; $i++) {
$lizards[] = 3;
}
srand(time());
for ($i = 0; $i < 10000; $i++) {
$a1 = mt_rand(0, count($lizards) - 1);
do {
$a2 = mt_rand(0, count($lizards) - 1);
} while ($a1 == $a2);
if ($lizards[$a1] == $lizards[$a2]) {
continue;
}
$new_color = 6 - $lizards[$a1] - $lizards[$a2];
$lizards[$a1] = $new_color;
$lizards[$a2] = $new_color;
$colors_count = (in_array(1, $lizards) ? 1 : 0) + (in_array(2, $lizards) ? 1 : 0) + (in_array(3, $lizards) ? 1 : 0);
if ($colors_count == 1) {
echo "Остался только один цвет\n";
break;
}
$counts = [null, 0, 0, 0];
foreach ($lizards as $color) {
$counts[$color]++;
}
echo sprintf("%s\t%s\t%s\n", $counts[1], $counts[2], $counts[3]);
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.3.1 0.078 0.025 14.55 7.3.0 0.096 0.021 14.94 7.2.13 0.094 0.020 14.93 7.2.12 0.090 0.017 14.98 7.2.11 0.079 0.013 15.16 7.2.10 0.100 0.029 14.74 7.2.9 0.093 0.033 15.13 7.2.8 0.075 0.010 14.89 7.2.7 0.093 0.017 14.62 7.2.6 0.121 0.024 14.89 7.2.5 0.067 0.026 14.97 7.2.4 0.091 0.026 15.13 7.2.3 0.080 0.007 15.05 7.2.2 0.124 0.023 15.07 7.2.1 0.071 0.016 15.00 7.2.0 0.084 0.020 15.30 7.1.25 0.117 0.014 13.64
preferences:dark mode live preview ace vim emacs key bindings
37.41 ms | 403 KiB | 5 Q