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:
- Make or import a string of alphabets in alphabetical order.
- Make another string of alphabets in reverse order.
- Make a dictionary that maps the alphabets in the alphabetical order to the alphabets in reverse order.
- Pass on the character if it’s uppercase or if it’s a punctuation.
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.