Problem 32
We shall say thatN-Digit number is pandigital if it makes use of all the digits 1NExactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital.
The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital.
Find the sum of all products whose multiplicand/Multiplier/product identity can be written as a 1 through 9 pandigital.
Hint: some products can be obtained in more than one way so be sure to only include it once in your sum.
Def is_pandigital (* ARGs, ** kwargs): # convert the three numbers into strings and sort num = sorted (''. join (STR (ARG) for ARG in ARGs) print num print "kwargs =", kwargs try: If kwargs ['length'] And Len (Num )! = Kwargs ['length']: Return false random t keyerror: Pass for I in range (LEN (Num): If STR (I + 1 )! = STR (Num [I]): Return false return truedef main (): pandigitals = set () Total = 0 for multiplicand in range (1, 5000 ): for multiplier in range (1,100): Product = multiplicand * multiplier if is_pandigital (multiplicand, multiplier, product, length = 9): pandigitals. add (product) print sum (pandigitals) If _ name _ = "_ main _": Main ()
Projectebench ----> problem = 32 ---- pandigital Products