-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTEP_Dices2.py
More file actions
42 lines (29 loc) · 998 Bytes
/
Copy pathTEP_Dices2.py
File metadata and controls
42 lines (29 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#Topicos especiais em programacao - DCC - UFRJ
#Assignment 6 - Dices
#Allan Monteiro David
#Simulates the roll of dices to test which case is most likely
#Three of a number or two pairs
#But in this case we addicted the dice to roll more 6's
import random
def rollDiceAddictIn6():
rand = random.randint(1, 6*6);
if(rand > 6):
rand = 6;
return rand;
def rollThree():
return (rollDiceAddictIn6(), rollDiceAddictIn6(), rollDiceAddictIn6());
def rollFour():
return (rollDiceAddictIn6(), rollDiceAddictIn6(), rollDiceAddictIn6(), rollDiceAddictIn6());
def testProbabilities():
numberOfThrees = 0;
numberOfTwoPairs = 0;
numberOfTests = 1000000;
for _ in range(0, numberOfTests):
result = rollThree();
if(result[0] == result[1] == result[2]):
numberOfThrees += 1;
result = rollFour();
if(result[0] == result[1] and result[2] == result[3]):
numberOfTwoPairs += 1;
print("Threes: "+str(numberOfThrees)+"\n"+"Two Pairs: "+str(numberOfTwoPairs));
testProbabilities();