7fd1feb477de

LEXF
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 10 Nov 2018 16:14:15 -0500
parents 23151d9021cf
children 5d71b5f0dfb5
branches/tags (none)
files rosalind.asd src/problems/lexf.lisp

Changes

--- 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")
--- /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))))))