Commit 1229ac92 authored by Taddeus Kroes's avatar Taddeus Kroes

funclang series3: implemented challenge.

parent 55f38f26
......@@ -13,13 +13,10 @@ let heads l = map hd l;;
(* 3 *)
let zip l m =
let rec cut l e =
let len = (length l) in
if e = len then l else cut (rev (tl (rev l))) e
in
let rec cut l e = if e = (length l) then l else cut (rev (tl (rev l))) e in
let min a b = if a > b then b else a in
let len = min (length l) (length m) in
List.combine (cut l len) (cut m len)
combine (cut l len) (cut m len)
;;
(* 4 *)
......@@ -51,4 +48,14 @@ let rec lookup l key =
;;
(* Challenge *)
let rec coin_permutation l n =
let perms coin l =
match coin with
| i when i < n -> 1 + (coin_permutation l (n - coin))
| i when i = n -> 1
| _ -> 0
in
match l with
| [] -> 0
| h::t -> (perms h t) + (coin_permutation t n)
;;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment