Google FooBar – Level 1 – Braille Translation – Python

I’ve recently been learning Python and was invited to the Google Foobar challenge. Google Foobar is an invitation only event that appears if Google detects that you’ve been searching for Python or Java related topics. You can accept the even and complete 5 levels which if you complete you will be able to fill out your personal information for a chance at an interview at Google. My skills aren’t the best but I had some trouble figuring out some of the levels so I decided to publish my submissions in hopefully helping someone out.


To complete the Google Foobar Level 1 challenge, Braille Translation


This level should be straight forward. You will simply need to create a Braille lookup tables list or array and translate the words given to you in Braille. You will need to interpret if the letter is capital as well as spaces. Below is the Google Foobar challenge. I ended up looking up what the Braille Charchets should be from the Braille Wikipedia page. If you notice from the Braille page it shows the Braille dots for the letters A to Z but they do not match the pattern Google wants you use so I had to manually create a list in the correct binary order.

The Challenge

Because Commander Lambda is an equal-opportunity despot, she has several visually-impaired minions. But she never bothered to follow intergalactic standards for workplace accommodations, so those minions have a hard time navigating her space station. You figure printing out Braille signs will help them, and – since you’ll be promoting efficiency at the same time – increase your chances of a promotion. Braille is a writing system used to read by touch instead of by sight. Each character is composed of 6 dots in a 2×3 grid, where each dot can either be a bump or be flat (no bump). You plan to translate the signs around the space station to Braille so that the minions under Commander Lambda’s command can feel the bumps on the signs and “read” the text with their touch. The special printer which can print the bumps onto the signs expects the dots in the following order:

So given the plain text word “code”, you get the Braille dots:

Write a function where 1 represents a bump and 0 represents no bump. Put together, “code” becomes the output string “100100101010100110100010”.

Write a function answer(plaintext) that takes a string parameter and returns a string of 1’s and 0’s representing the bumps and absence of bumps in the input string. Your function should be able to encode the 26 lowercase letters, handle capital letters by adding a Braille capitalization mark before that character, and use a blank character (000000) for spaces. All signs on the space station are less than fifty characters long and use only letters and spaces.

Test cases

Use verify [file] to test your solution and see how it does. When you are finished editing your code, use submit [file] to submit your answer. If your solution passes the test cases, it will be removed from your home folder.

The Solution

The output of the code run above. The Braille should translate to ‘Dayz’

Leave a Reply