Problem 006
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.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
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
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.
-
ABC_TheCMan
- Posts: 1
- Joined: Sun Jul 26, 2009 8:58 pm
Problem 006
Hi,
the problems ask for
Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
But is should be:
Find the difference between the square of the sum of the first one hundred natural numbers and the sum of the squares?
Did anybody hit the same problem?
ABC_TheCMan
the problems ask for
Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
But is should be:
Find the difference between the square of the sum of the first one hundred natural numbers and the sum of the squares?
Did anybody hit the same problem?
ABC_TheCMan
- daniel.is.fischer
- Posts: 2400
- Joined: Sun Sep 02, 2007 11:15 pm
- Location: Bremen, Germany
Re: Problem 6 - Wrong question?
Fortunately, the example makes it clear that the desired answer is the absolute difference.
But yes, that irritated me, too.
But yes, that irritated me, too.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
-
userProjectEuler
- Posts: 7
- Joined: Sat Jul 25, 2009 8:52 pm
Problem 006 error
the problem is asking:
the problem should be reformulated to:
Find the difference between the square of the sum of the first one hundred natural numbers and the sum of the squares.
right?!!
which results in a negative value.Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
the problem should be reformulated to:
Find the difference between the square of the sum of the first one hundred natural numbers and the sum of the squares.
right?!!
-
genious999
- Posts: 53
- Joined: Mon Oct 20, 2008 10:48 pm
-
userProjectEuler
- Posts: 7
- Joined: Sat Jul 25, 2009 8:52 pm
-
quilan
- Posts: 182
- Joined: Fri Aug 03, 2007 11:08 pm
Re: Problem 6 error
result = abs( SquareOfSum(100) - SumOfSquares(100) )userProjectEuler wrote:the problem is asking:
which results in a negative value.Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
the problem should be reformulated to:
Find the difference between the square of the sum of the first one hundred natural numbers and the sum of the squares.
right?!!
If there was any ambiguity, the example should be enough to show that the answer should be positive.
ex ~100%'er... until the gf came along.


-
userProjectEuler
- Posts: 7
- Joined: Sat Jul 25, 2009 8:52 pm
Re: Problem 6 error
there's no ambiguity. the problem is asking a different thing. there's nothing mentioning that the result must be unsigned. but that is ok.quilan wrote:result = abs( SquareOfSum(100) - SumOfSquares(100) )userProjectEuler wrote:the problem is asking:
which results in a negative value.Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
the problem should be reformulated to:
Find the difference between the square of the sum of the first one hundred natural numbers and the sum of the squares.
right?!!
If there was any ambiguity, the example should be enough to show that the answer should be positive.
-
drsparky
- Posts: 8
- Joined: Fri Aug 14, 2009 12:47 pm
Problem 006 solution in O(1)
I deleted my solution... apparently this is not the correct place. The forum in the puzzle is locked. That is so unfortunate. I was rather happy with my O(1) solution... 
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 6 solution in O(1)
The second and fourth post in the forum are O(1) too.
Please read the forum first.
Please read the forum first.

War ruins the life and health of untold numbers of innocent children.
-
drsparky
- Posts: 8
- Joined: Fri Aug 14, 2009 12:47 pm
- daniel.is.fischer
- Posts: 2400
- Joined: Sun Sep 02, 2007 11:15 pm
- Location: Bremen, Germany
Re: Problem 6 solution in O(1)
I doubt your solution will be fundamentally different from all posted variations of the sum formulae, but to check, could you please PM me your solution?
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
-
zwuupeape
- Posts: 189
- Joined: Tue Jun 09, 2009 6:11 pm
Re: Problem 6 solution in O(1)
You can solve every problem in O(1).
Let x be the solution to problem y. In pseudocode:
### O(1) algorithm to solve problem y:
### t <- x
### output t
Let x be the solution to problem y. In pseudocode:
### O(1) algorithm to solve problem y:
### t <- x
### output t
- stijn263
- Posts: 1505
- Joined: Sat Sep 15, 2007 11:57 pm
- Location: Netherlands
-
zwuupeape
- Posts: 189
- Joined: Tue Jun 09, 2009 6:11 pm
Re: Problem 6 solution in O(1)
...what? How so? This program is O(1) by definition since its execution time is independent of input (it has no input) and it obviously halts.
- daniel.is.fischer
- Posts: 2400
- Joined: Sun Sep 02, 2007 11:15 pm
- Location: Bremen, Germany
Re: Problem 6 solution in O(1)
How long does it take to output x (hint: if x is an integer, it has O(log |x|) digits
)
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
-
zwuupeape
- Posts: 189
- Joined: Tue Jun 09, 2009 6:11 pm
Re: Problem 6 solution in O(1)
x is a constant, therefore log|x| is a constant...daniel.is.fischer wrote:How long does it take to output x (hint: if x is an integer, it has O(log |x|) digits)
- elendiastarman
- Posts: 410
- Joined: Sat Dec 22, 2007 8:15 pm
Re: Problem 6 solution in O(1)
But not <=1 unless x only has one digit...
Want some
3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170679...?

3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170679...?

-
zwuupeape
- Posts: 189
- Joined: Tue Jun 09, 2009 6:11 pm
- elendiastarman
- Posts: 410
- Joined: Sat Dec 22, 2007 8:15 pm
Re: Problem 6 solution in O(1)
I think his point is that it will take longer to output a 100 digit answer rather than a 2 digit answer.
Want some
3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170679...?

3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170679...?

-
zwuupeape
- Posts: 189
- Joined: Tue Jun 09, 2009 6:11 pm
Re: Problem 6 solution in O(1)
It's true that it will take longer, but it will also take longer if you have a slower computer... Running time is measured relative to input. The running time of this algorithm is indeed O(|logx|) but O(|logx|) = O(1). Actually I don't even understand what's O(logx) supposed to mean. O(logn) means that the running time of the algorithm takes twice as long to halt if the input is raised to the power of 2. if 12 is the solution and it has 2 digits then what is O(2) supposed to mean?