Problem 145

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.
Post Reply
Ran
Posts: 3
Joined: Mon Apr 13, 2009 1:06 am

Problem 145

Post by Ran »

Problem 145 (View Problem)
"There are 120 reversible numbers below one-thousand."
Is this _really_ true? I've tried different solutions, but everytime I end up with 125 :(
I even printed them all to a file, and sure, there are 125 numbers n in which all digits of n+reverse(n) is odd. Starting at 10+1=11 and ending with 948+849=1797.
genious999
Posts: 53
Joined: Mon Oct 20, 2008 10:48 pm

Re: Problem 145

Post by genious999 »

The reverse of '10' is '01' which a leading zero, and leading zeroes are not allowed. I would imagine the other 'extra' reverisble numbers you found also fall into that category, so check and see.
Ran
Posts: 3
Joined: Mon Apr 13, 2009 1:06 am

Re: Problem 145

Post by Ran »

genious999 wrote:The reverse of '10' is '01' which a leading zero, and leading zeroes are not allowed. I would imagine the other 'extra' reverisble numbers you found also fall into that category, so check and see.
So, if reverse(n) has a leading zero, n can't be a reversible number?
genious999
Posts: 53
Joined: Mon Oct 20, 2008 10:48 pm

Re: Problem 145

Post by genious999 »

No. It explicitly states in the text for the problem "Leading zeroes are not allowed in either n or reverse(n)."
Ran
Posts: 3
Joined: Mon Apr 13, 2009 1:06 am

Re: Problem 145

Post by Ran »

Hm, I thought something weird about "don't count the leading zeros", which I thought was weird since you usually don't add them...

Surely that could be misunderstood.

Thank you.
User avatar
franceq
Posts: 8
Joined: Thu Dec 23, 2010 11:56 pm
Location: Czech Republic
Contact:

Re: Problem 145

Post by franceq »

must the sums be distincts...?? becouse I saw 9999999 mabe 100 times....:DDD
Image
User avatar
rayfil
Administrator
Posts: 1412
Joined: Sun Mar 26, 2006 5:30 am
Location: Quebec, Canada
Contact:

Re: Problem 145

Post by rayfil »

Nothing in the problem description specifies that sums must be distinct.
When you assume something, you risk being wrong half the time.
User avatar
franceq
Posts: 8
Joined: Thu Dec 23, 2010 11:56 pm
Location: Czech Republic
Contact:

Re: Problem 145

Post by franceq »

Oukej thats very good .-)
Image
xe3tec
Posts: 46
Joined: Thu May 05, 2011 8:52 am
Location: Vienna
Contact:

Re: Problem 145

Post by xe3tec »

that problem made my lifespan sink by factor 2 x_x
unbelievable...
RichardBuckalew
Posts: 1
Joined: Sat Sep 10, 2011 1:54 am

Re: Problem 145

Post by RichardBuckalew »

The problem description is indeed confusing. I assumed that 'leading zeros are not allowed' meant 'remove leading zeros before performing the addition'

For the sake of others who come after us, please fix this!
User avatar
Lord_Farin
Posts: 239
Joined: Wed Jul 01, 2009 10:43 am
Location: Netherlands

Re: Problem 145

Post by Lord_Farin »

RichardBuckalew wrote:'remove leading zeros before performing the addition'
Could you explain what difference this could possibly make? Last time I checked, I could calculate 120+21=141=120+021.
Image
drwhat
Posts: 45
Joined: Tue Sep 06, 2011 4:56 am

Re: Problem 145

Post by drwhat »

While taking the quote: "Leading zeroes are not allowed in either n or reverse(n)." to mean that you should strip of leading zeroes does result in tautology in the original problem, there is nothing to say the writer of the problem didn't include one. At first reading I also assumed that is what the line meant, rather than "Any n, or reverse(n) containing leading zeroes should be excluded from the answer." Which I think much more clearly expresses the intent of the line.

Tony
JMW1994
Posts: 43
Joined: Sat Apr 09, 2011 11:35 pm

Re: Problem 145

Post by JMW1994 »

I've written my program but should it take days to get to the answer?
Absolutely not! Each problem has been designed according to a "one-minute rule", which means that although it may take several hours to design a successful algorithm with more difficult problems, an efficient implementation will allow a solution to be obtained on a modestly powered computer in less than one minute.
I got an algorithm to correctly solve the example and possibly the actual problem itself, but is there a clever method to solve this one in about a minute? Project Euler's about clearly says that all answers can be approached within one minute.

I already wrote the functions in a header file(I use C) that deal with storing and reversing numbers, rotating numbers, and checking whether the digits is odd and even, so that I don't have to rewrite the functions required to solve the problems over again.
Image
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 145

Post by jaap »

JMW1994 wrote:I got an algorithm to correctly solve the example and possibly the actual problem itself, but is there a clever method to solve this one in about a minute?
My program takes less than a millisecond.
Fogmeister
Posts: 27
Joined: Mon Aug 22, 2011 11:20 am

Re: Problem 145

Post by Fogmeister »

LOL, I'm stuck in the same place as JMW.

I have an algorithm that gives the correct answer for the example in 24ms (using a very sow language).

However, if I have calculated the O of the algorithm correctly it will take about an hour and a half to solve for upto 999999999.

Oh well...

:P
Image
jamel12
Posts: 1
Joined: Sat Nov 06, 2010 8:59 am

Re: Problem 145

Post by jamel12 »

Hi everybody,

Can someone confirm me that below 100 there is 36 reversible numbers and under 300 there is 99 numbers

Thank you
thundre
Posts: 356
Joined: Sun Mar 27, 2011 10:01 am

Re: Problem 145

Post by thundre »

No, Jamel, those counts are too high. You must be counting some that don't meet the problem's requirements.
Image
Shroots
Posts: 1
Joined: Fri Apr 11, 2008 2:21 pm

Re: Problem 145

Post by Shroots »

The problem says that leading zeros are not allowed but I don't think that it's clear how to treat numbers ending in zeros. Should they be completely discarded since reverse(n) would contain leading zeros? Or should the leading zeros in reverse(n) be trimmed? And if so then which digits would correspond to eachother in n and reverse(n)?
User avatar
TheEvil
Posts: 84
Joined: Sun Nov 13, 2011 10:38 am
Location: Szeged, Hungary

Re: Problem 145

Post by TheEvil »

Shroots wrote:The problem says that leading zeros are not allowed but I don't think that it's clear how to treat numbers ending in zeros. Should they be completely discarded since reverse(n) would contain leading zeros? Or should the leading zeros in reverse(n) be trimmed? And if so then which digits would correspond to eachother in n and reverse(n)?
From the description of the problem: "Leading zeroes are not allowed in either n or reverse(n).". So neither n nor reverse(n) can end with zero.
Image
Post Reply