Berikut kode program Python memanfaatkan modul itertools untuk menghasilkan kombinasi dari list

# two_alfabets_combination.py

import itertools
import string


def create_circular_alfabet(count=26):
multiplier = count / 26 + 1
result = string.lowercase * multiplier
return result[:count]

source = create_circular_alfabet(100)
item_length = 2
output_file = ‘result.txt’

combination_result = itertools.combinations(source, item_length)

fh = open(output_file, ‘w’)

count = 0
for item in combination_result:
fh.write(‘%s ’ % “.join(map(str,item)))
count += 1

fh.close()

print “Finished %s result items, check %s” % (count, output_file)

Berikut hasil setelah dijalankan

$ python two_alfabets_combination.py
Finished 4950 result items, check result.txt
$ wc result.txt
0 4950 14850 result.txt
$ cat result.txt
ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av
.
.
.

Improvement: gunakan modul argparse atau optparse untuk membuat tool command line.