File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ #load " Common.fsx"
2+
3+ open Common
4+ open System
5+
6+ module p1 =
7+ let solve ( input : List < string >) =
8+ input
9+ |> Seq.map ( fun s ->
10+ if (( String.IsNullOrWhiteSpace >> not ) s) then
11+ Some( int64 s)
12+ else
13+ None)
14+ |> Seq.fold
15+ ( fun acc cal ->
16+ let ( c , s ) = acc
17+
18+ match cal with
19+ | Some v -> ( c + v, max ( c + v) s)
20+ | None -> ( 0 L, s))
21+ ( 0 , 0 )
22+ |> snd
23+
24+ let input = Common.readIn
25+ input |> p1.solve |> Common.writeOut
Original file line number Diff line number Diff line change 1+ module Common
2+
3+ open System
4+
5+ let readIn =
6+ Seq.initInfinite ( fun _ -> Console.ReadLine())
7+ |> Seq.takeWhile ( fun line -> ( not ( isNull line)))
8+ |> Seq.toList
9+
10+ let writeOut output = printfn " %A " output
You can’t perform that action at this time.
0 commit comments