KHAN! (Ruby)

This evening I read a story on reddit in which someone graphed the number results google gives vs. the number of A’s in “KHAN.”  KHAN! is from the second Star Trek Movie, “The Wrath of Khan.”  The original results from that article are here.  I thought it was pretty funny, so I decided to write a ruby script to automatically do the same thing (I’ve been using ruby a lot lately).

require 'gruff'
require 'open-uri'

dataToGraph =
khanNumOfAs = 1
maxKhanAs = 100

g =
g.title = "KHAN!"

    sleep 0.5
    open('' + "A"*i + "N") do |f|
        f.each do |line|
            dataToGraph[i] = $~[1].gsub(/,/, "").to_i if /of about ([0-9,]+)/.match(line)
    print "KH#{"A"*i}N!!!!!    results: #{dataToGraph[i]}n"
}"KHAN!", dataToGraph)

Kevin helped me with the regular expressions to get the number of results out of google.

Final results, no log scale :-(

Final results, no log scale 🙁