F# solution by Jérémie