We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1013dfc commit 782c0afCopy full SHA for 782c0af
f#/1.fsx
@@ -0,0 +1,25 @@
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 -> (0L, s))
21
+ (0, 0)
22
+ |> snd
23
24
+let input = Common.readIn
25
+input |> p1.solve |> Common.writeOut
f#/Common.fsx
@@ -0,0 +1,10 @@
+module Common
+let readIn =
+ Seq.initInfinite (fun _ -> Console.ReadLine())
+ |> Seq.takeWhile (fun line -> (not (isNull line)))
+ |> Seq.toList
+let writeOut output = printfn "%A" output
0 commit comments