(use util.combinations) ;; compute the most efficient way to cut item-list out of the ;; target-length pieces of wood (define target-length '(210 210 270)) ;; NOTE this list yields 12! = 479001600 permutations... ;;(define item-list '(61 61 61 61 69 69 69 69 28 28 28 28)) (define item-list '(61 61 69 69 28 28)) (define search-space (permutations item-list)) ;; 1 2 3 4 5 0 (1) ;; 2 3 4 5 1 (1 3) ;; 3 4 5 3 (1 3 6) ;; 4 5 6 (1 3 6 10) ;; 5 10 (1 3 6 10 15) (define (running-sum ls) (let ((sum 0) (r '())) (until (null? ls) (set! sum (+ sum (car ls))) (set! r (cons sum r)) (set! ls (cdr ls))) (reverse r))) (dolist (solution search-space) (print solution) (print (running-sum solution)))