# 1. Secretary problem by simulation ## Problem Description: We will see N=100 job candidates whose levels are random between 0 and 10. We see the candidates one-by-one, and after seeing each candidate, we have to make a decision on the spot whether to hire this candidate or not. This decision is irrevocable and we cannot change our mind later! We want to _maximize the probability to hire the best out of the N candidates_. To do so, we will implement the following policy: * Reject the first R candidates. * Then hire the first one we see that is better than the best among the first R. Write a program that decides the optimal threshold R using simulations. ```python= def simulate(R): assert 1 <= R <= 99 lvls = [random.randint(0,10) for i in range(100)] max_lvl = max(lvls) highest_lvl_in_R = 0 for i in range(R): lvl = lvls[i] if lvl > highest_lvl_in_R: highest_lvl_in_R = lvl for i in range(100-R): lvl = lvls[i] if lvl >= highest_lvl_in_R: if max_lvl == lvl: return 1 else: return 0 return 0 def simulation_process(): succeses = [0 for i in range(100)] for i in range(1,100): for j in range(1000): succeses[i] += simulate(i) return succeses.index(max(succeses)) ```