An exercise for Prime subscribers.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

An exercise for Prime subscribers. Visit to learn more.

Difficulty level: intermediate.

Your Task

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 macbeth_analyzer.rb
  543 Macbeth
  345 Banquo
  220 Duncan

You can find an XML-encoded version of Macbeth here: Your program should download and parse this file at runtime.

Your solution must be tested, preferably via TDD.


  1. To work on this exercise, fork the repo and begin implementing your solution.
  2. When you are done, copy the output of your program into a file in this repository.
  3. Create a pull request so your code can be reviewed.
  4. Perform a code review on at least one other person's solution. Your comments should follow our code review guidelines: Most important: be friendly. Make suggestions, not demands.
  5. Improve your solution based on the comments you've received and approaches you've learned from reviewing others' attempts.


While knowledge and skill improvement are their own rewards, the author with the best solution (as judged by thoughtbot) will receive a cool thoughtbot t-shirt.