Skip to content

Instantly share code, notes, and snippets.

@AgustinParmisano
Created October 17, 2017 02:14
Show Gist options
  • Select an option

  • Save AgustinParmisano/b5879071cd6748ffc3f436de5fcf752a to your computer and use it in GitHub Desktop.

Select an option

Save AgustinParmisano/b5879071cd6748ffc3f436de5fcf752a to your computer and use it in GitHub Desktop.
combinatoria de dos numeros x e y checkeando resultado z
import random
cant = random.randint(3,999)
ult = random.randint(2,999)
nums = []
for i in range(0,cant):
num = random.randint(1,1000)
nums.append(num)
print "Generando numeros ... " + str(num)
print " "
print "Lista de numeros: " + str(nums)
print " "
print "La cantidad de numeros es " + str(cant)
print " "
print "El ultimo numero es " + str(ult)
print " "
usados = []
parejas = []
for x in nums:
for y in nums:
if x not in usados:
if x + y == ult:
print "x + y = ult: " + str(x) + " + " + str(y) + " + " + " = " + str(ult)
par = (x,y)
parejas.append(par)
usados.append(x)
usados.append(y)
print "parejas:" + str(parejas)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment