Skip to content

Instantly share code, notes, and snippets.

@krmax44
Created October 8, 2018 18:06
Show Gist options
  • Save krmax44/e5a90f13acea5a922c5736cad136463c to your computer and use it in GitHub Desktop.
Save krmax44/e5a90f13acea5a922c5736cad136463c to your computer and use it in GitHub Desktop.
Horribly inefficient solution, but it's only one line of code!
// words.txt: https://github.com/dwyl/english-words/blob/master/words.txt
// see this video for why this exists: https://www.youtube.com/watch?v=zp4BMR88260
console.log(require('fs').readFileSync('words.txt').toString().split('\n').filter(word => /^[abcdefhijlnoprstu\-y. ]*$/.test(word.toLowerCase())).sort((a,b) => a.length < b.length ? 1 : -1)[0]);
// output: dichlorodiphenyltrichloroethane
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment