# Project Euler #32: Pandigital products

# Project Euler #32: Pandigital products

cnhnyu + 1 comment For N = 9, I got the following result:

4*1738=6952

4*1963=7852

12*483=5796

18*297=5346

27*198=5346

28*157=4396

39*186=7254

42*138=5796

48*159=7632

sum = 56370

I passed all tests except the last one. Can someone please tell me what's going wrong here?

cnhnyu + 1 comment Got it. No duplicate product. Not no duplicate multiplicand/multiplier pair.

bhavikgevariya + 0 comments [deleted]

deekshit_842 + 0 comments ive used brute force approach to solve this and got timeout in testcase 5 can anyone explain it

coder_batman + 0 comments what is the upper limit of the numbers to be considered for multiplicand and multiplier ?

rajesheeda1234 + 0 comments passed all the test cases

import re set1=set() sum=0 n=int(input()) for i in range(1964,1,-1): for j in range(100): if j not in set1: value=i*j str1=str(value)+str(i)+str(j) if value not in set1 : matcher=''.join(str(k) for k in range(1,n+1)) if(re.fullmatch(matcher,''.join(sorted(str1)))): sum=sum+value set1.add(value) print(sum)

tushartyagi8750 + 1 comment i am getting error for numbers greater than 7 i am using the permutation function.any help will be appericiated

prunns + 0 comments I used the same thing. At the beginning I was also getting wrong answers for TC 1,3 and 5. What kind of error are u getting?

I could pass all the cases with a little modification in pypy3 with the last case taking 1.21s

debagnikroy + 1 comment i am getting sum as 0 for n=7. is it correct? my test case 4 is only failing

tushartyagi8750 + 0 comments no it's not 0 for 7

allam_hemanthku1 + 0 comments what we have to add to get the sum becase i am simply breaking the loop .

Haseena_CSE + 1 comment Could you please tell me what is the logic here?

SOKS33 + 0 comments That's mine :

Generate all pandigital numbers of provided size (I use string permutation to compute them quite fast)

Then split into a/b/c of various sizes and try to find a match in a * b = c

Save c only once in your sum (ex : 4312 and 3412 give 4*3 = 12 and 3*4 = 12. Save 12 only once !)

jenilvagadiya19 + 0 comments nicely done Let's say i*j=k is pandigital then for N=5 i=1 j=2 k=2 (number of digits) N=6 i=1 j=2 k=3 and so on ... upto N=9

god_blessme + 1 comment Is there any way other than brute force??

SOKS33 + 0 comments In pandigital generation yes there is better. String permutation ("1234" gives "1234" & "1243" etc.)

Sort 19 Discussions, By:

Please Login in order to post a comment