games: Introduce a simple puzzle game
[lcapit-junk-code.git] / mega-sena.py
blob65c9fa132d93eafcdbe9010ec897d468c6282913
1 #!/usr/bin/python
3 # Mega-sena loterry
5 # Luiz Fernando N. Capitulino
6 # <lcapitulino@gmail.com>
8 from random import randint
9 from sys import exit, argv
11 def megasena(max):
12 numbers = []
13 for i in range(max):
14 while True:
15 val = randint(1, 60)
16 if val in numbers:
17 continue
18 numbers.append(val)
19 break
20 return numbers
22 def main():
23 try:
24 max = int(argv[1])
25 if max < 6 or max > 15:
26 raise ValueError
27 except:
28 max = 6
30 print megasena(max)
31 exit(0)
33 if __name__ == "__main__":
34 main()