Solving Facebook Programming Puzzles using Ruby

I really enjoy solving puzzles. That’s probably what drove me to becoming 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:

#!/usr/bin/env ruby
n =[0]).gets.to_i
1.upto(n) do |i|
    if i % 3 == 0 && i % 5 == 0
        print "Hopn"
    elsif i % 3 == 0
        print "Hoppityn"
    elsif i % 5 == 0
        print "Hophopn"

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 scripted languages shouldn’t have a file extension when they are submitted.

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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s