Enumerating all 3-tuples (Posting On Python-List Prohibited)

Ben Bacarisse ben.usenet at bsb.me.uk
Sat Mar 10 20:40:01 EST 2018


Lawrence D’Oliveiro <lawrencedo99 at gmail.com> writes:

> On Sunday, March 11, 2018 at 3:24:05 AM UTC+13, Ben Bacarisse wrote:
>> Unfortunately my Python is not up to using iterators well enough to
>> avoid a "maximum recursion depth exceeded" error.
>
> My solution only needed recursion up to a depth equal to the length of
> the tuples. The ordering is done based on the maximum value of any
> element of the tuple.

I'm sure deep recursion is not needed, it's just tricky translating from
a lazy language when one is not familiar with all the iterator
facilities in Python.  For example, I couldn't find an append operation
that returns an iterable.

It would be nice to avoid relying on any value-based ordering.  There is
inevitably an order that comes from the iterable whose elements are
being paired, trippled or whatever, but that's all that's really
required for a solution.

-- 
Ben.



More information about the Python-list mailing list