<?php
function cai_bolinha($linhas) {
$sorteio = mt_rand() % (1 << $linhas); }
$linhas = 15;
$bolinhas = 100000;
$casas = [];
for ($i = 0; $i <= $linhas; $i++) {
$casas[$i] = 0;
}
for ($i = 0; $i < $bolinhas; $i++) {
$casa_resultante = cai_bolinha($linhas);
$casas[$casa_resultante]++;
}
for ($i = 0; $i <= $linhas; $i++) {
echo $i . "->" . $casas[$i] . "\n";
}
?>
PD9waHAKICAgIGZ1bmN0aW9uIGNhaV9ib2xpbmhhKCRsaW5oYXMpIHsKICAgICAgICAkc29ydGVpbyA9IG10X3JhbmQoKSAlICgxIDw8ICRsaW5oYXMpOwogICAgICAgIHJldHVybiBzdWJzdHJfY291bnQoZGVjYmluKCRzb3J0ZWlvKSwgJzEnKTsKICAgIH0KCiAgICAkbGluaGFzID0gMTU7CiAgICAkYm9saW5oYXMgPSAxMDAwMDA7CgogICAgJGNhc2FzID0gW107CiAgICBmb3IgKCRpID0gMDsgJGkgPD0gJGxpbmhhczsgJGkrKykgewogICAgICAgICRjYXNhc1skaV0gPSAwOwogICAgfQoKICAgIGZvciAoJGkgPSAwOyAkaSA8ICRib2xpbmhhczsgJGkrKykgewogICAgICAgICRjYXNhX3Jlc3VsdGFudGUgPSBjYWlfYm9saW5oYSgkbGluaGFzKTsKICAgICAgICAkY2FzYXNbJGNhc2FfcmVzdWx0YW50ZV0rKzsKICAgIH0KCiAgICBmb3IgKCRpID0gMDsgJGkgPD0gJGxpbmhhczsgJGkrKykgewogICAgICAgIGVjaG8gJGkgLiAiLT4iIC4gJGNhc2FzWyRpXSAuICJcbiI7CiAgICB9Cj8+