Google Foo Bar Challenge Level #1

As I was working on my Capstone Project, I googled the syntax of a list comprehension in Python as a refresher, and all of a sudden I was given a “Google Foo Bar” challenge. I’ve heard about this before from one of my friends who encountered one in the past, but I never anticipated on actually having the opportunity to be given an invitation myself.

The first level of the challenge I was given was the following:

One thing that I learned when approaching a problem was to whiteboard the problem out first before coding away right away.

So I quickly broke down the problem into the following steps:

  1. Make or import a string of alphabets in alphabetical order.
  2. Make another string of alphabets in reverse order.
  3. Make a dictionary that maps the alphabets in the alphabetical order to the alphabets in reverse order.
  4. Pass on the character if it’s uppercase or if it’s a punctuation.
This here above takes care of step 1, 2, and 3

Before I made the function itself, I tested first through implementation steps 1, 2, and 3 while meeting the step 4 requirement. After seeing that the output worked with the test case of “Cat!”, I proceeded on to writing the function.

Overall, the first level of the challenge seemed pretty straightforward and was a good warm-up for the next levels to come.