Skip to main content

Home/ Python Programming/ Group items tagged combinatorics

Rss Feed Group items tagged

reckoner reckoner

ASPN : Python Cookbook : Permutation and Combination Enumerator - 0 views

  • def comb(items, n=None): if n is None: n = len(items) for i in range(len(items)): v = items[i:i+1] if n == 1: yield v else: rest = items[i+1:] for c in comb(rest, n-1): yield v + c
  • def perm(items, n=None): if n is None: n = len(items) for i in range(len(items)): v = items[i:i+1] if n == 1: yield v else: rest = items[:i] + items[i+1:] for p in perm(rest, n-1): yield v + p
  • Permutation and Combination Enumerator
reckoner reckoner

"n choose m" module - 0 views

  • """ a class for generating permutations from an array # choose 2 letters from 'abcd' c = Chooser(['a', 'b', 'c', 'd'], 2) while c.hasMoreElements(): print c.next() """ import time, copy class NoMoreChoices(StandardError): pass class Chooser:
reckoner reckoner

Place n indistinguishable items into k distinguishable boxes - comp.lang.python | Googl... - 0 views

  • >     Generate all ways to place n indistiguishable items into k >     distinguishable boxes
reckoner reckoner

SAGE: Open Source Mathematics Software - 0 views

  • General and Advanced Pure and Applied Mathematics Use SAGE for studying a huge range of mathematics, including algebra, calculus, elementary to very advanced number theory, cryptography, numerical computation, commutative algebra, group theory, combinatorics, graph theory, and exact linear algebra.
1 - 6 of 6
Showing 20 items per page