Source: https://grug.eeisti.fr/ING-1/Info /Algorithmique/TD/td11Corrigé.pdf