Created
May 29, 2018 04:04
-
-
Save wellmotta/e79bb34f0cbfadc8977f8abb595cd662 to your computer and use it in GitHub Desktop.
302685-stackoverflow created by wellmotta - https://repl.it/@wellmotta/302685-stackoverflow
This file contains 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
import random | |
from itertools import chain | |
numeros = [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] | |
listas = [] | |
def gera_lista(qnt): | |
nova_lista = [] | |
# Sorteia os 13 primeiros elementos | |
primeiros = random.sample(numeros, 13) | |
for i in range(0, qnt): | |
# Adiciona os primeiros elementos na nova lista | |
nova_lista.extend(primeiros) | |
# Adiciona os outros dois elementos | |
diferente(nova_lista) | |
listas.append(nova_lista) | |
nova_lista = [] | |
def diferente(lista): | |
# Sortea dois números | |
a, b = random.sample(numeros, 2) | |
# Verifica se 'a' e 'b' não esta na lista | |
# se estiver, chama a função novamente, caso contrário | |
# adiciona | |
[lista.extend([a,b]) if (a not in chain.from_iterable(listas)) and (b not in chain.from_iterable(listas)) else diferente(lista)] | |
gera_lista(5) | |
print(listas) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment