let hamming s t =
  if String.length s <> String.length t then -1
  else begin
    let d = ref 0 in
    for i = 0 to String.length s - 1 do
      if s.[i] <> t.[i] then d := !d + 1
    done;
    !d
  end

;;

hamming "karolin" "kathrin" + hamming "1011101" "1001001" + hamming "abc" "abcd"
