DEV Community

Discussion on: Daily Challenge #153 - Horse Race Gamble

Collapse
 
nickholmesde profile image
Nick Holmes

The code (F#)

let WinnerCombinations n =
    if (n <= 3) then None
    else Some (n * (n-1) * (n-2))

As F# is a strongly typed language, no need to check n is an integer - it is. Idiomatically, "undefined" in F# is handled with the Option monad, so we return either None or Some result.

The actual calculation is trivial; n * (n-1) * (n-2)