summary refs log tree commit diff stats
path: root/solutions/day1.fs
blob: 55616013ca4d5f05d5784e399483298c78dc956b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Solutions.Day1
open System.IO

let lines = File.ReadLines("inputs/day1.txt")
let totalWeights = seq {
    let mutable subseq = 0

    for line in lines do
    if line.Equals("") then
        yield subseq
        subseq <- 0
    else
        subseq <- subseq + int line
}

let part1 () = totalWeights |> Seq.max
let part2 () = totalWeights |> Seq.sortDescending |> Seq.take 3 |> Seq.sum