What is Foobar? On Google’s Amazing Secret Coding Challenge
By: Aviv Yaniv
Tags: Mathematics, Programming, Challenge, Coding, Software Development

The Exclusive Foobar Popup Invite

Imagine yourself, coding for fun as you do every day, without any further notice an error occurs (nobody is perfect) — you Google it.

This has been a usual day, but something strange is happening… the results screen starts to slide and a mysterious message appears.

“Curious developers are known to seek interesting problems. Solve one from Google?”

There are two possible future consequences, you may close it and never see it again — but if you do click it, one of the best coding challenges and mind-intriguing journeys will start!

Congratulations🥳🎉

You’re now part of the secret hiring process targeted to find the most talented programmers.

In this post, I shall share with you helpful advice on how to pass this legendary 5-levels journey, as for the honor code — no solutions will be provided.

The Journey Begins…

So as described above, I’ve been answering some questions on StackOverflow, whilst coding an answer, and Googled to check on an error, this message popped up, excited I’ve clicked it and the following message appeared

You begin the journey in Level-1 as a minion, that infiltrates Commander Lambda

Before moving on I shall warn you that once you start the journey, each riddle is time-constrained, so don’t start a riddle if you booked yourself travel abroad that week.

I describe how to handle the command-line (you can skip it) and then continue our journey😀

Command-Line Orientation Quick Guide

When first tackling the command-line interface, it looks puzzling

“Am I working on Linux? Is it DOS?”

Click on help to view all possible commands:

After you get into the riddle directory with cd you may read the problem description using cat readme and can edit you solution using Python or Java i.e. using edit solution.py , once you finish you would like to submit it i.e. using submit solution.py which in turn runs some hidden test-cases.

The Journey Continues…

The Foobar challenge, similar to an Escape room has it’s own story and theme.

You start at Level-1 as a minion that infiltrates Commander Lambda, which builds a destruction device called “LAMBCHOP” to destroy Bunny Planet.

In each level, you rank up based on your special abilities to solve problems and being helpful to Commander Lambda, however, the end-goal is to free the bunny prisoners from Commander Lambda's evil grasp and escape the space station.

This is about the story, that is interleaved with the descriptions of the problems which tend to be written like literature pieces, probably to test how can you refine a concrete goal and overcome distractions.

First Level, has a time constraint of 48 hours, it was very easy but don’t become overconfident — as the game steps up fast.

Level 1 Completion

Each level is divided into a number of riddles that you have to pass them all to continue to the next level.

On Level-3 you get the option to pass your information to Google recruiters.

Riddles are in increasing difficulty and will require knowledge in mathematics, complexity analysis, algorithms, dynamic programming, trees, and graph theory.

The famous CLRS : Introduction to Algorithms is a great source to study.

In the unfortunate case that a submission fails, no call stack nor details are provided rather than just the number of the test case.

So when designing a solution:

First, write down the problem requirement as simple and plain as possible, you may return to it many times. Reading the whole original problem description is inefficient and distracting

Consider the time and space complexity of the solution, you may come up with a solution and make improvements

Making the code as clean as possible, so you can debug and test it locally with ease (problems are complex enough — let’s make the solutions simple)

Prefer iterative solution over recursive one, Foobar generously provides the constraints constants for the input, some large inputs will blow up the stack, and… StackOverflow occurs🤯

Most (all) problems had an elegant short solution if you reach a point solution gets too long and overcomplicated, consider to start over with a new approach

Think of as much edge-cases as possible, and make sure to handle all of them (empty input, long input, and riddle-specific)

Maintain unit-tests for your solution, so if you have to start over you can fast and confidently test yourself

If you chose Python as your language, make sure your code is version 2.7 compatible (some Python 3 syntax and features may cause the error)

All riddles are time-constrained, and I’ve been working on other stuff while doing the Foobar challenge .The best advice is to take a break and relax, especially once stuck and between riddles 🏝

The Journey Ends

Once you finish all levels, our beloved free bunnies will jump and an encrypted message will be shown:

A final encrypted message will be shown

The message looks like a Base64 encoded string.

But what would be the encryption key? the hint is that it is for your eyes only, so let’s use your name as the key in a cyclic-manner and utilize XOR as in many encryption methods:

The message says:

{‘success’ : ‘great’, ‘colleague’ : ‘esteemed’, ‘efforts’ : ‘incredible’, ‘achievement’ : ‘unlocked’, ‘rabbits’ : ‘safe’, ‘foo’ : ‘win!’}

You did it! Well Done 😄🐇🏆

My Experience

Personally, Google Challenge has been one of the most joyful yet most challenging projects I’ve been working on (and I’ve started coding at age 14).

While a computer science degree or equivalent knowledge is much helpful, it’s not enough — the ability to simplify ideas and formalizing them is at least half of the way.

Failed test cases, while can be very frustrating, are a great priceless opportunity to improve algorithmic, coding, debugging, and testing skills, viewing them in a good light is the motivating way to go.

It’s very possible to get stuck and running out of ideas, value taking a break as much as you value working on it, watching the garden, or running at the park may evacuate enough room for new thoughts and more efficient approaches.

Wish you all the luck 🍀

Enjoyed this article? Feel free to long-press the 👏 button below 😀