src/problems/perm.lisp @ 1d0852c279f7

Add auto-module ASDF to save typing.  Thanks, jackdaniel
author Steve Losh <steve@stevelosh.com>
date Sat, 15 Dec 2018 16:56:57 -0500
parents 11df545d1a41
children 2735aa6aab79
(in-package :rosalind)

(defparameter *input-perm* "3")

(defparameter *output-perm* "6
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1")


(define-problem perm (data string)
    *input-perm*
    *output-perm*
  (let* ((n (parse-integer data))
         (count (factorial n))
         (perms (permutations (alexandria:iota n :start 1))))
    (format nil "~D~%~{~A~^~%~}"
            count
            ;; sort to ensure consistent output for the unit test
            (sort (mapcar (curry #'str:join " ") perms) #'string<))))

;; (problem-perm "3")
;; (solve perm)