Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 26 lines (19 sloc) 0.573 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
fs = require 'fs'

String::isAlphabetical = ->
return true if @length < 2
for i in [1..(@length - 1)]
return false if @[i] < @[i - 1]
return true

fs.readFile 'words.txt', (err, data) ->

if err
console.error 'Cannot open words.txt.'
process.exit 1

words = data.toString('ascii').split('\n')
alphacount = 0

for word in words
word = word.trim()
if word.length and word.isAlphabetical()
alphacount++
console.log word

console.log ''
console.log "#{alphacount} are alphabetical out of #{words.length} (#{(alphacount / words.length) * 100} percent)"
Something went wrong with that request. Please try again.