# HG changeset patch # User Steve Losh # Date 1541884455 18000 # Node ID 7fd1feb477de833ee67dc44bbaf243c5de9bc2b9 # Parent 23151d9021cf1413942cd76a627aaac2ab1409b4 LEXF diff -r 23151d9021cf -r 7fd1feb477de rosalind.asd --- a/rosalind.asd Thu Nov 08 22:06:36 2018 -0500 +++ b/rosalind.asd Sat Nov 10 16:14:15 2018 -0500 @@ -41,6 +41,7 @@ (:file "iev") (:file "iprb") (:file "lcsm") + (:file "lexf") (:file "lia") (:file "mprt") (:file "mrna") diff -r 23151d9021cf -r 7fd1feb477de src/problems/lexf.lisp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/problems/lexf.lisp Sat Nov 10 16:14:15 2018 -0500 @@ -0,0 +1,42 @@ +(in-package :rosalind) + +(defparameter *input-lexf* + "A C G T +2") + +(defparameter *output-lexf* + "AA +AC +AG +AT +CA +CC +CG +CT +GA +GC +GG +GT +TA +TC +TG +TT +") + + +(define-problem lexf (data stream) + *input-lexf* + *output-lexf* + (let* ((alphabet (sort (remove #\space (read-line data)) #'char<)) + (n (read data)) + (string (make-string n))) + (with-output-to-string (s) + (recursively ((n n) + (i 0)) + (if (zerop n) + (progn (write-string string s) + (terpri s)) + (map nil (lambda (ch) + (setf (aref string i) ch) + (recur (1- n) (1+ i))) + alphabet))))))