Sha256: fd56d800581e112677f79955da863c85b216d57549a8c2b37ae3c66c932e92f7
Contents?: true
Size: 541 Bytes
Versions: 396
Compression:
Stored size: 541 Bytes
Contents
module Dominoes let rotate xs = let length = xs |> List.length let perm n = xs |> List.permute (fun index -> (index + n) % length) [1 .. length] |> List.rev |> List.map perm let chainPair (x, y) list = match list with | (x', y')::xs when y = x' -> (x, y')::xs |> Some | (x', y')::xs when y = y' -> (x, x')::xs |> Some | _ -> None let rec canChain input = match input with | [] -> true | (x, y)::[] -> x = y | x::xs -> rotate xs |> List.choose (chainPair x) |> List.exists canChain
Version data entries
396 entries across 396 versions & 1 rubygems