LeetCode 2038. Remove Colored Pieces if Both Neighbors are the Same Color in F#

URL

Remove Colored Pieces if Both Neighbors are the Same Color - LeetCode

Code

https://github.com/syohex/dotnet-study/tree/master/fsharp/leetcode/problems/2038/main.fsx

let winnerOfGame (colors: string) : bool =
    seq { 1 .. (colors.Length - 2) }
    |> Seq.fold
        (fun (a, b) i ->
            if colors.[i - 1] = colors.[i] && colors.[i] = colors.[i + 1] then
                if colors.[i] = 'A' then a + 1, b else a, b + 1
            else
                a, b)
        (0, 0)
    ||> (>)