Skip to content

Instantly share code, notes, and snippets.

@josephg
Created October 10, 2014 08:23
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 josephg/01283b54847fa5053d87 to your computer and use it in GitHub Desktop.
Save josephg/01283b54847fa5053d87 to your computer and use it in GitHub Desktop.
# Get your word list:
# curl 'http://www-01.sil.org/linguistics/wordlists/english/wordlist/wordsEn.txt' -O
fs = require 'fs'
words = for word in fs.readFileSync('wordsEn.txt', 'utf8').split '\n' when word != ''
if word[word.length - 1] is '\r'
word[...word.length - 1]
else
word
#console.log words.length
w = {}
w[word] = true for word in words
w['i'] = true # Missing for some reason.
longest = ''
for word in words
w2 = word
cool = true
while word.length > 0 and cool
cool = false unless w[word]
word = word[1...word.length - 1]
if cool
if w2.length > longest.length
longest = w2
console.log w2 if w2.length >= 7
console.log 'longest', longest
8 letter words:
balinese
blessers
braiders
dopiness
drabbets
gaminess
lashings
methanes
pleasers
relaters
ropiness
washings
7 letter words:
ashamed
ashiest
borated
borates
bovines
bowings
busings
dosages
eclipse
escaped
escapee
escaper
escapes
estated
estates
flyings
lawings
lowings
musings
pirated
pirates
prearms
rowings
salient
scraped
scraper
scrapes
scrawls
scrawly
scrimps
scrimpy
sewings
sheathe
sheaths
striped
striper
stripes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment