Browse Source

distinct script now uses get_words function.

master
Charles Reid 3 years ago
parent
commit
96c7372ab3
1 changed files with 1 additions and 15 deletions
  1. +1
    -15
      distinct.py

+ 1
- 15
distinct.py View File

@@ -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

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