Ranking Solution for Hash Code 2022

In this short article, I will describe my solution for the practice round of Hash Code 2022, written in Dart, and with a particular architecture solution.

I’m describing the solution in the article because I would like to receive feedback if anyone wants to share and improve the solution.

We can discuss any type of problem and solution regarding the google competition on the G-challenges repository under the discussion.

In addition, any type of PR is welcome, and if someone is interesting to know how I’m designing this repository you can write me on Twitter or post your solution with my architecture with the hash #gchallenges.

One Pizza Hash Code 2022 solution

Let Jump to our solution, and basically, my last solution written in dart is available with the following pull request.

The algorithm tries to calculate the score of a user in terms of goodness. In particular, a user is good for the Pizzeria if and only if the like ingredients are calculated with the formula like_rank = user_like_ingredient / tot_like_ingredient and how a user it is bad for the pizzeria with the dislike_rank = -(user_dislike_ingredient / tot_dislike_ingredient) + 1.

After that, we calculate the total rank with the following formula

rank_user = like_rank + dislike_rank

Where the rank_user should be a value between [0 and 2], when we have the following tank we sort the list of users by rank in decreasing order and we start to check if the user can be a good use for the pizzeria.

In this case, we have two situations, described as follows:

  • The Client is a good candidate for the pizza, in this case, add all the ingredients to two global lists for the Pizza, one for the like ingredient and the other one for the dislike ingredient.
  • The Client is not a good candidate for the pizza, and in this case, that and ingredient that like to the user it is already inserted inside the dislike list.

The complexity time of the algorithm is O(Clients * dislike_ingredients) and the following is the score given by the google scoring function


In conclusion, I create this medium post not to say that my solution is good, but only to have a chat with other people that are involved in solving this problem.

I found really difficult to find someone that is doing the same problem around me. However, thanks to StarkPrince for a great talk on Reddit that give me some good ideas for implementing this ranking strategy.

If you like this post and my solution please consider supporting me by following on Twitter and Github.

Ah don’t forget to start also the repository G-challenges




I'm an Open Source software developer, and in my free time, I'm a master's student. My main focus is to build some tools useful for other developers.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The Secret GitHub Wiki Repo and CI/CD for Docs

9 steps to rename your default Github branch safely

A listing of branches from Github code view. The main branch is now labeled the default. Mouse over “View all branches”

Amazon Route 53

How to Build FAQ ChatBot Using Dialogflow From Scratch……

The return of the architect

Setting up a logger in Flutter

Serverless Lambda Custom Authorize

Deploying Kafka with plain SASL Authentication using Docker

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vincenzo Palazzo

Vincenzo Palazzo

I'm an Open Source software developer, and in my free time, I'm a master's student. My main focus is to build some tools useful for other developers.

More from Medium

Enhance business value by moving from project-centric to product-centric approach

On Privacy as Data Protection for the Individual

Software integration? What does that even mean?

An Overview of Insider Risk Management