problem 206

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.
User avatar
elendiastarman
Posts: 410
Joined: Sat Dec 22, 2007 8:15 pm

Problem 206

Post by elendiastarman »

Problem 206 is slightly ambiguous.
Find the unique positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0,
where each “_” is a single digit.
It didn't take me long to realize my mistake, but from the outset I assumed that all of the underscores were the same digit. Maybe it should be written this way:
Find the unique positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0,
where each “_” is a single digit, not necessarily the same.
Want some
3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170679...?
Image
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 206

Post by hk »

If your interpretation was the one that was intended then you would have to take only 10 square roots to identify the answer wouldn't it?
Well these problems were meant as really easy, but that easy?
So quite little work to abolish that idea.
Let's try and do our best not "to search for nails on low water" too much.
Image
War ruins the life and health of untold numbers of innocent children.
User avatar
elendiastarman
Posts: 410
Joined: Sat Dec 22, 2007 8:15 pm

Re: Problem 206

Post by elendiastarman »

I suppose I was a little suspicious...

Also, at the time of this writing, 206 people have solved the 206th problem!
Want some
3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170679...?
Image
thekrazykid
Posts: 3
Joined: Thu Oct 23, 2008 5:28 am

Problem 206

Post by thekrazykid »

ok so i didnt think this was that hard but i got an answer that is definately right but im told it it is wrong.. 1013091779 squared is 1026354952677384900 which is in the form 1_2_3_4_5_6_7_8_9_0.. so how is this wrong?
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: problem 206

Post by jaap »

How can an odd number squared be even?
10130917792 = 1026354952677384841
thekrazykid
Posts: 3
Joined: Thu Oct 23, 2008 5:28 am

Re: problem 206

Post by thekrazykid »

hmm good point.. this doesnt make sence ive been playing around with my code and it gives me more than 1 square for the same number.. i thought this was just my code but google calculator does it too.. http://www.google.com/search?hl=en&q=10 ... h&aq=f&oq=http://www.google.com/search?hl=en&q=10 ... h&aq=f&oq=http://www.google.com/search?hl=en&q=10 ... h&aq=f&oq=
http://www.google.com/search?hl=en&q=10 ... h&aq=f&oq=
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: problem 206

Post by jaap »

thekrazykid wrote:hmm good point.. this doesnt make sence ive been playing around with my code and it gives me more than 1 square for the same number.. i thought this was just my code but google calculator does it too..
It seems to gives more than one square root because it is getting rounded after nine or ten digits.
For example 1/3.

There is a limit on the value that a variable in a computer program can have. Most types use a fixed number of bytes of memory, so they don't hold necessarily hold as many digits as you might need.
thekrazykid
Posts: 3
Joined: Thu Oct 23, 2008 5:28 am

Re: problem 206

Post by thekrazykid »

yea that was the problem.. i think google does it too because its coded it python and thats what im using.. im running it right now using a decimal module that will run it out farther
MaJJ
Posts: 49
Joined: Tue Oct 14, 2008 12:14 am

Problem 206

Post by MaJJ »

Hello,
I'm having a problem again :lol:
I have been solving #206 - and here's what I thought:

1_2_3_4_5_6_7_8_9_0 means that
- min = 1020304050607080900 (replacing _ with 0)
- max = 1929394959697989990 (replacing _ with 9)

And since both number and its square must be integers, let's calculate low = floor(sqrt(min)) and high = ceil(sqrt(max)).

Now I know that the answer lies somewhere between low and high.
So all I have to do is just square all integers in that range and eventually some of them will have the required form.

And my result - there isn't any! I went through all 378 925 614 ( :lol: ) of them and none of them has form 1_2_3_4_5_6_7_8_9_0 .
Where did I make a mistake?
Image
Image
User avatar
Tommy137
Posts: 238
Joined: Sun Feb 24, 2008 6:02 pm
Location: Cologne, Germany
Contact:

Re: Problem 206

Post by Tommy137 »

Overflow bug?
Image
MaJJ
Posts: 49
Joined: Tue Oct 14, 2008 12:14 am

Re: Problem 206

Post by MaJJ »

I don't think so - I'm using Python, so this shouldn't happen. I'll try to check it though. Thanks :)
Image
Image
Ted
Posts: 23
Joined: Sun Apr 02, 2006 10:46 pm

Re: Problem 206

Post by Ted »

Maybe test with squares not square roots, as the latter may not resolve exactly to integers in some instances.
MaJJ
Posts: 49
Joined: Tue Oct 14, 2008 12:14 am

Re: Problem 206

Post by MaJJ »

Hmm. But while working with square roots, I have to test only ~3.8 * 10^8 of them.
Once I'll start testing squares, I have to test ~ 10 times more numbers (if bruteforcing it in the way:

1020304050607080900
1020304050607080910
...
1020304050607080990
1020304050607081900
1020304050607081910
...

- adding 10 and when it jumps to another digit place, fixing it)
Ted wrote:... as the latter may not resolve exactly to integers in some instances.
I don't get it. If answer to this problem has to be integer and integer^2 = another integer, my test with square roots should be correct. Or am I missing something?

EDIT: after this topic moved to another forum, I have read thekrazykid's issue - maybe there really is a overflow bug. But that's weird, Python lets me compute factorial of 10 000 and makes "simple" power function go wrong? I'm gonna try this "decimal" module ...
Image
Image
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: problem 206

Post by daniel.is.fischer »

I would be very surprised if python got a simple power function wrong. If you don't find out yourself what went wrong, I'd be willing to take a look at your code.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
sdkudrgn88
Posts: 4
Joined: Sat Feb 28, 2009 11:42 pm

Re: problem 206

Post by sdkudrgn88 »

I got the right answer (at least I believe, it's verifiable with Windows Calculator), but Project Euler's site doesn't accept it as correct.

As it's not the "right" answer anyway, I don't think I'm doing any harm by posting it here:

The number is [...] (Alright, I think I know what I should do now. Thanks anyway.)

Am I doing something wrong, or is the number that "euler" found not unique...?
Last edited by sdkudrgn88 on Sun Mar 01, 2009 12:38 am, edited 1 time in total.
JohnMorris
Posts: 64
Joined: Sun Dec 23, 2007 6:38 am

Problem 206

Post by JohnMorris »

sdkudrgn88 wrote:I got the right answer (at least I believe, it's verifiable with Windows Calculator), but Project Euler's site doesn't accept it as correct.

As it's not the "right" answer anyway, I don't think I'm doing any harm by posting it here:

[...]

Am I doing something wrong, or is the number that "euler" found not unique...?
I'm not a Project Euler team member, but I'm guessing they would ask you to edit your mail to remove the numbers, unless they get there first. It would probably be appreciated if you did it.

Guessing: did you enter the square (1_2_3...) as your answer? The question asks for the number, not the square.
Image
sdkudrgn88
Posts: 4
Joined: Sat Feb 28, 2009 11:42 pm

Re: problem 206

Post by sdkudrgn88 »

Thumbo wrote:I'm not a Project Euler team member, but I'm guessing they would ask you to edit your mail to remove the numbers, unless they get there first. It would probably be appreciated if you did it.

Guessing: did you enter the square (1_2_3...) as your answer? The question asks for the number, not the square.
As a matter of fact, that's exactly what I did. T_T...
mdean
Posts: 206
Joined: Tue Aug 02, 2011 2:05 am

Re: problem 206

Post by mdean »

Just got this one done. This one I cut a tad close. 47.33 seconds.
Image
quant42
Posts: 1
Joined: Wed Mar 05, 2014 9:17 pm

Re: Problem 206

Post by quant42 »

Because my algorithm to slove this problem don't return any answer - I want to know if I understand the problem correctly. We are searching x, such that the decimal representation of x * x matches the following regular expression: "1\d2\d3\d4\d5\d6\d7\d8\d9\d0"? (width \d short for [0-9])
User avatar
Marcus_Andrews
Administrator
Posts: 1637
Joined: Wed Nov 09, 2011 5:23 pm

Re: problem 206

Post by Marcus_Andrews »

quant42: That's correct.
Post Reply