-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.py
107 lines (95 loc) · 2.41 KB
/
generator.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import sys
import random
'''definition of auxiliary functions'''
def verify_type(game):
if game == "mega_sena":
return False
elif game == "dupla_sena":
return False
elif game == "lotomania":
return False
elif game == "loto_facil":
return False
elif game == "quina":
return False
else:
return True
def print_game(numbers):
numbers.sort()
print "The luck numbers:",
for no in numbers:
print no,
print
#quina game, as used in real life algarisms of ten and unity are choose
#independently
def quina():
numbers = []
x = range(5)
for i in x:
no1 = random.randint(0,7)
no2 = random.randint(0,9)
number = no1*10 + no2
if number == 0:
number = 80
if number in numbers:
x.append(x[-1]+1)
else:
numbers.append(number)
return numbers
def mega_sena():
numbers = []
x = range(6)
for i in x:
number = random.randint(1,60)
if number in numbers:
x.append(x[-1]+1)
else:
numbers.append(number)
return numbers
def loto_facil():
numbers = []
x = range(15);
for i in x:
number = random.randint(1,25)
if number in numbers:
x.append(x[-1]+1)
else:
numbers.append(number)
return numbers
def lotomania():
numbers = []
x = range(50)
for i in x:
no1 = random.randint(0,9)
no2 = random.randint(0,9)
number = no1*10 + no2
if number in numbers:
x.append(x[-1]+1)
else:
numbers.append(number)
return numbers
def dupla_sena():
numbers = []
x = range(6)
for i in x:
number = random.randint(1,50)
if number in numbers:
x.append(x[-1]+1)
else:
numbers.append(number)
return numbers
'''end definitions'''
if __name__ == "__main__":
#reads how many different games user wants
no_game = int(sys.argv[1])
#reads which kind of game user wants
type_game = sys.argv[2]
if verify_type(type_game):
print "Wrong time of game passed. Lookup the README for usage"
sys.exit(1)
#loop as many times as passed by user
for i in range(no_game):
millions_numbers = locals()[type_game]()
print "This is your #%d game"%(i+1)
print_game(millions_numbers)
print "Good luck!"