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 1:19 pm

Problem 061

Post by Josay » Mon Mar 31, 2008 1:34 pm

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 » Mon Mar 31, 2008 1:41 pm

We always write numbers without leading zeros.
Image

Josay
Posts: 2
Joined: Mon Mar 31, 2008 1:19 pm

Re: Problem with the problem 61

Post by Josay » Mon Mar 31, 2008 1:50 pm

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: Mon Oct 13, 2008 11:14 pm

Re: Problem 061

Post by MaJJ » Mon Aug 31, 2009 2:30 pm

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 » Mon Aug 31, 2009 2:34 pm

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: Mon Oct 13, 2008 11:14 pm

Re: Problem 061

Post by MaJJ » Mon Aug 31, 2009 2:55 pm

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 11:06 am

Re: Problem 061

Post by estanford » Sun Sep 13, 2009 11:09 am

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: 1401
Joined: Sun Mar 26, 2006 4:30 am
Location: Ontario, Canada
Contact:

Re: Problem 061

Post by rayfil » Sun Sep 13, 2009 6:41 pm

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 7:23 am

Re: Problem 061

Post by klang » Sun Oct 03, 2010 3:41 pm

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 » Mon Jan 17, 2011 3:32 pm

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 » Mon Jan 17, 2011 5:04 pm

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 » Mon Jan 17, 2011 7:35 pm

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 » Sat Jan 22, 2011 2:35 pm

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 9:43 am
Location: Netherlands

Re: Problem 061

Post by Lord_Farin » Sat Jan 22, 2011 2:43 pm

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 » Sat Jan 22, 2011 2:49 pm

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: 382
Joined: Fri Sep 12, 2008 2:31 am

Re: Problem 061

Post by TripleM » Sat Jan 22, 2011 7:33 pm

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 » Mon May 09, 2011 4:24 pm

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: 1401
Joined: Sun Mar 26, 2006 4:30 am
Location: Ontario, Canada
Contact:

Re: Problem 061

Post by rayfil » Mon May 09, 2011 5:15 pm

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 » Mon May 09, 2011 5:40 pm

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 9:01 am

Re: Problem 061

Post by thundre » Mon May 09, 2011 7:21 pm

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