Generation

generate functionSun, 13 Nov 2022

Monty hall problem that takes the chosen door as input and if I switch or not. Return if won

function montyHall(chosenDoor: number, switch: boolean): boolean { const winningDoor = Math.floor(Math.random() * 3) + 1; if (chosenDoor === winningDoor) { if (switch) { return false; } return true; } else { if (switch) { return true; } return false; } }

TypeScript
Generate More

Want to kickstart your project?Use the new AI Studio to create your code