src/problems/spec.lisp @ a95ed046cc2c
NWCK
| author | Steve Losh <steve@stevelosh.com> |
|---|---|
| date | Fri, 05 Aug 2022 00:16:11 -0400 |
| parents | cd3fc11e3298 |
| children | 7fcd748a4f00 |
(defpackage :rosalind/spec (:use :cl :rosalind :losh :iterate)) (in-package :rosalind/spec) (defparameter *input* "3524.8542 3710.9335 3841.974 3970.0326 4057.0646") (defparameter *output* "WMQS") (defun roughly= (a b &optional (epsilon (* 0.000001d0 (min a b)))) (< (abs (- a b)) epsilon)) (defun find-amino-acid (weight) (rassocar weight u:*monoisotopic-masses* :test #'roughly=)) (define-problem spec (data stream) *input* *output* (let* ((*read-default-float-format* 'double-float) (prefix-weights (u:read-lines data :key #'parse-float:parse-float)) (weights (mapcar #'- (rest prefix-weights) prefix-weights)) (result (mapcar #'find-amino-acid weights))) (string-join "" result)))