The best VPN 2024

The Best VPS 2024

The Best C# Book

Google Foobar Challenge 1 Adding Digits

Spread the love

I submitted my answer, Google accepted my solution, and told me I had completed Level 1 of Foobar. I typed request and receivedmy next challenge.

I was given two days to complete the challenge, which only took a few minutes. I first started to trying to use integer division and the modulo operator to try to peel of each digit one at a time, but it quickly became evident that the best solution involved simple string manipulation.

You can request coding challenges by typing request into the command line. You have a few days to complete each challenge.

I assume that this is some sort of recruitment tool for Google, but as far as I can tell, they havent mentioned it formally in any public statements (other thana cryptic response sent to Business Insider).

When you join, you are provided with a web interface that provides a simple Unix-esque command line and a text editor:

googlefoobar

I saw that someone posted a link toGoogle FoobaronHacker Newsand my curiosity was immediately piqued. Since I have been trying to hone my coding skills, it seemed like the perfect thing to try.

If you google a bunch of coding terms, e.g. python for loop syntax and have search history turned on, Google will display a banner that invites you to join Foobar.

You can solve the challenges in either Java or Python, and I chose Python because I figured it would be less verbose for simple challenges like these. Ive posted my answers online, inthis Github repo.

If you dont know what Foobar is, that makes two of us, because even after completing two coding challenges on the site, I still dont know what its for. What I do know is this:

The first challenge I received was called guard_game. I am not going to reproduce the text of the challenge here, both because I dont think I have permission to and because it is unecessary. The challenge was simple – write a function that turns an integer into a single digit by recursively adding the digits comprising it. E.g.123 – 1 + 2 + 3 = 6or1235 – 1 + 2 + 3 + 5 = 11 – 1 + 1 = 2

Leave a Comment