Sha256: 23fd52904e5829b1f6c8988cd4db7cb8ba9d980b4f2e0fcadae208d2d3066943
Contents?: true
Size: 881 Bytes
Versions: 130
Compression:
Stored size: 881 Bytes
Contents
module LargestSeriesProduct open System let digits (str: string) = str |> Seq.map (string >> int) |> Seq.toList let slices size list = let slice i = list |> List.skip i |> List.take size let sliceCount = List.length list + 1 - size List.init sliceCount slice let allDigits input = input |> Seq.forall Char.IsDigit let isInvalidCase input seriesLength = let inputLenth = String.length input inputLenth < seriesLength || inputLenth = 0 && seriesLength > 0 || seriesLength < 0 || not (allDigits input) let largestProduct input seriesLength : int option = match isInvalidCase input seriesLength with | true -> None | false -> input |> digits |> slices seriesLength |> List.map (List.fold (*) 1) |> List.max |> Some
Version data entries
130 entries across 130 versions & 1 rubygems