Skip to content

Instantly share code, notes, and snippets.

@mathias-brandewinder
Forked from radwane-h/FsharpSnippets.fs
Last active August 29, 2015 14:21
Show Gist options
  • Save mathias-brandewinder/d410214d2a7b1d5eb301 to your computer and use it in GitHub Desktop.
Save mathias-brandewinder/d410214d2a7b1d5eb301 to your computer and use it in GitHub Desktop.
open System
let readInt () = Console.In.ReadLine() |> int
let N = readInt ()
let readline = [ for i in 0 .. N - 1 -> readInt () ]
let minimumBetweenTwoNumbers n1 n2 = min n1 n2
let rec minimum data mini =
match data with
| first::second::tail ->
let min = (first-second) |> abs |> minimumBetweenTwoNumbers mini
match tail with
| [] -> min
| _ -> minimum (second::tail) min
let compute =
minimum readline 10000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment