Created
December 18, 2021 05:38
-
-
Save mettler/a4db0a725ea86f75cad0ee9db9e3cd9e to your computer and use it in GitHub Desktop.
This file contains 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
def load_words(): | |
with open('words.txt') as word_file: | |
valid_words = set(word_file.read().split()) | |
return valid_words | |
if __name__ == '__main__': | |
english_words = load_words() | |
for word in english_words: | |
word = word.replace('-', '') | |
if len(word) > 4: | |
firsthalf = "" | |
secondhalf = "" | |
for i, c in enumerate(word): | |
if (i % 2) == 0: | |
firsthalf += c | |
else: | |
secondhalf += c | |
if (firsthalf + secondhalf) == word: | |
print (word) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment