diff options
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 |