Skip to content

Instantly share code, notes, and snippets.

@Gorcenski
Last active December 5, 2022 15:08
Show Gist options
  • Save Gorcenski/cad1435ac25895f32213fbc81bc73742 to your computer and use it in GitHub Desktop.
Save Gorcenski/cad1435ac25895f32213fbc81bc73742 to your computer and use it in GitHub Desktop.
Advent of Code 2022 Day 1
open System.IO
let readLines (filePath:string) =
use sr = new StreamReader (filePath)
sr.ReadToEnd().Split([|"\n\n"|],System.StringSplitOptions.TrimEntries)
|> Seq.map (fun x -> x.Split [|'\n'|])
|> Seq.map (Seq.map (int))
|> Seq.map Seq.sum
|> Seq.sortDescending
let results = "data/day1.txt" |> readLines |> List.ofSeq
results.[0..2] |> List.sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment