Skip to content

Instantly share code, notes, and snippets.

@radwane-h
Last active August 29, 2015 14:21
Show Gist options
  • Save radwane-h/7a166373c8dffba8f629 to your computer and use it in GitHub Desktop.
Save radwane-h/7a166373c8dffba8f629 to your computer and use it in GitHub Desktop.
// Learn more about F# at http://fsharp.net. See the 'F# Tutorial' project
// for more guidance on F# programming.
#load "Library1.fs"
(* Auto-generated code below aims at helping you parse *)
(* the standard input according to the problem statement. *)
open System
let N = int(Console.In.ReadLine())
let readline = [ for i in 0 .. N - 1 -> int(Console.In.ReadLine()) ]
let minimumBetweenTwoNumbers n1 n2 =
if n1 > n2 then n2
else n1
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
(* Write an action using printfn *)
(* To debug: Console.Error.WriteLine("Debug message") *)
printfn "%i" compute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment