summary refs log tree commit diff stats
path: root/solutions/day6.fs
blob: bb8338840985610b8601bec8050f8e174fb02b6e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
namespace Solutions

module 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