You are viewing a single comment's thread. Return to all comments →
f# solution
open System let rec check r g y b = function | [] -> r = g && y = b | _ when (abs (r - g) > 1) -> false | _ when (abs (y - b) > 1) -> false | 'R' :: xs -> check (r + 1) g y b xs | 'G' :: xs -> check r (g + 1) y b xs | 'Y' :: xs -> check r g (y + 1) b xs | 'B' :: xs -> check r g y (b + 1) xs [<EntryPoint>] let main _ = let n = Console.ReadLine() |> int [ 1..n ] |> List.iter (fun _ -> Console.ReadLine() |> Seq.map char |> List.ofSeq |> check 0 0 0 0 |> Console.WriteLine) 0
Seems like cookies are disabled on this browser, please enable them to open this website
Sequence full of colors
You are viewing a single comment's thread. Return to all comments →
f# solution