-
-
Save xavierzwirtz/43d75c575718f5db3b5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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