Solving Facebook Programming Puzzles using Ruby

I really enjoy solving puzzles. That’s probably what drove me to become a software developer. So I was thrilled to learn that Facebook has a series of programming puzzles. Once you solve a puzzle, you email your code to Facebook and they email you back your results. What follows are the steps that I took to get my computer setup, solve my first puzzle, and submit it to Facebook for testing. It’s important to note that while I primarily work in the .NET world, the Facebook Puzzle bot doesn’t do .NET. This gave the opportunity choose a new language to learn from their list of supported languages (I chose Ruby).

General information about the Facebook Puzzles are at

1) Download Ruby-1.8.6 from

2) Next I picked the puzzle I was going to work on. For my first one I picked Hoppity!/careers/puzzles.php?puzzle_id=7

My solution looked like this:

1.upto(n) do |i|
    if i % 3 == 0 && i % 5 == 0
        print "Hop\n"
    elsif i % 3 == 0
        print "Hoppity\n"
    elsif i % 5 == 0
        print "Hophop\n"

3) Then I saved the solution to a file named the same as the keyword on the Facebook puzzles page. In this case, hoppity with no file extension. Source files from scripting languages shouldn’t have a file extension when they are submitted.

You can test the solution by creating a sample input file and calling Ruby from the Ruby command line like this:

David Eisenstat has some more information on his site Including more information on how to submit solutions for compiled languages.

4) Finally, email the file to {0xFACEB00C>>2 in decimal} (or Once the puzzle engine processes your submission you’ll receive an email with the results.

I hope that you enjoy solving these puzzles as much as I do. And who knows, maybe you’ll even learn something. ;-)