Permutations with repetitions: Difference between revisions

m
(→‎{{header|Python}}: Added a variant with a hand-written generator)
Line 1,570:
 
=={{header|Python}}==
 
===Applying itertools.product===
 
<lang python>from itertools import product
 
Line 1,578 ⟶ 1,581:
if w.lower() == 'crack': break</lang>
 
===Writing a generator===
 
Or, composing our own generator, by wrapping a function '''from''' an index in the range ''0 .. (distinct items to the power of groupSize)'' '''to''' a unique permutation. (Each permutation is equivalent to a 'number' in the base of the size of the set of distinct items, in which each distinct item functions as a 'digit'):
9,655

edits