Create a gist now

Instantly share code, notes, and snippets.

anonymous /cs.rb Secret
Created Aug 31, 2010

What would you like to do?
require 'rubygems'
require 'hpricot'
doc= Hpricot(open('cia-1996.xml'))
# What is the population of the country with the most people?
# What are the five countries with the highest inflation rates,
# and what were those rates in 1996?
puts r.to_a.sort_by{|a,b|b}.reverse[0..4]
# What are the six continents in the file and which
# countries belong to which continent?
# Can you also produce them in alphabetical order?
r = r.sort_by{|a,b|b + a}
r.each{|e|puts "#{e[1]} #{e[0]}"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment