Skip to content

Instantly share code, notes, and snippets.

@sakti
Created April 11, 2012 14:21
Show Gist options
  • Save sakti/2359597 to your computer and use it in GitHub Desktop.
Save sakti/2359597 to your computer and use it in GitHub Desktop.
Generate two combinations from alfabets
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment