Last week, I attended an event’s that becoming one of the favorite things on my calendar – Google Hash Code. Google comes up with an interesting real-world problem and gives teams of engineers around the world up to 4 hours within which to code solutions to it.
Let the Hunger Games begin! Snow delivering the address while Panem residents look on

This year, I didn’t get Kanzu Code’s core team from last year together in time so I joined a former colleague’s team. We’ve worked together before in MTN Uganda on some amazing things so it felt like the good old days putting our heads together to battle yet another real world problem.

We were graciously hosted by the awesome Andela Uganda.  We didn’t work out of my living room this time hehe.
Over 8,000 teams participated. The competition was intense but lots of fun. 4 hours fly past so fast!
Here’s what we submitted: Hash Code 2018. 
Points are awarded on how good your algorithm is.
Our score was 33,124,929. The winning team had 49,776,211
We will refine our algorithm and add an explanation to make it easier to follow; the link currently shows what those 4 intense hours produced so it is still a bit raw.
The team trying out multi-threading….
Some tips for you if you plan to participate:
Long Before the Competition
  • Get into the Algorithm & data structures groove. If possible, get a couple of buddies and meet regularly to hash through some difficult problems. The accountability will help in making sure you find a way to put some time into your preparation

Just before the competition

  • Write out the code that’s going to receive the input data. The input format is usually files who’s content you need to manipulate a bit into meaningful variables. Go through past problems and prepare this logic accordingly.  The only goal is that your algorithm is optimum so debugging code that’s only doing the input is a waste of precious time. It is key to mention here that there’s been a change in the way input data is provided by Google in Google Code Jam, a separate competition they run. I suspect they’ll make a similar change to Google Hash Code next year, eliminating the need for this input code altogether
  • Create a repo for this code and make sure all of you on the team have access to it and have your development environments set up
  • Get a whiteboard or huge sheets of paper. They help in visualizing while discussing the problem

    The team, A J Cyclops, at work. L-R: Jonathan, Alex, Peter and Sidney
  • [Nice Bonus] If you have access to a huge screen, get one and hook it up to a machine of someone on the team. It helps when you start discussing & debugging the code jointly

onStart()

  • Watch the opening ceremony intently not because you’ll get tips but because it is an intense competition. Do everything with intensity. If you break for a snack, eat with intensity too.
  • Read the problem separately as soon as it is released (15 minutes)
  • Discuss it together to ensure you’ve all captured all aspects of it (10 minutes)
  • Discuss your algorithm. At the very least, get the greedy approach (15 minutes – 45 minutes)
  • Split now. Let the designated coder start testing your code against the data and writing out the initial implementation as the rest look to refine it further
  • Another person can also split off and start coding another solution too
  • It is very key to submit a working algorithm early. It might take a bit of debugging to get there so do it early. There’s also something that seeing those initial scores does for your morale so get something in early.
  • Split or continue discussing on the board as appropriate to your scenario to optimize your algorithm further
  • Towards the end, you should all be submitting solutions. Scores are given for the best solution on your team so create separate branches, discuss, optimize, make changes, build and submit. Repeat.
During the announcements at the end of the competition, Google announces, among other things, the country that scored the most points. I hope they’ll also start releasing countries with the most points per team otherwise countries with a huge number of participating teams will always be the ones being announced.
Our performance leaped by bounds from our first Google Hash Code attempt last year. Hopefully, you’ll be encouraged to sign-up, practice and show up. It is truly a phenomenal experience.

Peter Kakoma is the lead developer here at Kanzu Code. He is the reigning World thumb-wrestling champion who loves to write clean code and silly things in equal measure.