Forráskód Böngészése

init solution day 8

AbderFaiz 5 hónapja
szülő
commit
a8b48bd184
3 módosított fájl, 47 hozzáadás és 0 törlés
  1. 3 0
      8/dune
  2. 22 0
      8/solve_1.ml
  3. 22 0
      8/solve_2.ml

+ 3 - 0
8/dune

@@ -0,0 +1,3 @@
+(executables
+ (names  solve_1 solve_2)
+ (libraries base stdio str))

+ 22 - 0
8/solve_1.ml

@@ -0,0 +1,22 @@
+open Stdio
+(* open Str *)
+
+let input_info = 
+  let rec one_string inp nb_rows nb_columns = 
+    let line = In_channel.input_line In_channel.stdin in
+    match line with
+    | None -> (inp, (nb_rows, nb_columns))
+    | Some x -> one_string (inp ^ x) (nb_rows + 1) (String.length x)
+  in one_string "" 0 0
+;;
+
+let grid = (fst input_info);;
+let nb_rows = (fst (snd input_info));;
+let nb_columns =(snd (snd input_info));;
+
+let solve = 0
+;;
+
+let () = printf "%d %d\n\n%s" nb_rows nb_columns grid;
+printf "Total: %d\n" solve;;
+         

+ 22 - 0
8/solve_2.ml

@@ -0,0 +1,22 @@
+open Stdio
+(* open Str *)
+
+let input_info = 
+  let rec one_string inp nb_rows nb_columns = 
+    let line = In_channel.input_line In_channel.stdin in
+    match line with
+    | None -> (inp, (nb_rows, nb_columns))
+    | Some x -> one_string (inp ^ x) (nb_rows + 1) (String.length x)
+  in one_string "" 0 0
+;;
+
+let grid = (fst input_info);;
+let nb_rows = (fst (snd input_info));;
+let nb_columns =(snd (snd input_info));;
+
+let solve = 0
+;;
+
+let () = printf "%d %d\n\n%s" nb_rows nb_columns grid;
+printf "Total: %d\n" solve;;
+