let rec read_mountains n = let mountainh = int_of_string (input_line stdin) in if n < 1 then [] else mountainh :: (read_mountains (n-1)) ;; let c = ref 0 in prerr_endline "Start" ; (** game loop *) while true do c := !c + 1 ; string_of_int !c |> fun str -> "tour = " ^ str |> prerr_endline ; let mountains = read_mountains 7 in let target = mountains |> List.mapi (fun idx value -> (value, idx)) |> List.sort (fun (value1, idx1) (value2, idx2) -> Pervasives.compare value1 value2 ) |> List.hd |> fun (idx, value) -> idx in let target_str = string_of_int target in prerr_endline ("target = " ^ target_str); print_endline target_str ; (); done;