Created
October 17, 2017 02:14
-
-
Save AgustinParmisano/b5879071cd6748ffc3f436de5fcf752a to your computer and use it in GitHub Desktop.
combinatoria de dos numeros x e y checkeando resultado z
This file contains hidden or 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 | |
| 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