Skip to content

Instantly share code, notes, and snippets.

@xavierzwirtz
Forked from JonBons/gist:62ca4b6957c3e11689b5
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xavierzwirtz/43d75c575718f5db3b5f to your computer and use it in GitHub Desktop.
Save xavierzwirtz/43d75c575718f5db3b5f to your computer and use it in GitHub Desktop.
open System
//leaderboard #1
let leaderboard1 =
let ln = System.Console.In.ReadLine //;;
[1..(int (ln()))] |> List.map (fun x-> ln().Split([|' '|]) |> Array.map int |> Array.reduce (+)) |> List.iter System.Console.WriteLine
//leaderboard #2
let leaderboard2 =
let n = Console.ReadLine() |> int
for i = 1 to n do
let number_string = Console.ReadLine()
let numbers = Array.map (fun s -> int s) (number_string.Split [|' '|])
let s = Array.sum numbers
printfn "%d" s
//leaderboard #3
let leaderboard3 =
let count = stdin.ReadLine() |> int
Seq.init count (fun i -> stdin.ReadLine().Split() |> Seq.map int)
|> Seq.map Seq.sum
|> Seq.iter (fun x -> printfn "%d" x)
//my try ( could not figure out how to pipeline this :( )
//pipeline attempt
// [1..lines] |> Seq.iter ( printf "%i\n" (Console.ReadLine().Split() |> Seq.map int |> Seq.sum) )
let mySolution =
let lines = Console.ReadLine() |> int
for i = 1 to lines do
//my first iteration
//let numbers = Console.ReadLine().Split[|' '|] |> Seq.map int
//printf "%i\n" ((numbers |> Seq.nth 0) + (numbers |> Seq.nth 1))
//second iteration
printfn "%i" (Console.ReadLine().Split() |> Seq.map int |> Seq.sum)
let XaviersSolution =
let lines = [(Console.ReadLine() |> int)..lines]
let result =
lines
|> List.map(fun _ -> Console.ReadLine().Split() |> Seq.map int |> Seq.sum |> string)
|> String.concat("\n")
printf "%s" result
[<EntryPoint>]
let main argv =
mySolution
0 // return an integer exit code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment