Source: https://www.epfl.ch/labs/gdp/wp-content/uploads/2019/09/Exercices_1.pdf