The Monty Hall problem is a probability puzzle base on the American TV show "Let's Make A Deal".

In this show, you would be presented with 3 doors: One with a prize behind it, and two without (represented with goats).

After choosing a door, the host would open one of the other two doors which didn't include a prize, and ask the participant if he or she wanted to switch to the third door. Most wouldn't. One would think you have a fifty-fifty chance of winning after having been shown a false door, however the math proves that you significantly increase your chances, from 1/3 to 2/3 by switching.

Further information about this puzzle can be found on https://en.wikipedia.org/wiki/Monty_Hall_problem.

In this program you are given an array of people who have all guessed on a door from 1-3, as well as given the door which includes the price. You need to make every person switch to the other door, and increase their chances of winning. Return the win percentage (as a rounded int) of all participants.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def monty_hall(correct_door_number, participant_guesses):
	

Solutions:
def monty_hall(door, guesses):
	return round(100.0 * (len(guesses) - guesses.count(door)) / len(guesses))


def monty_hall(c, p):
	print((c, p))
	return round((1 - p.count(c) / len(p)) * 100)


def monty_hall(correct, guesses):
	return round(sum([correct != x for x in guesses]) / len(guesses) * 100)


def monty_hall(correct_door_number, participant_guesses):
	return round(100 * sum((1 for x in participant_guesses if x != correct_door_number)) / len(participant_guesses))


def monty_hall(correct_door_number, participant_guesses):
	winners = 0
	for x in participant_guesses:
		if x != correct_door_number:
			winners += 1
	return round(winners / len(participant_guesses) * 100)


def monty_hall(cdoor, pguesses):
	pick_cdoor = 1 - pguesses.count(cdoor) / len(pguesses)
	return round(pick_cdoor * 100)


from statistics import mean

def monty_hall(correct_door_number, participant_guesses):
	return round(mean([100 if p != correct_door_number else 0 for p in participant_guesses]))


def monty_hall(correct, guesses):
	return round(100 - 100.0 * guesses.count(correct) / len(guesses))


def monty_hall(correct, guess):
	return int(round(sum((1 for i in guess if i != correct)) / len(guess), 2) * 100)


def monty_hall(x, a):
	return round(100 * sum((1 for i in a if i != x)) / len(a))