Coding Environment for the Google Foobar Challenge
The Google Foobar Challenge is a series extremely interesting and fun coding problems. Lots has been written about the individual levels and problems. It seems to be a recruiting tool but there is no statement from Google about the Challenge and it's purpose. It it very well designed and covers a wide range of computer science tops. Earlier this year I received an invitation and have been slowly working through the levels. If you get an invite take it!
Working on the Google Foobar Challenge is tough on many fronts. Only one of two coding languages can be used: Java or Python. Furthermore you are restricted to older versions of these languages. If you choose Python you need to use version 2.7 and with limited libraries. Creating a Python coding environment for this Challenge is not easy because Python 2 is no longer being maintained. It was sunsetted back in 2020 and is no longer available in some Linux distributions.
Containerization provides a flexible and convenient way to isolate software that you want to keep separate from your main operating system. There are lots of coding tools for Python and JupyterLab is my favorite, providing an excellent environment for prototyping code.
The link above points to my
Dockerfile
for creating a JupyterLab container with both Python3 and Python2 kernels.
pylint
and
flake8
are also installed in case Google gives extra points for conforming to PEP8!
Installation steps:
-
Build the container with:
docker build -t foobar .
-
Run the container with:
docker run --rm --name foobar -v ./notebooks:/code/notebooks -p 8888:8888 foobar
-
Access JupyterLab in the container with a browser: http://localhost:8888/lab
JupyterLab .ipynb
notebooks are stored in the notebooks
directory
located in the same directory as the Dockerfile
.
Docker will create it if it does not exist.
This Dockerfile
can be easily extended to install additional Kernels such as go, rust, R, and so on.
A full list and instructions can be found here.