Problem 196

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
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Problem 196

Post by daniel.is.fischer »

Jochen_P wrote:Got the same results as you have for S(100,000), S(200,010) and S(150,073) so I guess my triplet finding algorithm is ok. Well then, it must be a glitch in my (slow) prime finding solutions which hasn't shown yet for the other problems it has solved. Hard to find :sceptic:
You're using Python, aren't you? Then it's probably not integer overflow.
I have an idea what might be problematic, could verify if you PM me the code.
My code can't handle that
You mean the sum of S(1) to S(10000)? Wonder how that can be..
Easy: our programmes don't consider that many rows.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
User avatar
Jochen_P
Posts: 55
Joined: Mon Oct 05, 2009 10:47 am
Location: Stuttgart, Germany

Re: Problem 196

Post by Jochen_P »

No, it's not my Eratosthenes method of prime checking (trial division of primes up to sqrt of testee).
I found a MillerRabin algorithm on the web and tried with this instead. Got me the same wrong result in just 32 minutes :)

Daniel, PM is on the way!

edit: Daniel spotted the looney (me). Silly mistake. Danke, Daniel ;)

I tried to apply the 6k+/-1 rule to my loop from row start to row end, which worked ok for the beforementioned tests but of course not for all cases which I failed to recognize :lol:
Image
ukimiku
Posts: 13
Joined: Sun Jul 04, 2010 12:38 am

Re: Problem 196

Post by ukimiku »

Do you consider the prime 5 a part of a prime triplet? It is part of a prime quadruplet, and I wonder if sets of more than 3 primes are considered "prime triplets" as well. Thanks.
There are two kinds of people: those who divide eyerything up into two kinds, and those who don't.
http://otac0n.com/ProjectEuler/Flair/ukimiku.png
User avatar
Lord_Farin
Posts: 239
Joined: Wed Jul 01, 2009 10:43 am
Location: Netherlands

Re: Problem 196

Post by Lord_Farin »

The problem says nothing about being part of more than one prime triplet :). A prime quadruple is just two triplets that aren't disjoint.
Image
ukimiku
Posts: 13
Joined: Sun Jul 04, 2010 12:38 am

Re: Problem 196

Post by ukimiku »

Thanks.
There are two kinds of people: those who divide eyerything up into two kinds, and those who don't.
http://otac0n.com/ProjectEuler/Flair/ukimiku.png
LarryBlake
Posts: 100
Joined: Sat Aug 29, 2009 8:49 pm

Re: Problem 196

Post by LarryBlake »

Hmm. I get the right answer for all the test cases, but not the final answer. Can someone confirm if either of these is correct?

S(5678027) ends in 78.
S(7208785) ends in 09.
Image
ldesnogu
Posts: 17
Joined: Wed Jan 11, 2012 10:04 am

Re: Problem 196

Post by ldesnogu »

It took me a while to understand why I was getting this wrong, my program looked fine. What I did was to reimplement the pattern detector in a brutal way, and bingo I had missed one pattern.
Image
pcqsl
Posts: 2
Joined: Sat Feb 11, 2012 1:51 am

Re: Problem 196

Post by pcqsl »

I am trying to understand this problem.

For my understanding, 31 has neighbors: 23, 24, 25, 30, 32, 38, 39, 40. There is only one prime number, 23, in them. Why is 31 considered as an element of a triplet. Can anyone kindly point out what I missed?
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 196

Post by TripleM »

{23,29,31} is a prime triplet because 23 and 31 are adjacent to 29. Therefore 23, 29 and 31 are all part of (at least one) prime triplet.
pcqsl
Posts: 2
Joined: Sat Feb 11, 2012 1:51 am

Re: Problem 196

Post by pcqsl »

TripleM wrote:{23,29,31} is a prime triplet because 23 and 31 are adjacent to 29. Therefore 23, 29 and 31 are all part of (at least one) prime triplet.
Thanks a lot, TripleM! Now I get.
scientes
Posts: 6
Joined: Fri Sep 12, 2014 11:54 am

Re: Problem 196

Post by scientes »

S(1 000 000)=<snipped by moderator>?
User avatar
Georg
Posts: 157
Joined: Mon Jan 21, 2008 7:00 am
Location: Mannheim, Germany
Contact:

Re: Problem 196

Post by Georg »

Yes.
tchiari
Posts: 3
Joined: Sat Jan 12, 2019 6:40 pm

Re: Problem 196

Post by tchiari »

I've been working on this problem for a while now trying to confirm the test data, which says that S(10000) = 950007619. Because each number in row 10000 is around 50 million, that would lead me to believe that there are 19 primes in this row that are part of a prime triplet family. I keep coming up with the following 11 primes:
Expand
49,995,811
49,997,501
49,998, 209
49,999,441
49,999,819
50,000,921
50,000,971
50,001,197
50,003,077
50,003,201
50,004,407
I'm wondering if someone would be willing to give me a prime that is part of a triple but not on my list. That would help me to figure out if the issue is with how I'm generating/determining my primes or with how I'm looking for triples.
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 196

Post by jaap »

tchiari wrote: Sat Jan 12, 2019 6:53 pmI'm wondering if someone would be willing to give me a prime that is part of a triple but not on my list. That would help me to figure out if the issue is with how I'm generating/determining my primes or with how I'm looking for triples.
I've sent a private message.
User avatar
kenbrooker
Posts: 187
Joined: Mon Feb 19, 2018 3:05 am
Location: Northern California, USA

Re: Problem 196

Post by kenbrooker »

There are indeed 19, if that helps...

oops - Was confirming that
with the Reply box open
while jaap replied...
"Good Judgment comes from Experience;
Experience comes from Bad Judgment
..."
Image
hamsterofdeath
Posts: 20
Joined: Fri Apr 27, 2018 7:17 pm

Re: Problem 196

Post by hamsterofdeath »

tchiari wrote: Sat Jan 12, 2019 6:53 pm I've been working on this problem for a while now trying to confirm the test data, which says that S(10000) = 950007619. Because each number in row 10000 is around 50 million, that would lead me to believe that there are 19 primes in this row that are part of a prime triplet family. I keep coming up with the following 11 primes:
Expand
49,995,811
49,997,501
49,998, 209
49,999,441
49,999,819
50,000,921
50,000,971
50,001,197
50,003,077
50,003,201
50,004,407
I'm wondering if someone would be willing to give me a prime that is part of a triple but not on my list. That would help me to figure out if the issue is with how I'm generating/determining my primes or with how I'm looking for triples.
i got the exact same result. i forgot the "value itself"
PierrotLeFou
Posts: 32
Joined: Tue Jun 10, 2025 2:42 am
Location: Montreal, Canada
Contact:

Re: Problem 196

Post by PierrotLeFou »

TripleM wrote: {23,29,31} is a prime triplet because 23 and 31 are adjacent to 29. Therefore 23, 29 and 31 are all part of (at least one) prime triplet.
I would rather say that 29 and 31 are adjacent to 23.
I have the same problem. I try to figure out how to do it efficiently.
I hope that the previous and next lines are sufficients to do the job. I already have those lines.
I know that my result is still wrong, but does it make sense that it has 18 digits?
Actually, my execution time is around 500 ms on an Intel I7 4790K.
If I generate only once the list (flags) of prime numbers up to the square root of the greatest numbers with the Sieve of Eratosthene, I can extend the sieve to the appropriate range.
So, the three lines are flags saying if the corresponding number is a prime.
I'm always right ... until I'm wrong
Post Reply