Enumerating all 3-tuples

Ben Bacarisse ben.usenet at bsb.me.uk
Sat Mar 10 13:38:27 EST 2018


Sorry for following up to myself again...

Ben Bacarisse <ben.usenet at bsb.me.uk> writes:
<snip>
>> ...  But I think that is an easier way (no code yet though!) unless
>> you are set on one particular enumeration: consider the triple as a pair
>> one element of which runs over the enumeration of pairs you already
>> have.
<snip>

This algorithm has the disadvantage that the sequence is not any of the
usual "zig-zag" patterns.  Using numbers, for example the sums of the
triples are not monotonic:

*Main> take 30 $ map sum (pn 2 [1..])
[3,4,4,5,5,4,6,6,5,5,7,7,6,6,5,8,8,7,7,6,5,9,9,8,8,7,6,6,10,10]

That probably makes it a non-starter for you.

-- 
Ben.



More information about the Python-list mailing list