Problem 038

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.

This forum is NOT meant to discuss solution methods for a problem.

In particular don't post any code fragments or results.

Don't start begging others to give partial answers to problems

Don't ask for hints how to solve a problem

Don't start a new topic for a problem if there already exists one


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
spen
Posts: 1
Joined: Sun Sep 05, 2010 9:15 pm

Re: Problem 038

Post by spen »

I still must be misunderstanding something. The solution is supposed to be the largest number, nine digits, permutation of 1..9, right? The largest number I get that meets all of the requirements given is given as one of the examples, and is not accepted as the right answer. I can generate 4 other candidates, each from a 3 digit number multiplied by (1, 2, 3). The two examples given are the highest and lowest numbers that I can generate, so I have 3 others.

What am I missing?
User avatar
Slaunger
Posts: 40
Joined: Tue Jul 20, 2010 12:23 am

Re: Problem 038

Post by Slaunger »

Hi spen,

It appears to me that you understand the problem correctly, but have overlooked some candidates in your analysis. I do not know how many concatenated pandigital products with three, three-digit numbers there are as those never really caught my interest in the problem.

Slaunger
Image
mury
Posts: 2
Joined: Mon Nov 07, 2011 11:27 am

Re: Problem 038

Post by mury »

People are talking about reverse order here (n,...,3,2,1), but as far as I understand the problem, we are looking for the closest to 999999999 number that can be formed as the concatenated product of an integer and one of the lists:
(1,2)
(1,2,3)
(1,2,3,4)
.............
(1,2,3,4,...,n)
Am I right?
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 038

Post by TripleM »

Yes. The problem used to be worded differently, thus the confusion in the earlier posts.
User avatar
Yamaneko
Posts: 6
Joined: Wed Nov 14, 2012 9:54 pm
Location: Budapest, Hungary

Re: Problem 038

Post by Yamaneko »

I don't want to give away anything, but I have to tell you that I loved working on this one! At first I got sidetracked taking something for granted that I shouldn't have, and I got one of the pandigitals in the example, which of course wasn't the answer. :) Realising my supposition was wrong made me come up with better, more flexible code and also made me aware that I was overlooking some cases that I really shouldn't have. This time I loved being wrong. Cheers! :D
Image
brunnock
Posts: 1
Joined: Tue Feb 05, 2013 12:38 pm

Re: Problem 038

Post by brunnock »

I believe the title is misspelled. I think it should be "multiple".
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 038

Post by hk »

Thanks, changed.
Image
War ruins the life and health of untold numbers of innocent children.
dunne
Posts: 5
Joined: Sat Mar 16, 2013 11:43 am
Location: Hamburg
Contact:

Re: Problem 038

Post by dunne »

I am completely stuck on this. I can't for the life of me see why the second example is not the right answer -- and my program agrees with me! ;-) Does anyone feel like giving me a slight hint?
Image
thundre
Posts: 356
Joined: Sun Mar 27, 2011 10:01 am

Re: Problem 038

Post by thundre »

dunne wrote:I am completely stuck on this. I can't for the life of me see why the second example is not the right answer -- and my program agrees with me! ;-) Does anyone feel like giving me a slight hint?
The number of concatenated products can be anywhere from 2 to 9. Don't get in a rut thinking that they must all be the same number of digits.
Image
dunne
Posts: 5
Joined: Sat Mar 16, 2013 11:43 am
Location: Hamburg
Contact:

Re: Problem 038

Post by dunne »

thundre wrote:
dunne wrote:I am completely stuck on this. I can't for the life of me see why the second example is not the right answer -- and my program agrees with me! ;-) Does anyone feel like giving me a slight hint?
The number of concatenated products can be anywhere from 2 to 9. Don't get in a rut thinking that they must all be the same number of digits.
Thanks, thundre. I am sure I have avoided this problem. Here's what I am doing (hopefully not giving away too much -- I doubt it, since my method is clearly flawed!) :

I am taking from 1 to 4 (although I think 3 is the actual limit) of the most signficant digits in turn from each pandigital, and generating and concatenating the products one by one, using 1,2,3...9. I don't bother about the number of products or the number of digits in each product. I have a check that stops this generation/concatenation as soon as the pandigital is reached or exceeded. I am doing this for *all* pandigitals, starting with the biggest. I get valid results, but the highest is always the second example from the problem text.
Image
thundre
Posts: 356
Joined: Sun Mar 27, 2011 10:01 am

Re: Problem 038

Post by thundre »

dunne wrote: I am taking from 1 to 4 (although I think 3 is the actual limit) of the most signficant digits in turn from each pandigital, and generating and concatenating the products one by one, using 1,2,3...9. I don't bother about the number of products or the number of digits in each product. I have a check that stops this generation/concatenation as soon as the pandigital is reached or exceeded. I am doing this for *all* pandigitals, starting with the biggest. I get valid results, but the highest is always the second example from the problem text.
So you're checking all 9! pandigitals, or at least the ~8! which are greater than 918273645.

If instead of a pandigital you give it 666613332, does it acknowledge that it's 6666 * (1,2)?
Image
dunne
Posts: 5
Joined: Sat Mar 16, 2013 11:43 am
Location: Hamburg
Contact:

Re: Problem 038

Post by dunne »

thundre wrote: So you're checking all 9! pandigitals, or at least the ~8! which are greater than 918273645.

If instead of a pandigital you give it 666613332, does it acknowledge that it's 6666 * (1,2)?
I am *generating* all 9!, but since I sort before checking and start checking at the end of the array, I stop at the first one found, which by definition is the biggest.

I gave it that number, it *didn't* acknowledge it, and almost at once I knew exactly why! Thanks a lot thundre, just a simple coding error but without talking it through with someone I doubt I would have spotted it any time soon.
Image
ubershmekel
Posts: 1
Joined: Mon Apr 30, 2018 8:26 am

Problem 038

Post by ubershmekel »

Take the number 192 and multiply it by each of 1, 2, and 3:
[..]
By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3)
When I read through this problem, I didn't realize what "1 to 9 pandigital" meant until I submitted the wrong answer a few times. My impression was that "1 to 9 pandigital" meant a number with 9 digits that was created through that multiplication form. I would recommend revising the text to define pandigital. For example:
By concatenating each product we get the 1 to 9 pandigital (a number that contains all the digits 1-9), 192384576...
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 038

Post by hk »

Please don't start a new topic for a problem if there exists one already.
Image
War ruins the life and health of untold numbers of innocent children.
fistuk
Posts: 1
Joined: Sun Nov 11, 2018 11:06 am

Re: Problem 038

Post by fistuk »

sorry couldn't find the other post so I'm asking here:

I probably don't get something regarding pandigitals since I had the same problem at 032.

I get a better answer that only the 2nd best is being accepted.
So maybe can someone explain me what's bad with 2469 *4 and 2469 *5 ?
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 038

Post by hk »

If you want to go up to 5 you have to concatenate 2469*1 and 2469*2 and 2469*3 and 2469*4 and 2469*5.
This gives 246949387407987612345
Image
War ruins the life and health of untold numbers of innocent children.
imallett
Posts: 2
Joined: Sat Dec 07, 2019 7:52 am

Re: Problem 038

Post by imallett »

I was able to easily solve this problem, as far as I can tell, but my solution is not accepted. After some searching, I have found a few (forbidden) solutions to this problem that purport to give the right answer. However, my answer is much larger than these. Moreover, I can spot the errors in their solutions.

It is of-course easy to validate by hand that my answer is a correct 9-digit pandigital and that is larger than these solutions. However, I have also generated a manual proof that my solution must be the largest.

Since I can't post solutions or algorithms, about all I can do is restate the question as I understood it in the hope that I have misunderstood something:
Given any nonnegative integer and tuple of nonnegative integers, define the pandigital as the decimal representations of the elements of the tuple times the integer, concatenated. Using the provided examples, if the integer is 192 and the tuple is (1,2,3), then the pandigital is 192384576. The number of digits in the subproducts changing doesn't matter. E.g. if the integer is 9 and the tuple is (1,2), then the pandigital is 918; the second subproduct "overflowing" to 18 simply makes the pandigital 3 digits instead of 2.

The problem is: suppose that the tuple must be the first n elements of the natural numbers, where n>1 (that is, the tuple contains at-least two elements). Now, find the pandigital that is 9 digits long and is larger than all other such 9-digit pandigitals.
If I have not misunderstood anything, then I would like to know what I should do to determine whether my answer is correct, since it doesn't seem like I am allowed to state my answer or a program that generates it, and I don't know whether the correct answer is somehow even larger yet and my program has a bug.
User avatar
Valentyn_Shtronda
Posts: 27
Joined: Tue Sep 11, 2012 9:18 pm
Location: Ukraine

Re: Problem 038

Post by Valentyn_Shtronda »

918 is not pandigital.
imallett
Posts: 2
Joined: Sat Dec 07, 2019 7:52 am

Re: Problem 038

Post by imallett »

Or, more-precisely, the result must also contain the digits 1–9 to be a "1-9 pandigital". Thanks! That got the right answer.
Post Reply