Ad
Code
Diff
  • module rec ExampleSolution
      let findUniqueNumber (array : _ array) =
        let guess = array.[0]
        findUniqueNumber' array guess 1
        
      let rec findUniqueNumber' (array : _ array) guess n =
        let a = array.[n]
        let b = array.[n+1]
        match guess = a, guess = b with
        | true, true -> findUniqueNumber' array guess (n+1)
        | false, true -> a
        | true, false -> b
        | false, false -> guess
    • module ExampleSolution
    • let findUniqueNumber array =
    • () // your code goes here
    • module rec ExampleSolution
    • let findUniqueNumber (array : _ array) =
    • let guess = array.[0]
    • findUniqueNumber' array guess 1
    • let rec findUniqueNumber' (array : _ array) guess n =
    • let a = array.[n]
    • let b = array.[n+1]
    • match guess = a, guess = b with
    • | true, true -> findUniqueNumber' array guess (n+1)
    • | false, true -> a
    • | true, false -> b
    • | false, false -> guess