A prize is behind one of doors doors, each as likely as the others, and you pick door 1. The host then opens opened of the other doors, and they’re all empty. Write chance_if_switch(doors, opened, host_knows): the chance you win if you switch to one particular other door that’s still closed. When host_knows is True he knows where the prize is and only ever opens empty doors; when it’s False he opened doors at random, and this time they just happened to be empty.
Three doors, a prize behind one; you pick door 1 and the host, who knows where it is, opens an empty one. Two doors are left, so 50/50? 100 games say otherwise, and the bars over the doors count where the prize was. The goal is that chance for any number of doors, any doors opened, and either kind of host.
chance_if_switch(doors, opened, host_knows)| doors | how many doors there are; the prize is behind one at random, and you picked door 1 | e.g. 3 |
| opened | how many of the other doors the host opened, all of them empty | e.g. 1 |
| host_knows | True if the host knows where the prize is (he only opens empty doors), False if he opened doors at random and they happened to be empty | e.g. True |
| returns | the chance you win if you switch to one particular other door that's still closed | |