Sha256: 81a706b419e52fd9e56ea499fbf1f00753a8ac842839c2582a45fa727bd27efd
Contents?: true
Size: 594 Bytes
Versions: 134
Compression:
Stored size: 594 Bytes
Contents
module Change let minimalCoins coins map target = coins |> List.filter (fun x -> x <= target) |> List.choose (fun x -> match Map.tryFind (target - x) map with | Some y -> Some(x :: y) | None -> None) |> List.sortBy List.length |> List.tryHead let updateMinimalCoinsMap coins map target = match minimalCoins coins map target with | Some x -> Map.add target x map | None -> map let findFewestCoins coins target = [1..target] |> List.fold (updateMinimalCoinsMap coins) (Map.ofList [(0, [])]) |> Map.tryFind target
Version data entries
134 entries across 134 versions & 1 rubygems