Hi everyone!

I’m writing today to tell you about my first experience with Hash Code coding competition.

Hash Code is a team coding competition organized by Google. You can form a team up to 4 people, use whatever language you are more comfortable (even more than one!) and stretch your neurons to solve a problem.


Some friends and I have been working on our coding skills for a while using coding platforms like Hackerrank, Leetcode, Topcoder… I think it is a great way to learn new things and to stay in shape.

So, when I heard about the Hash Code competition I suggested them to participate and everyone was on board. We were very excited!

We met two times before the day of the competition. We tried the example exercise :pizza: :pizza: :pizza: in order to be familiar with the environment. Also, we talked about how to confront the problem. We decided the following:

  1. First of all, make a brainstorming. Give several ideas to solve the problem.
  2. Secondly, begin with the implementation of a score program to be able to measure our solutions without needing to upload the solution to the HashCode platform.
  3. Lastly, implement solutions starting from greedy and pseudo-greedy approaches, and improve it from there.

The competition started at 17:30 UTC and we had 4 hours. They released the problem and several datasets. The goal is to submit a solution and an output for each of the datasets. The best score for each of the datasets adds up to your total score. So, we did as we planned, we discussed the problem to be sure we understood it correctly, and we decided a course of action.

In the end, we came up with the scoring program, a random solver to test it, and a greedy solution.

We achieved the 1,290th position out of 6,671 participants, not so bad for our first time. We ended without finishing some of our tentative solutions, but overall the experience was very nice.


The whole Hash Code experience was very enriching. The fact that the problem to solve is NP-hard, and you must aim for a good enough solution, not only look for the best algorithm and data structure, is challenging and exciting.

We noted some things to improve for future competitions:

  • Speed up coding skills.
  • Be organized and prepared, you want to save time in the beginning to focus on your program. For example, by having pre-built utilities to handle the input and to parse solutions.
  • And of course, enjoy! Be relaxed and happy during the competition.

In case you are courious, here you can find our GitHub repository with the solutions we tried.

Hope you liked my post! See you soon!