Advertisement
ploffie

Pandigital numbers problem

Oct 31st, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. from itertools import permutations
  2. # the leading number of the sum p3 is 1 - 1 is not used in the permutations
  3. for p in permutations([0,2,3,4,5,6,7,8,9]):
  4.     p = reduce(lambda a, b: 10 * a + b, p)
  5.     p , p3 = divmod(p, 1000)
  6.     p1, p2 = divmod(p, 1000)
  7.     if p1 < p2 and p1 + p2 == p3 + 1000:
  8.         print p1, p2, p3 + 1000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement