src/problems/revc.lisp @ 6088027147e1

Do HAMM, add fancy stream/string management
author Steve Losh <steve@stevelosh.com>
date Thu, 01 Nov 2018 21:54:39 -0400
parents 4cad0eb1a700
children 11df545d1a41
(in-package :rosalind)

;; In DNA strings, symbols 'A' and 'T' are complements of each other, as are 'C'
;; and 'G'.
;;
;; The reverse complement of a DNA string s is the string sc formed by reversing
;; the symbols of s, then taking the complement of each symbol (e.g., the
;; reverse complement of "GTCA" is "TGAC").
;;
;; Given: A DNA string s of length at most 1000 bp.
;;
;; Return: The reverse complement sc of s.

(define-problem revc (data string)
    "AAAACCCGGT"
    "ACCGGGTTTT"
  (flet ((dna-complement (base)
           (case base
             (#\A #\T)
             (#\T #\A)
             (#\G #\C)
             (#\C #\G)
             (t base)))) ; newline etc
    (map-into data #'dna-complement data)
    (nreverse data)))