Pergunta de entrevista da empresa Battlefy

The second part of code challenge was very unexpected. Because they provide an algorithm that was wrote very badly. In the time of code challenge I can't focus on this code (I want to wrote my algorithm, I can't imagined why I must correct this code, I can write better code in a short time. So I consume a lot of time for nothing.