Fermat's Wager

From BlogNomic Wiki
Revision as of 16:48, 11 August 2020 by Kevan (talk | contribs) (Created page with "Showing my working for [https://blognomic.com/archive/fermats_wager_victory this proposal]. --~~~~ ==Code== <pre>$wins = array(0,0,0,0,0,0,0); for ($i=0; $i<1000000; $i++) {...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Showing my working for this proposal. --Kevan (talk) 16:48, 11 August 2020 (UTC)

Code

$wins = array(0,0,0,0,0,0,0);

for ($i=0; $i<1000000; $i++)
{
        $scores = array(2,2,1,0,0,0,0);

        while (max($scores)<3)
        {
                $scores[rand(0,6)]++;
        }

        $wins[array_search(max($scores),$scores)]++;
}

print_r($wins);

Output

Array
(
    [0] => 408544
    [1] => 409071
    [2] => 93189
    [3] => 22226
    [4] => 22446
    [5] => 22190
    [6] => 22334
)