Any help will be appreciated
A few suggestions on something that I noticed:
In the function
makechaintheelseafter thereturnis not necessary.Typo in:
VOWELS = set('aeiouy'), there is an extray.This part:
LETTERS = set(ascii_lowercase) VOWELS = set('aeiouy''aeiou') CONSONANTS = LETTERS - VOWELS BASETAILS = { 'a': CONSONANTS, 'b': 'bjlr', 'c': 'chjklr', 'd': 'dgjw', .... } tails = dict() for i in ascii_lowercase: v = BASETAILS[i] if type(v) == set: v = ''.join(sorted(v)) tails.update({i: ''.join(sorted('aeiou' + v))})seems to do the following:
- Create a dictionary with mixed value's type (strings and sets)
- Convert all values to string
- Sort dictionary's values
It could be simplified to:
- Create a dictionary where all values are strings
- Sort dictionary's values
Additionally, having
VOWELSas a set andCONSONANTSas a string is a bit confusing. Would be better to use only one type.Code with suggestions above:
LETTERS = set(ascii_lowercase) VOWELS = set('aeiouy')'aeiou' CONSONANTS = ''.join(set(LETTERS) - set(VOWELS)) BASETAILS = { 'a': CONSONANTS, 'b': 'bjlr', 'c': 'chjklr', 'd': 'dgjw', .... } tails = dict() for i in ascii_lowercase: v = BASETAILS[i] tails.update({i: ''.join(sorted('aeiou'VOWELS + v))})In this way, you also avoid to sortsorting twice.