This coding exercise comes from Upcase, the online learning platform we run. It's part of the Ruby Challenges course and is just one small sample of all the great material available on Upcase, so be sure to visit and check out the rest.
Difficulty: Easy, but requires isolating an external service during testing.
As a Shakespeare buff, statistics junkie, and Unix lover, Ben finds himself wanting a command-line tool for analyzing Macbeth.
Write a command-line program that prints the number of lines spoken by each character in the play.
Sample usage/output (using made-up numbers):
$ ruby lib/macbeth_analyzer.rb
543 Macbeth
345 Banquo
220 Duncan
(etc.)