Problem 061

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.
Josay
Posts: 2
Joined: Mon Mar 31, 2008 2:19 pm

Problem 061

Post by Josay »

Hello everybody,
I've got troubles with the problem 61.
(Link to problem added by moderator: Problem 61 (View Problem))

The wording is :
Find the sum of the only ordered set of six cyclic 4-digit numbers for which each polygonal type: triangle, square, pentagonal, hexagonal, heptagonal, and octagonal, is represented by a different number in the set.
I found this solution : n1=1 n2=148 n3=4851 n4=5151 n5=5184 n6=8400

First point is each polygonal type is represented by a different number :

Code: Select all

         n1=1    n2=148  n3=4851 n4=5151 n5=5184 n6=8400
tri     1       0      *1*      1       0       0
squ     1       0       0       0      *1*      0
pen     1       0       0       0       0      *1*
hex     1       0       0      *1*      0       0
hep     1      *1*      0       0       0       0
oct    *1*      0       0       0       0       0

        tri     squ     pen     hex     hep     oct
n1:   1 1       1       1       1       1      *1*
n2: 148 0       0       0       0      *1*      0
n3:4851*1*      0       0       0       0       0
n4:5151 1       0       0      *1*      0       0
n5:5184 0      *1*      0       0       0       0
n6:8400 0       0      *1*      0       0       0
s:23735
Second point is this solution is cyclic and composed by 6 4-digits numbers:

Code: Select all

0001
  148
    4851
      5151
        5184
          8400
            0001 and so on
I still don't see why my solution is not good. So iif someone could help me telling me what part of the problem I could have misunderstood.

Thanks.

(Sorry for my poor English)
User avatar
Tommy137
Posts: 238
Joined: Sun Feb 24, 2008 6:02 pm
Location: Cologne, Germany
Contact:

Re: Problem with the problem 61

Post by Tommy137 »

We always write numbers without leading zeros.
Image
Josay
Posts: 2
Joined: Mon Mar 31, 2008 2:19 pm

Re: Problem with the problem 61

Post by Josay »

Ok, that is a good reason.

Thanks a lot.

Edit : Well, in fact I discovered the true solution. I was searching n1<n2<n3<n4<n5<n6 and finally, it was not the case.
Could anybody explain me what "Find the sum of the only ordered set of six cyclic 4-digit numbers for which each polygonal type" means?
MaJJ
Posts: 49
Joined: Tue Oct 14, 2008 12:14 am

Re: Problem 061

Post by MaJJ »

Hi there,
I've got troubles with this one. Everything looks fine, my code outputs (!) two answers, but they are wrong.

Code: Select all

4465 + 6561 + 6112 + 1225 + 2512 + 1281
22156

5565 + 6561 + 6112 + 1225 + 2512 + 1281
23256
What's wrong?
Thanks in advance :-)
Image
Image
User avatar
Tommy137
Posts: 238
Joined: Sun Feb 24, 2008 6:02 pm
Location: Cologne, Germany
Contact:

Re: Problem 061

Post by Tommy137 »

MaJJ wrote:Hi there,
I've got troubles with this one. Everything looks fine, my code outputs (!) two answers, but they are wrong.

Code: Select all

4465 + 6561 + 6112 + 1225 + 2512 + 1281
22156

5565 + 6561 + 6112 + 1225 + 2512 + 1281
23256
What's wrong?
Thanks in advance :-)

"The set is cyclic, in that the last two digits of each number is the first two digits of the next number (including the last number with the first). "

So, if your last number is 1281, the first number should be 81..
Image
MaJJ
Posts: 49
Joined: Tue Oct 14, 2008 12:14 am

Re: Problem 061

Post by MaJJ »

Aha, I somehow skipped that sentence :) Thanks.
Edit: Heh, now my code can't find any such set :) I guess my conditions are too strict...
Image
Image
estanford
Posts: 10
Joined: Sun Sep 13, 2009 12:06 pm

Re: Problem 061

Post by estanford »

Quick question about this problem -- how is it possible that each of the six numbers separately represent a triangular, square, pentagonal, hexagonal, heptagonal and octagonal number when all hexagonal numbers are triangular?
User avatar
rayfil
Administrator
Posts: 1412
Joined: Sun Mar 26, 2006 5:30 am
Location: Quebec, Canada
Contact:

Re: Problem 061

Post by rayfil »

when all hexagonal numbers are triangular?
But, not all triangular numbers are hexagonal.
When you assume something, you risk being wrong half the time.
klang
Posts: 3
Joined: Sun Aug 15, 2010 8:23 am

Re: Problem 061

Post by klang »

Strangely, using this (wrong) definition of heptagonals ALSO produce a unique reply .. the wrong one of course

Code: Select all

(def heptagonals 
     (map (fn [n] (quot (* n (- (* 5 n) 1)) 3)) (iterate inc 1)))
Image
iordan_tanev
Posts: 6
Joined: Mon Jan 17, 2011 3:25 pm

Re: Problem 061

Post by iordan_tanev »

Hi,
i have a simple problem and i cant find the problem in my code. When i run the algorithm without the check that triangle number is not Hexagonal i get 6 sets. One of these sets is:
The problem is that 8128 is Triangle and Hexagonal. But when i add in my algorithm check to exclude sets with numbers both Triangle and Hexagonal i get zero results. Is this check not needed or am i missing something else.
Best Regards,
Iordan
Last edited by iordan_tanev on Mon Jan 17, 2011 5:46 pm, edited 1 time in total.
Mr.Wizard
Posts: 26
Joined: Sun Jan 02, 2011 9:20 am

Re: Problem 061

Post by Mr.Wizard »

The check is not needed. Now, remove your output, please.
ImageImage
iordan_tanev
Posts: 6
Joined: Mon Jan 17, 2011 3:25 pm

Re: Problem 061

Post by iordan_tanev »

Hi,
thanks a lot for the quick answer. Your help is greatly appreciateа
Best Regards,
Iordan
ReNegr
Posts: 2
Joined: Sat Jan 22, 2011 1:14 pm

Re: Problem 061

Post by ReNegr »

Hi,

I'm having a little trouble with the wording of this one.
I get the cyclic part but what they mean by ordered set?

Is it this? n1>=n2>=n3>=n4>=n5>=n6 ?

Best Regards,
Renato
User avatar
Lord_Farin
Posts: 239
Joined: Wed Jul 01, 2009 10:43 am
Location: Netherlands

Re: Problem 061

Post by Lord_Farin »

ReNegr wrote:Hi,

I'm having a little trouble with the wording of this one.
I get the cyclic part but what they mean by ordered set?

Is it this? n1>=n2>=n3>=n4>=n5>=n6 ?

Best Regards,
Renato
No, it means only that your set comes with a given order. That is, it is given which number is on which place in your list.
An example: As unordered sets, {2,3} and {3,2} are equal, but as ordered sets, they are not.
Image
ReNegr
Posts: 2
Joined: Sat Jan 22, 2011 1:14 pm

Re: Problem 061

Post by ReNegr »

Find the sum of the only ordered set of six cyclic 4-digit numbers for which each polygonal type: triangle, square, pentagonal, hexagonal, heptagonal, and octagonal
This means that the first number has to be a triangle, the second a square and so on ?

Best Regards,
Renato
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 061

Post by TripleM »

No, it doesn't say they have to be in that order. In fact, they're not in order in the previous example either - 8281 was the square number.
chiefsci
Posts: 3
Joined: Tue Nov 30, 2010 8:35 pm

Re: Problem 061

Post by chiefsci »

I've written a program in C++ that should tell me the answer. Unfortunately, I've written it with a segment that has 12 nested "for" loops, and while the inner 6 loops are n=0 to 5, the outer loops are n=0 to 96. From my calculations, this will take over 490 days to run.

Can anybody give me an idea of how to make this program more efficient? There must be a way to solve this without comparing each and every possible combination of triangular numbers, square numbers, pentagonal numbers, hexagonal numbers, heptagonal numbers, and octagonal numbers, but I seem to be missing it.
Image
User avatar
rayfil
Administrator
Posts: 1412
Joined: Sun Mar 26, 2006 5:30 am
Location: Quebec, Canada
Contact:

Re: Problem 061

Post by rayfil »

There must be a way to solve this without ....
Yes there is, almost instantaneous. 8-)
When you assume something, you risk being wrong half the time.
chiefsci
Posts: 3
Joined: Tue Nov 30, 2010 8:35 pm

Re: Problem 061

Post by chiefsci »

And I'm guessing it has nothing to do with storing the values in a 2D array...
Image
thundre
Posts: 356
Joined: Sun Mar 27, 2011 10:01 am

Re: Problem 061

Post by thundre »

klang wrote:Strangely, using this (wrong) definition of heptagonals ALSO produce a unique reply .. the wrong one of course

Code: Select all

(def heptagonals 
     (map (fn [n] (quot (* n (- (* 5 n) 1)) 3)) (iterate inc 1)))
Weird, I made exactly the same mistake, dropped the /2 from the formula for heptagonal. The /2 is right there in the problem text, which I always save before starting. I re-checked them all after seeing your comment, and sure enough, I had the same mistake in the same formula, except mine was in Java.
Image
Post Reply