[perl-python] generate all possible pairings
From: Xah Lee (xah_at_xahlee.org)
Date: 02/27/05
- Previous message: Erik Max Francis: "Re: generic equivalence partition"
- Next in thread: Mike Meyer: "Re: [perl-python] generate all possible pairings"
- Reply: Mike Meyer: "Re: [perl-python] generate all possible pairings"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: Erik Max Francis: "Re: generic equivalence partition"
- Next in thread: Mike Meyer: "Re: [perl-python] generate all possible pairings"
- Reply: Mike Meyer: "Re: [perl-python] generate all possible pairings"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|