Sha256: d23f87b9e18bdaef09f1cd022bc8ee7022d5ed774fcf6be64fb5f2a117bcaa06

Contents?: true

Size: 574 Bytes

Versions: 266

Compression:

Stored size: 574 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 largestProduct input seriesLength = 
    if seriesLength > String.length input then failwith "Slice size is too big"
    else 
        input 
        |> digits 
        |> slices seriesLength
        |> List.map (List.fold (*) 1)
        |> List.max

Version data entries

266 entries across 266 versions & 1 rubygems

Version Path
trackler-2.2.1.48 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.47 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.46 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.45 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.44 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.43 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.42 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.41 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.40 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.39 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.38 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.37 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.36 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.35 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.34 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.33 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.32 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.31 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.30 tracks/fsharp/exercises/largest-series-product/Example.fs
trackler-2.2.1.29 tracks/fsharp/exercises/largest-series-product/Example.fs