fork download
  1. let rec combinations n l =
  2. match n, l with
  3. | 0, _ -> [[]]
  4. | _, [] -> []
  5. | k, (x::xs) -> List.map ((@) [x]) (combinations (k-1) xs) @ combinations k xs
  6.  
  7. let solve n (lst : int list) =
  8. seq { for e in 1..n do yield! combinations e lst }
  9.  
  10. solve 8 [1..16]
  11. |> Seq.last
  12. |> printfn "%A"
Success #stdin #stdout 0.29s 30112KB
stdin
Standard input is empty
stdout
[9; 10; 11; 12; 13; 14; 15; 16]