let string_1_list_of_string x = String.to_seq x |> List.of_seq |> List.map (String.make 1);; let array_of_string s = string_1_list_of_string s |> Array.of_list;; let replace_int s ar = let s = string_1_list_of_string s in let rec replace_p result s = match (s) with | [] -> result |> List.rev |> String.concat "" | hd::tr -> try replace_p (ar.(int_of_string hd) :: result) tr with | Failure _ -> replace_p (hd::result) tr in replace_p [] s;; let () = let a = array_of_string (read_line ()) in let s = read_line () in replace_int s a |> print_string; print_newline ();;