Source: https://grug.eeisti.fr/ING-1/Info%20/Algorithmique/TD/td11Corrig%C3%A9.pdf