Skip to content

Instantly share code, notes, and snippets.

@parkercoleman
Last active July 18, 2018 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parkercoleman/c8261ad388c33e2f4bcfde00b74b9759 to your computer and use it in GitHub Desktop.
Save parkercoleman/c8261ad388c33e2f4bcfde00b74b9759 to your computer and use it in GitHub Desktop.
Warmup solution
import nltk
from nltk.corpus import words
# nltk.download()
# print(words.words())
words = words.words()
phrase = "ada lovelace".lower().replace(" ", "")
longest_word = ""
for word in words:
iw = 0
for ip in range(0, len(phrase)):
if phrase[ip] == word[iw]:
iw += 1
if iw == len(word):
# The word was a match
if len(word) > len(longest_word):
longest_word = word
break
print("Longest word is {0} length {1}".format(longest_word, len(longest_word)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment