Last active
December 11, 2015 02:19
-
-
Save bricker/4529753 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple, stupid script that counts how many times a letter occurs | |
# in the english translation of each number from 0 to MAX_NUM. | |
# Doesn't include the joining word "and" in numbers like "one hundred and two" | |
# | |
# NOTE: You need to install two gems to run this script: | |
# * loggability (linguistics depends on it but doesn't install it as a dependency for some reason) | |
# * linguistics | |
require 'linguistics' | |
Linguistics.use(:en) | |
MAX_NUM = 999_999 | |
# String of all the wordified numbers with all " and " and non-word | |
# characters stripped out. | |
# This method takes a long time to perform. | |
str = (0...MAX_NUM).map { |n| n.en.numwords }.join.gsub(/ and /, "").gsub(/\W/, "") | |
# Loop through each letter, scan the string for it, and output its frequency. | |
%w{a b c d e f g h i j k l m n o p q r s t u v w x y z}.each do |l| | |
puts "#{l}: #{str.scan(l).size}" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a: 998999 | |
b: 0 | |
c: 0 | |
d: 4598995 | |
e: 6319993 | |
f: 1420000 | |
g: 600000 | |
h: 3998997 | |
i: 2619994 | |
j: 0 | |
k: 0 | |
l: 40000 | |
m: 0 | |
n: 5358985 | |
o: 2359000 | |
p: 0 | |
q: 0 | |
r: 2999999 | |
s: 2198999 | |
t: 4338997 | |
u: 3198997 | |
v: 1020000 | |
w: 600000 | |
x: 600000 | |
y: 1599998 | |
z: 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment