src/problems/lexv.lisp @ e3aefcbf364c
Cache Uniprot results on the filesystem This will make only the first `(run-tests)` on a given computer take forever, instead of the first `(run-tests)` of a given Lisp session. It will also hopefully make the Uniprot folks not hate me.
| author | Steve Losh <steve@stevelosh.com> |
|---|---|
| date | Fri, 24 Jan 2020 23:05:16 -0500 |
| parents | 2735aa6aab79 |
| children | (none) |
(defpackage :rosalind/lexv (:use :cl :rosalind :losh :iterate)) (in-package :rosalind/lexv) (defparameter *input* "D N A 3") (defparameter *output* "D DD DDD DDN DDA DN DND DNN DNA DA DAD DAN DAA N ND NDD NDN NDA NN NND NNN NNA NA NAD NAN NAA A AD ADD ADN ADA AN AND ANN ANA AA AAD AAN AAA ") (define-problem lexv (data stream) *input* *output* (let* ((alphabet (remove #\space (read-line data))) (n (read data)) (string (make-string n))) (with-output-to-string (s) (recursively ((n n) (i 0)) (unless (zerop i) ;; The empty string *is* first, lexicographically, but I don't think ;; they accept it in the answer for some reason. (write-string string s :end i) (terpri s)) (unless (zerop n) (map nil (lambda (ch) (setf (aref string i) ch) (recur (1- n) (1+ i))) alphabet))))))