[perl-python] generate all possible pairings

From: Xah Lee (xah_at_xahlee.org)
Date: 02/27/05

  • Next message: Mike Meyer: "Re: [perl-python] generate all possible pairings"
    Date: 26 Feb 2005 17:26:31 -0800
    
    

    20050226 exercise: generate all possible pairings

    given a list that is a set partitioned into subsets, generate a list
    of all possible pairings of elements in any two subset.

    Example:

     genpair( [[9,1],[5],[2,8,7]] );

    returns:

     [[5,8],[9,5],[1,5],[9,2],[9,7],[1,8],[1,7],[5,2],[1,2],[9,8],[5,7]]

    (we do not assume the given set has order, so the result is not
    ordered.)

    Perl code and Python code will be posted in 2 days.

    This is brought to you by the perl-python community. To subscribe, see
    http://xahlee.org/perl-python/python.html

     Xah
     xah@xahlee.org
     http://xahlee.org/PageTwo_dir/more.html


  • Next message: Mike Meyer: "Re: [perl-python] generate all possible pairings"

    Relevant Pages

    • [perl-python] generate all possible pairings
      ... 20050226 exercise: generate all possible pairings ... of all possible pairings of elements in any two subset. ... Perl code and Python code will be posted in 2 days. ... Xah ...
      (comp.lang.python)
    • Re: problem: reducing comparison
      ... (tested for pairings of comb(n) ... ©def reduce2(pairings, pair): ... Xah Lee wrote: ... > Note also that in Python there's already a function called reduce. ...
      (comp.lang.python)
    • Re: problem: reducing comparison
      ... (tested for pairings of comb(n) ... ©def reduce2(pairings, pair): ... Xah Lee wrote: ... > Note also that in Python there's already a function called reduce. ...
      (comp.lang.perl.misc)