Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- *******************************************************************************
- * Written by I.F. Luis Mex Dzib 1/May/2014
- * krtk_140989<at>hotmail<dot>com
- * This program Solve the following:...
- It can be seen that the number, 125874, and its double, 251748,
- contain exactly the same digits, but in a different order.
- Find the smallest positive integer, x, such that 2x,
- 3x, 4x, 5x, and 6x, contain the same digits.'''
- def contiene(numero,mult):
- numeros = []
- comparacion = []
- cad_numero = str(numero)
- cad_mult = str(numero*mult)
- if (len(cad_numero) < len(cad_mult)):
- return False
- for i in range(0,len(cad_numero)):
- numeros.append(int(cad_numero[i]))
- comparacion.append(int(cad_mult[i]))
- numeros.sort()
- comparacion.sort()
- i = 0
- while True:
- if i >= len(numeros): break
- if numeros[i] != comparacion[i]:
- return False
- elif numeros[i] == comparacion[i]:
- i+=1
- return True
- cont = 0
- numero = 1
- _max = 6
- while True:
- if cont >= _max:
- break
- if contiene(numero,2):
- for i in range(3,_max+1):
- if contiene(numero,i) == False :
- cont = 0
- numero+=1
- else:
- cont+=1
- else:
- numero+=1
- for m in range(2,_max+1):
- print numero,contiene(numero,m),m,"x",m*numero
Advertisement
Add Comment
Please, Sign In to add comment