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

let buf = File.ReadAllText("inputs/day6.txt")

let rec scan size str index =
    if String.length str < size then -1
    else
        let current = str[..size - 1] |> Set.ofSeq
        if Set.count current = size then index + size
        else
            scan size str[1..] index + 1

let part1 () =
    scan 4 buf 0

let part2 () =
    scan 14 buf 0