Files
rose-ash/lib
giles df6efeb68e
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s
ocaml: phase 5.1 hamming.ml baseline (Hamming distance, 3+2-1 = 4)
Counts position-wise differences between two strings of equal
length; returns -1 sentinel for length mismatch:

  let hamming s t =
    if String.length s <> String.length t then -1
    else
      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

Three test cases:
  'karolin'  vs 'kathrin'    3   (positions 2,3,4)
  '1011101'  vs '1001001'    2   (positions 2,4)
  'abc'      vs 'abcd'      -1   (length mismatch)
  sum                        4

91 baseline programs total.
2026-05-09 18:27:50 +00:00
..