+#!/usr/bin/coffee
+
+# this script tries to calculate an optimal letter distrobution.
+
+fs = require 'fs'
+
+
+fs.readFile 'wordlist.txt', 'utf8', (err, data) ->
+ if err?
+ console.log "Error reading #{orig_file}: #{err}"
+ process.exit(1)
+ else
+ weights = {
+ a: 0
+ b: 0
+ c: 0
+ d: 0
+ e: 0
+ f: 0
+ g: 0
+ h: 0
+ i: 0
+ j: 0
+ k: 0
+ l: 0
+ m: 0
+ n: 0
+ o: 0
+ p: 0
+ q: 0
+ r: 0
+ s: 0
+ t: 0
+ u: 0
+ v: 0
+ w: 0
+ x: 0
+ y: 0
+ z: 0
+ qu: 0
+ }
+ words = data.split '\n'
+ for word in words
+ weight = 1.0 * Math.pow .6, (Math.abs(word.length - 4))
+ i = 0
+ while i < word.length
+ if word[i] is 'q' and i < word.length and word[i+1] is 'u'
+ weights['qu'] += weight
+ i += 2
+ else
+ #if word[i] is 'u' and i > 0 and word[i-1] is 'q'
+ # console.log "skipping the u of a qu didn't work"
+ weights[word[i]] += weight
+ i += 1
+
+ total = 0
+ for letter, weight of weights
+ total += Math.round(weight)
+
+ for letter, weight of weights
+ weight = Math.round(weight)
+ #console.log "#{letter}: #{Math.round(weight / total * 1000)} (1 in #{Math.round(total / weight)})"
+ console.log "#{weight} # #{letter}"
+
+ console.log "total: #{total}"