Source: https://www.lri.fr/~hivert/COURS/Info121/TP4-corr.pdf