How to find the best place to live using the Google Maps API

The problem

Assuming you travel a lot e.g. for your jobs and you want to reduce the time you travel. I wondered in which city you should rent a flat to stay between your trips. In my specific case the only important factor was the travel time. Regarding this, what is the best city? Luckily we can solve this problem with a computer, some programming skills and an internet connection. Some small real-world problems like this are the best way to improve your skills like in a code kata. In Germany, almost every city is connected by rails and tickets are quite cheap. This reduces the cities we have to consider as small towns don’t have a train station. The cities to consider can be picked from a map.

The solution

I wrote the script in python, but a javascript version should work the same way. One input file is a simple list of cities with the concert locations. The other one is a list of cities which are a reasonable to consider. Then the mean travel time with public transport is calculated for each home city. The results are sorted, so you get a ranking. In her case the best city is Cologne. Cologne is quite well connected, so is not that much surprising. You need an API code for the directions API from the Google developer section in order to Google Maps API. A free API key allows up to 2500 request a day, which is more than enough for this task. Using the API is quite easy, but the documentation for the Python API links to the Javascript one. The code for my implementation can be found here.

As I started my studies I had a lot to learn. Here is a collection of things I learned over time or what felt right in retrospective. Therefore this article may be only interesting for current or ongoing computer science (cs) students or people who want to get some insight into a cs students mind.

Choosing the right computer

As a computer science student, you obviously need a computer. But which one? When I started my studies I bought a MacBook Pro. The times when I only used my computer at home were gone. So a desktop computer is not the right choice. Studying cs you life is focused on your computer. The laptop you use matters a lot and shapes your daily life and matters to your quality of life a lot. As a cs student almost everything you do can be performed by using just that one piece of technology. Therefore many of us carry our laptops with us. I took all of my lecture notes on my laptop. Even the math lectures. Others rely on paper, their mobile phone or tablet. For me, this does not work because I can not properly work without a keyboard and a small screen. For some time I tried using an iPad as a replacement for my laptop but my laptop is a much more powerful tool than a tablet. For some people this also works, but not for me. Nowadays there are some laptop/tablet hybrids, so maybe check them out. I mostly commute by bike or walk. Having a heavy laptop in your rucksack or in an extra case slows you down and makes moving strenuous and takes the feeling of freedom and spontaneity. I recommend against a 15" or even 17" laptop. Get an external screen for your home instead if you want the size. If you don’t want an Apple MacBook you should install windows and ubuntu on two partitions. Many universities offer windows licenses in some software program. You will miss a lot if you don’t work with a Unix system. Because of the huge variety in needs and also the budget, I don’t advice for a specific model. But do not save money on your device. The return of increased production from a better device is huge.

Learn to work from the command line.

You want to understand your computer. You can chain commands together and get a better understanding what is happening under the hood of your computer. If you use macOS, install the shell fish. Zsh is another good alternative available for other Unix systems. It replaces the default shell bash. It comes with some nice features like autosuggestions. This one is also for macOS: Do you know the right-click-“open directory in terminal”-command with Ubuntu? As we will often use the terminal, you can add a similar feature to macOS. For a quick shortcut to open the current Finder directory in the terminal you can download cdto.app and drag it into Finder’s menu bar. Clicking this icon will save you a lot of time.

Learn a scripting language

I suggest learning a scripting language as soon as possible if it is not already part of your curriculum. I mostly use Python, but Ruby is also nice. You could also use JavaScript. JS cannot only run in a browser but also be run by using Java’s Nashorn engine by using the command “jjs” (assuming you have Java installed).

Obtain social skills

There is more than technology. Enjoy your student life. Go partying, do some sport, be engaged in the student union, some political party, or do some other social things. If you are single, start asking people out and go on dates. You should use this time to grow so push yourself to get out of your comfort zone.