Commits

Anonymous committed 8ffed69

adde nchoose k function

Comments (0)

Files changed (1)

     !lines
 ;;
 
+let timer f x =
+  let t0 = Sys.time() in
+  let res = f x in
+  let t1 = Sys.time() in
+  Printf.printf "time take %f sec \n" (t1 -. t0);
+  res
+    
+
+
+
+let  n_choose_k n k = 
+  let rec choose lo = 
+    function
+      |[] -> [[]]
+      |x::xs as cs -> if lo = 1 then List.map (fun a -> [a]) cs
+	              else 
+	                List.map (fun cs -> x::cs) (choose (lo-1) xs)
+			  
+  in
+  choose k n
+
+	
+
 let bits_to_int nbits s  = 
   let rec acc_bits hi lo shift acc = 
     if hi = lo then acc
       
 let fname =  Sys.argv.(1);;
 
-IntSet.iter (fun x -> print_int x; print_newline ()) (snd (read_input fname))
+ ignore (timer read_input fname)
 ;;