Created
April 11, 2012 14:21
-
-
Save sakti/2359597 to your computer and use it in GitHub Desktop.
Generate two combinations from alfabets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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