This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' A tennis club invites 32 players of equal ability to compete in an elimination tournament. | |
| (Only the winner of the pair will stay for the next round) | |
| What is the probability that a particular pair of players will meet during the tournament?''' | |
| import random | |
| count = 0 | |
| def recursive_round(a): # we create a recursive function to simulate the tournament where the argument is a list | |
| if len(a) == 1: | |
| return a[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # On average how many times do you need to roll a die before all six different numbers show up? | |
| import random | |
| dado = [i for i in range (1,7)] | |
| throw_list = [] | |
| N = 100000 # montecarlo method | |
| for i in range(N): | |
| lista = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ Given the first 10 numbers, we want to know how many snake permutations exist, where a snake permutations is: | |
| x1 < x2 > x3 < x4 > x5 < x6 > x7 < x8 > x9 < x10 | |
| The result is very counterintuitive....more than 50000 snake permutation exist. | |
| It takes a lot of time to have the output, so take only the idea of the code...""" | |
| import random | |
| union = [] | |
| for i in range (25000000): | |
| A = [s for s in range (1,11)] | |
| new = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """We want to calculate the probabilty that in a set of 3 sets, each composed of 3 different integers in the range [1,9] | |
| we have at least one set where all the integers are odd""" | |
| import random | |
| print("""We want to calculate the probabilty that in a set of 3 sets, each composed of 3 different integers in the range [1,9] | |
| we have at least one set where all the integers are odd\n\n""") | |
| print("For example in the list [[1,4,5],[7,3,9],[2,6,8]] we have 1 sublist where all numbers are odd\n\n") | |
| print("Let's start...") | |
| print("Loading...") |
NewerOlder