Browse Source

distinct script now uses get_words function.

try-trie-tree
Charles Reid 8 years ago
parent
commit
96c7372ab3
  1. 16
      distinct.py

16
distinct.py

@ -1,10 +1,6 @@ @@ -1,10 +1,6 @@
"""
distinct.py
Number of words that contain exactly k distinct letters,
1 <= k <= 5
Donald Knuth
Art of Computer Programming
Volume 4 Facsimile 0
@ -12,17 +8,7 @@ Exercise #27 @@ -12,17 +8,7 @@ Exercise #27
How many SGB words contain exactly k distinct letters, for 1 <= k <= 5?
"""
def get_words():
# Load the file.
with open('sgb-words.txt','r') as f:
## This includes \n at the end of each line:
#words = f.readlines()
# This drops the \n at the end of each line:
words = f.read().splitlines()
return words
from get_words import get_words
if __name__=="__main__":
words = get_words()

Loading…
Cancel
Save