Hi all
Many of us have fun creating solutions, imagining algorithms to solve difficult problems. Sometimes that's why we answer a question, because we think we'll have fun figuring out the solution.
I thought it would be a good idea if we posted, here in the lounge, complex problems to help us improve our knowledge in excel.
The idea is not to write a solution efficient, easy to read and to maintain. We do that in the excel forum. Here I thought we would try to push the formula/code capabilities to the limit. I'm talking about compact, ugly looking formulas, recursive algorithms, etc.
We will get solutions that we would not use in our work, but I believe it will help us to explore further the possibilities of the tools. Also the important is not the definitive solution, but the different ways to tackle the problems.
The problems should be complex enough to make even an experienced user feel some difficulty to solve them.
I will post the first one. It requires some background in mathematics.
Tough Problem 1
Background:
As we all know, the prime numbers have a very irregular distribution. Sometimes we find pairs of primes that are only 2 units apart, like (17,19) or (2549,2551). They are called Twin Primes. Their distribution is also very erratic, you find 2 pairs between 820 and 830 (821,823) and (827,829) but not even one pair between 900 and 1000!
Problem:
How many pairs of Twin Primes are there between 5 and N, with N<=10000?
Ex.:
For N=20 we have
(3,5),(5,7),(11,13),(17,19) - 4 pairs
For N=100 we add the pairs
(29,31),(41,43),(59,61),(71,73) - total of 8 pairs
The solution must work in excel versions before 2007 (to avoid formulas with 25 nested parentheses).
Criteria for ranking of the solutions:
1 - less formulas is better
2 - cleverer, simpler solution is better
To the mvp's and experienced users: If you find this simple or already know a solution, please don't post it in the next hours to allow everyone to have some fun trying to figure it out.
Here is a link where you have the first 35 twin primes pairs:
http://en.wikipedia.org/wiki/Twin_prime
Don't forget, the idea is to have fun!!!
-----
P. S.
Do you think this makes sense?
Remark:
It may also happen that none of this makes sense and it's all the product of a disturbed mind.
Many of us have fun creating solutions, imagining algorithms to solve difficult problems. Sometimes that's why we answer a question, because we think we'll have fun figuring out the solution.
I thought it would be a good idea if we posted, here in the lounge, complex problems to help us improve our knowledge in excel.
The idea is not to write a solution efficient, easy to read and to maintain. We do that in the excel forum. Here I thought we would try to push the formula/code capabilities to the limit. I'm talking about compact, ugly looking formulas, recursive algorithms, etc.
We will get solutions that we would not use in our work, but I believe it will help us to explore further the possibilities of the tools. Also the important is not the definitive solution, but the different ways to tackle the problems.
The problems should be complex enough to make even an experienced user feel some difficulty to solve them.
I will post the first one. It requires some background in mathematics.
Tough Problem 1
Background:
As we all know, the prime numbers have a very irregular distribution. Sometimes we find pairs of primes that are only 2 units apart, like (17,19) or (2549,2551). They are called Twin Primes. Their distribution is also very erratic, you find 2 pairs between 820 and 830 (821,823) and (827,829) but not even one pair between 900 and 1000!
Problem:
How many pairs of Twin Primes are there between 5 and N, with N<=10000?
Ex.:
For N=20 we have
(3,5),(5,7),(11,13),(17,19) - 4 pairs
For N=100 we add the pairs
(29,31),(41,43),(59,61),(71,73) - total of 8 pairs
The solution must work in excel versions before 2007 (to avoid formulas with 25 nested parentheses).
Criteria for ranking of the solutions:
1 - less formulas is better
2 - cleverer, simpler solution is better
To the mvp's and experienced users: If you find this simple or already know a solution, please don't post it in the next hours to allow everyone to have some fun trying to figure it out.
Here is a link where you have the first 35 twin primes pairs:
http://en.wikipedia.org/wiki/Twin_prime
Don't forget, the idea is to have fun!!!
-----
P. S.
Do you think this makes sense?
Remark:
It may also happen that none of this makes sense and it's all the product of a disturbed mind.
Last edited: