cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

How to Extract Non-overlap Triplets

lvl107
20-Turquoise

How to Extract Non-overlap Triplets

Hello, Everyone.

Extract_Non_Overlap_Triplet+.PNG

( or Refer : http://communities.ptc.com/message/154874#154874 )

Thanks in advance for your time and help.

Best Regards.

ACCEPTED SOLUTION

Accepted Solutions
StuartBruff
23-Emerald III
(To:Werner_E)

Neat. I was bored at lunchtime, so I thought I'd generalize things a little bit generate arbitrary k-tuples (defined by the required difference between the first member of the k-tuple and the other members).

Stuart

View solution in original post

5 REPLIES 5
Werner_E
25-Diamond I
(To:lvl107)

Use the output of PrimeTriplet as input. Run from the second to the last but one element and remove every triple where one of its numbers are included in the next triple. A function overlap(triple1, triple2) may be useful in doing so.

Alternative approach: lookup the prime before the first and the prime after the last element of your triple. If the difference of any of them to the center element of the triple is 6, discard it.

StuartBruff
23-Emerald III
(To:Werner_E)

As the triplet selection algorithm already sorts the triplets in ascending order, it should be sufficient to just ensure that:

the first number in a triplet is greater then the last in the previous triplet

and

the last number in a triplet is less than the first number in the succeding triplet

Stuart

Werner_E
25-Diamond I
(To:StuartBruff)

Oh, yes! That sure was too obvious and too easy for me too see

In the attached sheet I nevertheless had to resort to my alternative approach as I don't use the precalculated triples.

P1.png

The routines are written so that the argument is either a scalar (highes prime number involved) or, as in Liu's routine, a vector of primes.

So if you want to collect all routines in one programm as in the original sheet, you would calculate the prime list only once.

P2.png

StuartBruff
23-Emerald III
(To:Werner_E)

Neat. I was bored at lunchtime, so I thought I'd generalize things a little bit generate arbitrary k-tuples (defined by the required difference between the first member of the k-tuple and the other members).

Stuart

Werner_E
25-Diamond I
(To:StuartBruff)

Great work.

What shall I say - welcome back!

Your primes2() is twice as fast as the routine listPrimes() in my sheet and uses up less ressources - great!

Announcements

Top Tags