#GPC - 2017
#Gera chaves de euromilhões
#com certas imposições
import numpy as np
from random import randint
import winsound
Freq = 880 # Set Frequency To 2500 Hertz
Dur = 1 # Set Duration To 1000 ms == 1 second
winsound.Beep(700,65)
quantas = int(input("Quantas chaves?"))
contagem = 1
ficheiro = open("C:\Python34\chaves.txt", "w")
while(contagem <= quantas):
mylist=np.random.choice([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], 5,
replace=False,p=[0.02702702702702703, 0.016216216216216217, 0.021621621621621623,
0.016216216216216217, 0.02702702702702703, 0.016216216216216217,
0.016216216216216217, 0.016216216216216217, 0.03783783783783784,
0.032432432432432434, 0.005405405405405406, 0.016216216216216217,
0.02702702702702703, 0.032432432432432434, 0.02702702702702703,
0.016216216216216217, 0.016216216216216217, 0.0162162162162,
0.02702702702702703, 0.005405405405405406, 0.016216216216216217,
0.010810810810810811, 0.03783783783783784, 0.016216216216216217,
0.021621621621621623, 0.02702702702702703, 0.021621621621621623,
0.02702702702702703, 0.005405405405405406, 0.021621621621621623,
0.016216216216216217, 0.043243243243243246, 0.005405405405405406,
0.02702702702702703, 0, 0.016216216216216217, 0.032432432432432434,
0.02702702702702703, 0.005405405405405406, 0.032432432432432434,
0.010810810810810811, 0.02702702702702703, 0.03783783783783784,
0.005405405405405406, 0.010810810810810811,0.016216216216216217,
0.005405405405405406, 0.016216216216216217, 0.032432432432432434,
0.010810810810810811])
# [i = randint(1,50) for i in range(5)] # bah
mylist = list(set(mylist))
mylist.sort()
mylist2 = [j for j in range (1,3)]
mylist2[0] = randint(1,11)
mylist2[1] = randint(1,11)
mylist2 = list(set(mylist2))
mylist2.sort()
if len(mylist) !=5:
continue
elif len(mylist2) != 2:
continue
#5555555555555555555555555555555555555555555555
# CONDIÇÔES
amplitude = mylist[4] - mylist[0]
if amplitude > 37 or amplitude < 22:
continue
# 4444444444444444444444444444444#4444444444444444444444444444444
dezenas = 0
for i in mylist:
if i%10 == 0:
dezenas = dezenas +1
if dezenas > 2:
continue
# 4444444444444444444444444444444#4444444444444444444444444444444
pares = 0
for i in mylist:
if i % 2 == 0:
pares = pares +1
if pares > 3:
continue
# 4444444444444444444444444444444#4444444444444444444444444444444
impares = 0
for i in mylist:
if i % 2 != 0:
impares = impares + 1
if impares > 3:
continue
# 4444444444444444444444444444444#4444444444444444444444444444444
fibonnaci = [1,2,3,5,8] # uma estrela
primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47] #pelo menos 1 primo
quantos_fibonnaci = len(set(fibonnaci) & set(mylist2))
quantos_primos = len(set(primes) & set (mylist))
if quantos_fibonnaci != 1:
continue
if quantos_primos == 0:
continue
# 4444444444444444444444444444444#4444444444444444444444444444444
if mylist[4] < 32:
continue
if mylist [0] > 23:
continue
# 4444444444444444444444444444444#4444444444444444444444444444444
#fazer não: omissos mais do que 3
# 4444444444444444444444444444444#4444444444444444444444444444444
print("")
print("Chave n.º:", contagem, mylist,mylist2, end=" ")
#print ("amplitude =",amplitude)
contagem = contagem + 1
numeros=str(mylist)
estrelas=str(mylist2)
ficheiro.write("Chave n.º" + str(contagem-1) + ":" + numeros + estrelas + " \n")
continue
ficheiro.close()
import subprocess
subprocess.Popen('notepad "C:\Python34\chaves.txt"')
winsound.Beep(700,65)
print()
print("I'm done, Sir")
No comments:
Post a Comment
Exprima-se livremente!