Skip to content

Commit 782c0af

Browse files
committed
1fs
1 parent 1013dfc commit 782c0af

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

f#/1.fsx

+25
Original file line numberDiff line numberDiff line change
@@ -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

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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

0 commit comments

Comments
 (0)