Problem 013

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.
kuro11
Posts: 7
Joined: Wed Jan 21, 2009 9:29 pm

Re: Problem 013

Post by kuro11 »

rayfil wrote:
As for as the first two summed:
083484225211392112511446123117807668296927154000788
What is your interpretation of that single leading "0" in the sum of the first two numbers???
So you think I would include a leading zero? Honestly?


I would also like to note that I have solved Problem 16 (correctly) using the same String-based math functions I made.
User avatar
rayfil
Administrator
Posts: 1412
Joined: Sun Mar 26, 2006 5:30 am
Location: Quebec, Canada
Contact:

Re: Problem 013

Post by rayfil »

So you think I would include a leading zero? Honestly?
Believe me, that never even crossed my mind. Read my signature. Your assumption was absolutely WRONG, and taking such risks may alienate people who may be willing to help you.

I was only trying to help by asking a simple question, which you refused to answer. I will not make any attempt to assume the reason of your refusal; I would most probalby be wrong.
When you assume something, you risk being wrong half the time.
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 013

Post by hk »

There is only one interpretation possible:
Sum the following 100 numbers and give the ten most significant digits of the result.
If your program outputs a wrong result generate a smaller example and try to find out what the problem is(e.g. 10 9-digit numbers and compare the result with what you get using ordinary means).
We're not here to debug your program. That belongs to your ability to solve the problem.

(BTW the array length should be 100.)
Image
War ruins the life and health of untold numbers of innocent children.
User avatar
stijn263
Posts: 1505
Joined: Sat Sep 15, 2007 11:57 pm
Location: Netherlands

Re: Problem 013

Post by stijn263 »

Just copy the values to excel and add 'm up. (you might need to use text to columns)
kuro11
Posts: 7
Joined: Wed Jan 21, 2009 9:29 pm

Re: Problem 013

Post by kuro11 »

hk wrote:There is only one interpretation possible:
Sum the following 100 numbers and give the ten most significant digits of the result.
If your program outputs a wrong result generate a smaller example and try to find out what the problem is(e.g. 10 9-digit numbers and compare the result with what you get using ordinary means).
We're not here to debug your program. That belongs to your ability to solve the problem.

(BTW the array length should be 100.)
The array length is 100 because the first entry starts at 0 and ends at 99. If you try and input array[100] in an array that was initialized with int array[] = new int[100]; then then it would error. (I realize that you most probably realize this.


I just tested my method with this array:

Code: Select all

String[] numbers = {
                            "123456789",
                            "312414321",
                            "125325234",
                            "321543232",
                            "124532234",
                            "123532423",
                            "124125134",
                            "124514232",
                            "321412323",
                            "314123231",
                            "343241232"
                            };
I summed this on my calculator, I got 2358220385 three times
I also summed the array by parsing all of those as double values, I got 2.358220385E9
My String summing method gives me 2358220385
stijn263 wrote:Just copy the values to excel and add 'm up. (you might need to use text to columns)
While a good Idea, I don't want to just get the answer. But currently I fear I am making an assumption and I have no idea where it is.
rayfil wrote:
So you think I would include a leading zero? Honestly?
Believe me, that never even crossed my mind. Read my signature. Your assumption was absolutely WRONG, and taking such risks may alienate people who may be willing to help you.

I was only trying to help by asking a simple question, which you refused to answer. I will not make any attempt to assume the reason of your refusal; I would most probalby be wrong.
My objective wasn't to alienate you, but I am prone to taking things personally (the faceless nature of the internet doesn't help that fact), so I am sorry for snapping back at you.

But as for my interpretation of the leading zero, I would not enter a leading zero into the answer, and it is the result of my method. I fixed that problem but I still get the same answer numerically speaking. That zero, if it is a zero, is added only after it finishes everything else (Leading zeros won't show up any more).
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Problem 013

Post by daniel.is.fischer »

kuro11 wrote:
hk wrote:There is only one interpretation possible:
Sum the following 100 numbers and give the ten most significant digits of the result.
If your program outputs a wrong result generate a smaller example and try to find out what the problem is(e.g. 10 9-digit numbers and compare the result with what you get using ordinary means).
We're not here to debug your program. That belongs to your ability to solve the problem.

(BTW the array length should be 100.)
The array length is 100 because the first entry starts at 0 and ends at 99. If you try and input array[100] in an array that was initialized with int array[] = new int[100]; then then it would error. (I realize that you most probably realize this.
But above you said your programme told you the array's length was 99. And in the code you posted, it was. To cut a long story short, that was your problem, while copying and pasting the numbers into your code, you dropped one.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
kuro11
Posts: 7
Joined: Wed Jan 21, 2009 9:29 pm

Re: Problem 013

Post by kuro11 »

Oh duh *slaps head*, thanks.
Lizho
Posts: 2
Joined: Sun Mar 22, 2009 8:06 am
Location: People's Republic of China, Sichuan Province, Chengdu, Chengdu University of Technology.

Re: Problem 013

Post by Lizho »

hey, don't you think the last 10 digits of a 50-digit number equals a 10-digit number?
if so, what is the difficulty of this problem, then?
:shock:
PRC!
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 013

Post by hk »

Reading the problem well, obviously: it asks for the first ten digits of the sum.
Not for the last.
Image
War ruins the life and health of untold numbers of innocent children.
Nailuree
Posts: 1
Joined: Fri May 08, 2009 2:28 pm

Re: Problem 013

Post by Nailuree »

Hi,

I would like to know how they want us to write the answer. For instance if "azertyuiopa" are the first ten digits of the sum. Do they want us to write "azertyuiop" or "a.z.e.r.t.y.u.i.o.p"? or "a,z,e,r,t,y,u,i,o,p" or something else? My solution must be wrong but I prefere being sure.

Thanks

Finally I made a mistake in my programm, there is no problem any more.
User avatar
Tommy137
Posts: 238
Joined: Sun Feb 24, 2008 6:02 pm
Location: Cologne, Germany
Contact:

Re: Problem 013

Post by Tommy137 »

Nailuree wrote:Hi,

I would like to know how they want us to write the answer. For instance if "azertyuiopa" are the first ten digits of the sum. Do they want us to write "azertyuiop" or "a.z.e.r.t.y.u.i.o.p"? or "a,z,e,r,t,y,u,i,o,p" or something else? My solution must be wrong but I prefere being sure.

Thanks

Finally I made a mistake in my programm, there is no problem any more.

"azertyuiop" please :)
Image
magezy
Posts: 1
Joined: Mon Aug 31, 2009 1:57 pm

Problem 13

Post by magezy »

Hi I have only started a few weeks and have solved 15 problems , I have designed an algorithm for number 13 and it seems to be working fine and giving me an answer, the answer is apparently wrong and I cant see anything wrong with the program, can I post the code on here for a second pair of eyes or would I have to email it?

Its the question to add 50 one hundred digit numbers and give the first ten digits of the sum. I am assuming its the lowest value first 10 digits units tens hundreds etc or could I be wrong and it be the first ten with the largest numerical values reading from left to right??

Thanks for reading and if you want my code (c#) let me know?
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 13

Post by hk »

Please don't enter any code here.
Actually
The first 5 digits of the number 12345678901234567 are: 12345.
Image
War ruins the life and health of untold numbers of innocent children.
User avatar
Sepehrmousavi
Posts: 1
Joined: Thu Jul 08, 2010 5:21 pm
Location: Tehran, Iran
Contact:

Re: Problem 013

Post by Sepehrmousavi »

I calculated the whole sum not with any codes or programs but just with using windows calculator. Just a hint for those who're trying to solve this problem via program : There are 100 50-digit numbers that are going to be summed and the interesting part is that the sum is just 52 digits :lol: Using arbitrary-precision arithmetic may also help you!
Image
Mozza314
Posts: 3
Joined: Sun Feb 06, 2011 12:50 am

Skeptical that my answer is incorrect

Post by Mozza314 »

I'm fairly confident my answer for http://projecteuler.net/index.php?secti ... lems&id=13, but the website is saying it's wrong. I'm fairly confident because I've checked it against an arbitrary precision expression evaluator I have.

I believe posting my answer here would be against the rules, so I was hoping someone who has completed the problem could verify that my answer is incorrect.

Actually I'm in the same situation for problem 10, for that one I've worked out the answer 4 different ways and gotten the same one each time.
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Skeptical that my answer is incorrect

Post by TripleM »

When over forty-four thousand people have solved the problem before you, I can say with 100% certainty that your answer is wrong already :) But you can PM me if you like.
Mozza314
Posts: 3
Joined: Sun Feb 06, 2011 12:50 am

Re: Skeptical that my answer is incorrect

Post by Mozza314 »

I admit it seems more likely I just can't see where I've gone wrong, however if there's some sort of bug/corruption in the system that validates answers it could be telling me the wrong thing no matter how many people's answers it correctly verified.

PM sent.
User avatar
euler
Administrator
Posts: 5095
Joined: Sun Mar 05, 2006 4:49 pm
Location: Cheshire, England
Contact:

Re: Skeptical that my answer is incorrect

Post by euler »

I hope I'm not stating the obvious, but when it says, "Work out the first ten digits," make sure you're not providing the last ten digits. With problem 10, make sure you're including 2 among the primes and you are not including 1; does you program give 17 as the answer for the sum of primes below 10?
Image
impudens simia et macrologus profundus fabulae
Mozza314
Posts: 3
Joined: Sun Feb 06, 2011 12:50 am

Re: Skeptical that my answer is incorrect

Post by Mozza314 »

I worked it out a couple of days ago. For the 50 digit summation one, I was giving the full answer not just the first 10 digits. The bizarre thing about the primes one was that I was using very different methods, including downloading the primes I needed, and getting the same answer! As it turns out, the reason I got the wrong answer multiple times was because each time I was adding all the values in a 32 bit integer, so the overflow occurred in the same way each time.
davidFashion
Posts: 14
Joined: Fri Mar 04, 2011 10:53 pm

Re: Skeptical that my answer is incorrect

Post by davidFashion »

Mozza314 wrote:I worked it out a couple of days ago. For the 50 digit summation one, I was giving the full answer not just the first 10 digits. The bizarre thing about the primes one was that I was using very different methods, including downloading the primes I needed, and getting the same answer! As it turns out, the reason I got the wrong answer multiple times was because each time I was adding all the values in a 32 bit integer, so the overflow occurred in the same way each time.
Project Euler has been quite a learning experience. Not only have I learned a great deal about algorithms and mathematics, but I have also learned new details about the Java programming language.

In many problems, a solver needs to understand the overflow characteristics of certain data types within their particular language. In particular, I changed the data type used in the computation of a problem and out came the correct answer. In some problems, changing integer variables from 32-bit integers to 64-bit integers resulted in the correct answer. In other problems, a more complex data type change was necessary.
Post Reply