blob: 310f6ace35387a91774cdc139da926065b5963a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
let () = print_endline "hello"
let read_file_into_lists filename =
let in_channel = open_in filename in
let rec read_lines left right =
try
let line = input_line in_channel in
match String.split_on_char '\t' line with
| [l; r] ->
read_lines (int_of_string l :: left) (int_of_string r :: right)
| _ -> failwith "invalid line format"
with End_of_file ->
close_in in_channel;
(List.rev left, List.rev right)
in read_lines [] []
let () =
let left_nums, right_nums = read_file_into_lists "d01.input" in
Print.printf "Left numbers: %s\n" (String.concat " " (List.map string_of_int left_nums));
Print.printf "Right numbers: %s\n" (String.concat " " (List.map string_of_int right_nums));;
|