Projectebench ----> problem = 32 ---- pandigital Products

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.