Example #1
0
def find_pandigitals():
    pandigitals = []
    for n in xrange(1, 10000):
        result = ''
        for f in xrange(1, 10):
            result += str(n*f)
            if len(result) > 9:
                break
            if is_pandigital(result, 9):
                print n, '-->', result
                pandigitals.append(result)
    return pandigitals
Example #2
0
def find_pandigital_products():
    result = set()
    # a and b must be less than 5 digits, otherwise the total digits would
    # exceed 9.  (e.g. 1 x 10000 = 10000 is 11 digits.)
    for a in range(1, 9999):
        for b in range(a, 9999):
            x = a * b
            string = str(a) + str(b) + str(x)
            # Short circuit if results get too long
            if len(string) > 9:
                break
            if is_pandigital(string, 9):
                print a, "x", b, "=", x
                result.add(x)
    return result