Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun validate-dp (password words)
- (let ((v (make-array (1+ (length password)) :initial-element nil)))
- (setf (aref v 0) t)
- (loop for i upto (length password) do
- (loop for w in words do
- (let ((lw (length w)))
- (if (and (<= lw i) (string= w (subseq password (- i lw) i)) (elt v (- i lw)))
- (setf (aref v i) w)))))
- (if (aref v (- (length v) 1))
- (coerce (remove nil (remove T v)) 'list)
- nil)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement