diff options
author | Brian Chu <brianmchu42@gmail.com> | 2022-01-04 22:14:05 -0800 |
---|---|---|
committer | Brian Chu <brianmchu42@gmail.com> | 2022-01-04 22:14:05 -0800 |
commit | 102086e040577a4f6b3e7d97e442ee32e12f3e27 (patch) | |
tree | c88f097b0a798bc9e1cd4ed09684216ac0f0946d /day6.fsx | |
download | AdventOfCode2016-102086e040577a4f6b3e7d97e442ee32e12f3e27.tar.gz |
solutions to day 8
Diffstat (limited to 'day6.fsx')
-rw-r--r-- | day6.fsx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/day6.fsx b/day6.fsx new file mode 100644 index 0000000..251dba1 --- /dev/null +++ b/day6.fsx @@ -0,0 +1,18 @@ +open System.IO + +let lines = File.ReadLines "day6.txt" |> Seq.toArray |> Array.map (fun x -> x.ToCharArray()) |> array2D +let rows, cols = Array2D.length1 lines, Array2D.length2 lines + +let chars (reversed:bool) = seq { for i = 0 to cols - 1 do + let col = lines[*, i] + yield col + |> Seq.countBy id + |> Seq.sortBy (snd) + |> if reversed then Seq.last else Seq.head + |> fst + |> string } + +// part 1 +chars true |> String.concat "" |> printfn "%s" +// part 2 +chars false |> String.concat "" |> printfn "%s" \ No newline at end of file |