Open
Description
My first attempt (see below) to solve this exercise passed all tests but was faulty. It didn't raise an exception when the first argument of hamming-distance
has a smaller length than the latter. So I suggest to add a test.
#lang racket
(define (distance eq lst1 lst2 [acc 0])
(cond
[(empty? lst1) acc]
[(eq (first lst1) (first lst2)) (distance eq (rest lst1) (rest lst2) acc)]
[(distance eq (rest lst1) (rest lst2) (add1 acc))]))
(define (hamming-distance strand1 strand2)
(distance char=? (string->list strand1) (string->list strand2)))
Metadata
Metadata
Assignees
Labels
No labels