Sha256: e1b5b516073ddd9781f1021484b07c3d9aabc974e8a98a1e9c332645e7226af8

Contents?: true

Size: 647 Bytes

Versions: 396

Compression:

Stored size: 647 Bytes

Contents

;;; hamming.el --- Hamming (exercism)

;;; Commentary:

;;; Code:

(require 'cl)

(defun hamming-distance (dna1 dna2)
  "Determine number of mutations between DNA strands DNA1 and DNA2."
  (if (= (length dna1) (length dna2))
      (let ((dl1 (split-string-and-unquote dna1 ""))
            (dl2 (split-string-and-unquote dna2 "")))
        (loop with cnt = 0
              for x in dl1
              for y in dl2
              when (not (string= x y))
              do
              (setq cnt (1+ cnt))
              finally
              return cnt))
    (error "Strands are of different lengths")))


(provide 'hamming)
;;; hamming.el ends here

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.179 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.178 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.177 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.176 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.175 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.174 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.173 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.172 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.171 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.170 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.169 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.167 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.166 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.165 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.164 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.163 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.162 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.161 tracks/elisp/exercises/hamming/example.el
trackler-2.2.1.160 tracks/elisp/exercises/hamming/example.el