Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Re: [mg4434] Pairings
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Allan Hayes

Posts: 1,508
Registered: 12/6/04
Re: [mg4434] Pairings
Posted: Jul 30, 1996 3:01 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Robert Pratt <rpratt@math.unc.edu>
[mg4434] Pairings
writes

> I want a function that finds, given n, all pairings of Range[n]
> excluding {1,2}, {2,3}, {n-2,n-1}, and {n-1,n}........


Robert:
Needs["DiscreteMath`Combinatorica`"]

DeleteCases[KSubsets[Range[7],2], {a_,b_}/;b==a+1]//Timing
{0.05 Second,
{{1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {2, 4}, {2, 5}, {2, 6},
{2, 7}, {3, 5}, {3, 6}, {3, 7}, {4, 6}, {4, 7}, {5, 7}}
}

Allan Hayes
hay@haystack.demon.co.uk







Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.