Solution by Gustavo Chaves
