3 # this script tries to calculate an optimal letter distrobution.
8 fs.readFile 'wordlist.txt', 'utf8', (err, data) ->
10 console.log "Error reading #{orig_file}: #{err}"
42 words = data.split '\n'
44 weight = 1.0 * Math.pow .6, (Math.abs(word.length - 4))
47 if word[i] is 'q' and i < word.length and word[i+1] is 'u'
48 weights['qu'] += weight
51 #if word[i] is 'u' and i > 0 and word[i-1] is 'q'
52 # console.log "skipping the u of a qu didn't work"
53 weights[word[i]] += weight
57 for letter, weight of weights
58 total += Math.round(weight)
60 for letter, weight of weights
61 weight = Math.round(weight)
62 #console.log "#{letter}: #{Math.round(weight / total * 1000)} (1 in #{Math.round(total / weight)})"
63 console.log "#{weight} # #{letter}"
65 console.log "total: #{total}"