Skip to content

Instantly share code, notes, and snippets.

@stibear
Created July 11, 2014 13:18
Show Gist options
  • Save stibear/02b9e59380bed6ce5da2 to your computer and use it in GitHub Desktop.
Save stibear/02b9e59380bed6ce5da2 to your computer and use it in GitHub Desktop.
(use srfi-1)
(define acgt '(#\a #\c #\g #\t))
(define (create n)
(map list->string
(let loop ((n n))
(if (zero? n)
(list '())
(append-map
(lambda (x)
(map (lambda (y) (cons x y))
(loop (- n 1))))
acgt)))))
(define (solve lst)
(filter (lambda (str) (string-scan str "aag"))
lst))
(solve (create 4))
;=> ("aaag" "aaga" "aagc" "aagg" "aagt" "caag" "gaag" "taag")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment