December 28, 2009

Pythonで順列や組み合わせを手に入れる

from itertools import ...

IteratorArguments
product()p, q, ... [repeat=1]
permutations()p[, r]
combinations()p, r

product('ABCD', repeat=2)AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD
permutations('ABCD', 2)AB AC AD BA BC BD CA CB CD DA DB DC
combinations('ABCD', 2)AB AC AD BC BD CD

10.7. itertools — Functions creating iterators for efficient looping — Python v2.6.4 documentation