; paint-by numbers ; The object of _Paint By Numbers_ is to discover which cells should be colored blue and which should be colored white. Initially, all squares are grey, indicating that the correct colors are not known. The lists of numbers to the left and above the grid are your clues to the correct color of each square. Each list of numbers specifies the pattern of blue squares in the row beside it or the column below it. Each number indicates the length of a group of blue squares. For example, if the list of numbers beside the first row is "2 3" then you know that there is a contiguous block of two blue squares followed by a contiguous block of three blue squares with at least one white square between them. The label does not tell you where the blue squares are, only their shapes. The trick is to gather as much information as you can about each row, and then use that information to determine more about each column. Eventually you should be able to fill in the entire puzzle, but problems are feasible for which there is no solution or for which there is more than one solution. In these cases the solver shown below leaves a number of cells gray. (this text has been copied from PLT200) (require-library "synrule.ss") ; omit for PLT200 (require-library "pretty.ss") ; or (require (file ...)) for PLT200 ; co-lambda ; prepares a coroutine. see doc below (define-syntax co-lambda (syntax-rules (name return/resume stop ()) ((co-lambda () formaldec body ...) (let ((self #f) (r/r #f) (xstop #f)) (co-lambda ((name self) (return/resume r/r) (stop xstop (lambda (x) x))) formaldec body ...))) ((co-lambda ((name self)) formaldec body ...) (let ((r/r #f) (xstop #f)) (co-lambda ((name self) (return/resume r/r) (stop xstop (lambda (x) x))) formaldec body ...))) ((co-lambda ((return/resume r/r)) formaldec body ...) (let ((self #f) (xstop #f)) (co-lambda ((name self) (return/resume r/r) (stop xstop (lambda (x) x))) formaldec body ...))) ((co-lambda ((stop xstop ...)) formaldec body ...) (let ((self #f) (r/r #f)) (co-lambda ((name self) (return/resume r/r) (stop xstop ...)) formaldec body ...))) ((co-lambda ((name self) (return/resume r/r)) formaldec body ...) (let ((xstop #f)) (co-lambda ((name self) (return/resume r/r) (stop xstop (lambda (x) x))) formaldec body ...))) ((co-lambda ((return/resume r/r) (name self)) formaldec body ...) (let ((xstop #f)) (co-lambda ((name self) (return/resume r/r) (stop xstop (lambda (x) x))) formaldec body ...))) ((co-lambda ((name self) (stop xstop ...)) formaldec body ...) (let ((r/r #f)) (co-lambda ((name self) (return/resume r/r) (stop xstop ...)) formaldec body ...))) ((co-lambda ((stop xstop ...) (name self)) formaldec body ...) (let ((r/r #f)) (co-lambda ((name self) (return/resume r/r) (stop xstop ...)) formaldec body ...))) ((co-lambda ((return/resume r/r) (stop xstop ...)) formaldec body ...) (let ((r/r #f)) (co-lambda ((name self) (return/resume r/r) (stop xstop ...)) formaldec body ...))) ((co-lambda ((name self) (stop xstop ...) (return/resume r/r)) formaldec body ...) (co-lambda ((name self) (return/resume r/r) (stop xstop ...)) formaldec body ...)) ((co-lambda ((stop xstop ...) (name self) (return/resume r/r)) formaldec body ...) (co-lambda ((name self) (return/resume r/r) (stop xstop ...)) formaldec body ...)) ((co-lambda ((stop xstop ...) (return/resume r/r) (name self)) formaldec body ...) (co-lambda ((name self) (return/resume r/r) (stop xstop ...)) formaldec body ...)) ((co-lambda ((return/resume r/r) (name self) (stop xstop ...)) formaldec body ...) (co-lambda ((name self) (return/resume r/r) (stop xstop ...)) formaldec body ...)) ((co-lambda ((return/resume r/r) (stop xstop ...) (name self)) formaldec body ...) (co-lambda ((name self) (return/resume r/r) (stop xstop ...)) formaldec body ...)) ((co-lambda ((name self) (return/resume r/r) (stop xstop)) formaldec body ...) (co-lambda ((name self) (return/resume r/r) (stop xstop (lambda (x) x))) formaldec body ...)) ((co-lambda ((name self) (return/resume r/r) (stop xstop stop-proc)) formaldec body ...) (lambda z ; co-routine-maker (letrec ((alive? #t) ; true as long as not finished (ystop stop-proc) ; evaluate stop-proc once (coroutine ; the dynamic part of the coroutine (lambda () (call/cc (lambda (exit) ; exit always points to the most recent caller (letrec ((r/r (lambda (result) (set! exit (call/cc (lambda (cc) (exit (list result cc))))))) (xstop (lambda x (exit (list (apply ystop x))))) (self (lambda formaldec body ...))) ; the proc proper (xstop (apply self z)))))))) ; call proc with implied stop (lambda x ; static part of the coroutine: calls the dynamic part (if (null? x) (let* ; normal call ((result+cc (coroutine)) ; call dynamic part of coroutine (result (car result+cc)) ; it returns (value) or (value cc) (cc (cdr result+cc))) (if (null? cc) ; return via stop (begin (set! ystop #f) ; allow gc to collect stop-proc (set! alive? #f) ; drop dead (set! coroutine ; disable dynamic part of coroutine (lambda () (error "coroutine" self "called after having finished")))) (set! coroutine (lambda () (call/cc (car cc))))) ; return via r/r result) ; return result to caller alive?))))))) ; in case of info call ; (for ((var from to [step]) ...) body ...) --> void ; forms a nested fortran like loop. ; each var must be a variable. ; each from, to and step specification must yiels a number ; in deeper levels of the loop, the from, to and step specifiers may refer to the vars of higher levels. (define-syntax for (syntax-rules (()) ((for () body ...) (begin body ...)) ((for ((var from to) control ...) body ...) (let* ((f from) (t to) (b (<= f t)) (s (if b 1 -1)) (p (if b > <))) (do ((pvar f (+ pvar s))) ((p pvar t)) (let ((var pvar)) (for (control ...) body ...))))) ((for ((var from to step) control ...) body ...) (let* ((f from) (t to) (s step) (p (if (>= s 0) > <))) (do ((pvar f (+ pvar s))) ((p pvar t)) (let ((var pvar)) (for (control ...) body ...))))))) ; (while (condition) body ...) --> void ; (while (var condition) body ...) --> void ; forms a while-loop. if a var is specified, it is locally bound to the computed condition before each iteration. (define-syntax while (syntax-rules () ((while (var condition) body ...) (do ((var condition condition)) ((not var)) (begin body ...))) ((while (condition) body ...) (do () ((not condition)) (begin body ...))))) (define grey 'g) (define white 'w) (define blue 'b) (define unknown 'u) ; (solve list-of-list-of-numbers list-of-list-of-numbers) --> ; list-of-list-of-symbols ; the symbols are: ; w for white ; b for blue ; g for unsolved elements (define solve (lambda (collists rowlists) (repaint (do ((board (make-board (length collists) (length rowlists)) ((lambda (x) (show (repaint x)) x) (transpose (map update-row-or-column rowlists (transpose (map update-row-or-column collists board)))))) (old #f board)) ((equal? board old) board))))) ; (update-row-or-column list-of-numbers row-or-column) --> row-or-column ; the following method is used ; an iteration is made along all rows and all column. this iteration is itself repeated until no more cells have been changed. for a row or a column, say an array, the following method is used: all possible patterns are formed matching the list of numbers of the array nd not conflicting with the info already in the array. if in all patterns a corresponding element is blue/white, then the corresponding element of the array is known to be blue/white. the patterns are formed by partitioning the total number of white elements in as many terms as required, ie one more than the number of blue subarrays. at least one white element is required between two blue subarrays. these required white elements are not in the numbr to b partitioned. the partitions are computed by a coroutine that returns every next partition every time it is called. it returns false if no more partitions can be found. in order to prevent the partitioner to descend in recursion on subpartitions that already conflict with the array, a filter is maintained. the filter accepts a term of the partition and checks whether or no the term conflicts with the present info in the array. if a conflict is detected, the filter returns #f to the partitioner, else it returns a new filter, which is to be used or the next term. (define update-row-or-column (lambda (nlist array) (let* ((nr-of-elements (length array)) (nr-of-blue-blocks (length nlist)) (check-array (make-list nr-of-elements unknown)) ; check-array will contain ; b for elements that are definitely blue, ; w for elements that are definitely white, ; u for elements for which this is not yet known ; g for elements whose color cannot yet be known (p (make-partitioner (- nr-of-elements (+ (apply + nlist) (max 0 (sub1 nr-of-blue-blocks)))) (add1 nr-of-blue-blocks) (make-filter nr-of-elements nlist array)))) (while (pm (p)) (let ((test (make-pattern pm nlist))) (if (andmap (lambda (t e) (or (eq? t e) (eq? e grey))) test array) (set! check-array (map checker check-array test))))) (show (map (lambda (x) (if (eq? x unknown) grey x)) check-array))))) ; (make-partitioner n ncel filter) --> coroutine ; n : number to be partioned ; ncel : number of terms n must be partitioned to ; filter : a procedure accepting a term and returning #f if the term is not acceptable or a new filter for the next term if the current term is acceptable. the filter is used to avoid unnecessary sub-partitions (define make-partitioner (co-lambda ((return/resume return) (stop stop (lambda (x) #f))) (n ncel filter) (if (< ncel 2) (if (filter n) (return (list n))) (for ((i 0 n)) (let ((newfilter (filter i))) (if newfilter (let ((p (make-partitioner (- n i) (sub1 ncel) newfilter))) (while (pm (p)) (return (cons i pm)))))))))) ; (make-filter nr-of-blue-blocks numberlist row-or-column) --> procedure ; the procedure accepts a term of the partion, and checks wether or not this term fits the current contents of a row-or-column of the board. returns a filter for the next term if the current term is acceptable, or #f if the current term is not acceptable (define make-filter (lambda (nr-of-elements nlist array) (lambda (n) (let ((test (append (make-list n white); n whites (make-list (if (null? nlist) 0 (car nlist)) blue); the blue elements (make-list ; zero or one white if more blue blocks are to follow (cond ((null? nlist) 0) ((null? (cdr nlist)) 0) (else 1)) white)))) (if (match test array) (if (null? nlist) (lambda (n) #f) ; return new filter or #f (make-filter (sub1 nr-of-elements) (cdr nlist) (list-tail (length test) array))) #f))))) ; (match list list) --> boolean ; matches a test array against a row or column of the board (define match (lambda (test array) (or (null? test) (null? array) (and (or (eq? (car test) (car array)) (eq? (car array) grey)) (match (cdr test) (cdr array)))))) ; (make-pattern numberlist numberlist) --> row-or-column ; make-pattern accepts a partition and the numbers of a row or column and returns a list of the symbols w and b (define make-pattern (lambda (p nlist) (if (null? nlist) (make-list (car p) white) (if (null? (cdr nlist)) (append (make-list (car p) white) (make-list (car nlist) blue) (make-list (cadr p) white)) (append (make-list (car p) white) (make-list (car nlist) blue) (list white) (make-pattern (cdr p) (cdr nlist))))))) (define list-tail (lambda (n lst) (if (zero? n) lst (if (null? lst) lst (list-tail (sub1 n) (cdr lst)))))) ; (make-list number value) --> list of specified length all elements initialized to contain the specified value (define make-list (lambda (len fill) (if (zero? len) '() (cons fill (make-list (sub1 len) fill))))) ; (make-board list-of-list-of-numbers list-of-list-of-numbers) --> list-of-list-of-symbols (all symbols initially being grey (define make-board (lambda (nrow ncol) (if (zero? nrow) '() (cons (make-list ncol grey) (make-board (sub1 nrow) ncol))))) ; (checker symbol symbol) --> symbol ; given a symbol of a test array and a symbol of a row or column the checker returns the symbol that should be replaced in the test array (define checker (lambda (c p) (case c ((u) p) ((g) grey) ((w) (if (eq? p white) white grey)) ((b) (if (eq? p blue) blue grey))))) ; (repaint board) --> list of strings ; in the result, each string repesents a row ; in the string we have the following characters only ; letter X for a blue element ; space for a white element ; asterix for an unsolved element (define repaint (lambda (x) (map (lambda (r) (list->string (map (lambda (e) (case e ((g) #\*) ((b) #\X) ((w) #\ ))) r))) x))) ; (transpose list-of-lists-of equal-lengths) --> list-of-list-of-equal-lengths ; transposes a recangular list of lists (define transpose (lambda (x) (apply map list x))) ; (show x ... y) --> y ; returns the value of its last argument ; pretty prints each element (define show (lambda x (cond ((null? x) '()) ((null? (cdr x)) (pretty-print (car x)) (car x)) (else (pretty-print (car x)) (apply show (cdr x)))))) #|***************************************************************************** macro:: co-lambda (co-lambda ([(name )]/[(return/resume )]/[(stop [])]) ...1) --> procedure with arguments as described by : symbol : symbol : symbol $stop-proc$ : one-argument proc. default: identity : declaration of formal arguments as in a lambda clause as far as provided, , and must be distinct symbols. in this doc $expr$ is the value of . is the expression rather than its value. square brackets indicate optional elements. slashes indicate that elements may appear in arbitrary order ------------------------------------------------------------------------------- definitions co-lambda produces a coroutine-maker. a coroutine-maker is a proc that produces a coroutine. a coroutine is a thunk with an internal state. ------------------------------------------------------------------------------- calling a coroutine () --> value : normal call ( ...1) --> boolean : info-call ------------------------------------------------------------------------------- normal call () in principle the value of a normal call is $( (begin ...1))$. however, the flow of control may be altered by means of $r/r$ and $stop$. in the body, the formal arguments of the are bound to the operands given to the coroutine-maker. as far as not shielded by the , the symbols , and are bound to procs provided by co-lambda: $name$ a proc with arguments as specified in the . it can be used for recursion. at top level the arguments of the formaldec are bound to the operands given to the coroutine-maker. ( ) --> void use ( ) to return the value $result$ to the form that called the coroutine. the evaluation of the body is suspended. if the coroutine is called again (normal call), the evaluation of the body is resumed after $r/r$ is updated such as to return to the most recent caller (normal call) of the coroutine. ( ) --> never returns use ( ) to return to the most recent caller (normal call) of the coroutine. $stop$ calls $stop-proc$ with operand $value$ and returns the value returned by $stop-proc$ to the most recent caller of the coroutine. $stop$ disables the coroutine. a subsequent normal call of the coroutine results in an error-exception. $stop$ is implicitly called upon normal return from the top level evaluation of the body, with the value of the body as the operand. is evaluated once while the coroutine is formed, ie. while the coroutine-maker is called. it is evaluated in an environment in which the formal arguments of the are bound to the operands given to the coroutine-maker. the symbols , and are not yet bound. the body is allowed to assign new values to the formal arguments of the formaldec and to the symbols , and . the flow controller does not bother. it is not sensitive to these reassignments, because it does not refer to these symbols. if the inner proc destructs the value of , and/or , then it can no longer use these symbols for their proper purposes, but it can still finish normally. after normal end of the body, the flow controller always uses the original $stop-proc$ and returns to the most recent caller (normal call) of the coroutine. the body is allowed to call continuations for temporal or final exits that bypass the flow controller. eg: a coroutine called by another coroutine may use the return/resume of the calling coroutine. ------------------------------------------------------------------------------- info calls ( ...1) the arguments are evaluated, but their values are ignored. as long as $stop$ has not been called, an info call yields #t. once $stop$ has been called, the info call forever yields #f. ------------------------------------------------------------------------------- usage the use of a coroutine requires three steps. a schematized example: 1: define a coroutine-maker (define coroutine-maker (co-lambda ((name ) (stop ) (return/resume )) ...)) 2: define a coroutine (define coroutine (coroutine-maker ...)) with arguments as required by the 3: call the coroutine until it has finished (coroutine) --> first $value$ returned with ( ) (coroutine 'still-alive?) --> assume #t (coroutine) --> second $value$ returned with ( ) ... (coroutine 'still-alive?) --> assume #t (coroutine) --> assume this to be returned with ( ) or by normal completion of the body (coroutine 'still-alive?) --> #f; the coroutine has finished if the final value returned by means of $stop$ or by normal completion, can be distinguished from all other values, the info calls are not necessary. eg the final value can be #f if this value is never returned via return/resume: 3: call the coroutine until it returns a sign that it has finished (coroutine) --> first $value$. assume it to be true (coroutine) --> second $value$. assume it to be true ... (coroutine) --> #f : the coroutine has finished it does no longer permit normal calls ***************************************************************************|# (solve '((3) (3) (2) () ) '((3) (2) (1) ())) (solve (quote ((2) (1 1) (4) (2 1) (3 1) (8) (8) (7) (5) (3))) (quote ((1) (2) (1 6) (9) (6) (5) (5) (4) (3) (4)))) (solve '((4 1) (7 2) (3 6) (2 3) (2 4) (5) (7) (7) (3 3) (2 2 2) (1 2 4) (3 2 2) (2 3 2) (3 2) (4 2) (3 2) (2 2) (2 1 1) (3 2) (3 2) (3 1) (3 2) (5 3 1 4) (7 2 1 7) (8 3 1 10) (7 2 1 10) (2 3 2 2 4 4) (2 2 2 2 3) (4 4 5) (13)) '((3) (5) (3 2) (4 1) (5 1) (5 2) (4 1) (3 1 1) (1 2 1) (3 2) (7 5 3) (2 5 2 11 3) (4 4 2 10 1 2) (8 2 4 3 5 1) (2 4 1 4 2 2 1 1) (4 4 3 2 4 2 1) (4 5 3 3 4 2) (4 7 5 2) (1 1 3 5 1) (1 1 5 1) (2 4 2) (2 5) (5) (3) (3))) (solve '((16 14) (13 12) (10 10) (9 1 3 2 1 9) (9 1 1 1 1 1 1 1 8) (9 1 1 1 1 1 3 7) (8 1 1 1 3 1 1 1 2) (8 2 1 1 1 1 1) (8 1) (7 2 4 2) (7 2 2 4 1 1 5) (6 2 3 1 1 3 3) (5 3 4 3 2 1) (5 2 2 2 2 2 1 1) (5 2 2 2 2 1 4 5) (1 2 6 4 6) (2 4 1 6) (2 3 2 5 7) (3 2 1 9 7) (3 3 9 8) (7 7 8) (4 9) (2 1 11) (4 4 12) (14 14)) '((16 3) (15 3) (15 3 2) (15 5 2) (15 5 1) (12 2 1) (11 3 1) (9 4 2) (6 9 2) (3 9 3) (2 4 2) (2 4 5 1) (2 1 5 1) (1 4 4 2 1 1) (1 1 3 2 3) (1 5 5 3) (1 5 3) (4 3) (1 1 1 2 3) (5 1 3 4) (1 2 1 4) (1 5 1 1 1 3 1) (1 1 3 1 2 1) (2 4 1 2) (2 1 2 3) (3 1 3 3) (4 1 2 1 4) (5 1 1 1 6) (6 3 1 8) (7 10) (6 1 11) (6 1 11) (6 2 11) (7 3 11) (7 17))) (solve (quote (() () (4 4) (6 6) (8 8) (9 9) (9 9) (8 8) (7 6 7) (5 8 5) (10) (13) (14) (14) (18) (2 14 2) (2 14 2) (2 16 2) (2 2 12 2 2) (1 2 10 2 1) (4 3 2 3 4) (2 2 6 2 2) (4 2 2 2 4) (1 2 1 2 1 2 1) (2 1 2 2 2 1 2) (2 2 2 2 2) (2 2 2 2) (2 2 2 2) (2 2 2 2) (30))) (quote ((1) (3 1) (5 3 3 1) (7 2 3 2 1) (7 2 3 2 1) (8 2 2 2 2 1) (8 2 2 2 3) (7 1 2 2) (6 7 3 1) (5 8 2 2 1) (12 2 1) (12 2 1) (14 3) (12 1 2) (18 1) (18 1) (12 1 2) (14 3) (12 2 1) (12 2 1) (5 8 2 2 1) (6 6 3 1) (7 1 2 2) (8 2 2 2 3) (8 2 2 2 2 1) (7 2 3 2 1) (7 2 3 2 1) (5 3 3 1) (3 1) (1)))) (solve (quote ((1) (8) (6 1 2) (5 2 2) (5 2 2) (5 3 3) (5 4 3) (2 1 1 5 1 3) (2 1 2 5) (1 1 1) (1) (1) (1) (1) (1) (1) (1) (1) (1 1) (3))) (quote ((1) (3) (3) (5) (5) (5) (4 1 2) (3 1 1) (2 2 1) (2 3 6) (1 10) (8) (1 3) (2 1) (2 1) (3 1) (6) (4) (3) (2)))) ; the following problems have been copied from PLT200 (solve (quote ((10 8) (9 6) (5 5 5) (6 7 4) (6 9 3) (4 2 2 1 1 3) (5 3 2 1 1 3) (5 2 2 1 2 2) (4 2 2 1 2 2) (5 3 7 2) (5 1 2 1 3) (2 1 1 7 3) (3 1 6 4) (3 1 8 3) (2 6 5 2) (3 4 3 2) () (2 3 3 3 3 1) (2 3 3 3 3 1) ())) (quote ((16 2) (16 2) (11 2 1) (12 1 2) (5 2 2 2 2) (2 2 5 2) (2 5 2) (2 6 2 2) (2 4 2 2 2) (1 3 4 2) (8 3) (8 4 2) (1 3 1 5 2) (1 14 2) (2 2 1 5) (3 6 1 2 2) (4 3 1 2) (7 4 2) (16) (16 2)))) (solve (quote ((7 7) (5 5) (3 3) (2 2) (2 2) (1 2 2 1) (1 4 4 1) (2 1 2 1) (2 2) () (2 2) (4 4) (1 1 4 1 1) (1 2 1 1 2 1) (1 3 3 1) (2 4 2) (2 2) (3 3) (5 5) (7 7))) (quote ((7 7) (5 5) (3 3) (2 1 2) (2 3 2) (1 2 1 1 1) (1 4 4 1) (2 1 1 1) (2 4) (1 1) (1 1) (2 4) (4 1 1) (1 2 1 4 1) (1 2 1 1 1) (2 3 2) (2 1 2) (3 3) (5 5) (7 7)))) (solve (quote ((3 2 2 1) (1 2 2 2) (1 1) (1 1) (1 2 1) (1 2 1 3) (1 1 3 1 1) (1 1 2 1 1) (1 2 2 3) (1 1 1) (1 1 3) (2 1 3) (5 1 3) (1 5 1 3) (3 4 4) (4 1 4) (5 6) (7) (5) (4))) (quote ((15) (1 2 1) (2 2 1 2) (1 1 1 1 1) (1 1 1 2 1) (1 1 1 2) (1 1 1 1) (1 3 1 1) (1 1 2 2 1) (1 1 1 1 2) (1 3 1 3) (6 12) (1 1 4) (3 5) (5) (8) (8) (5) () ()))) (solve (quote (() (7 2 3) (8 2 4) (2 2 4 1 1) (2 2 4 4) (2 2 1 1 3) (2 2 4 1 2) (5 2 1 1 1 2) (4 5 3 2) () () (1 1 2 3 2) (1 1 2 4 3) (1 1 4 1 1 2) (1 1 4 4 2) (1 1 1 1 1 3 2) (1 1 1 4 1 2 2) (5 1 1 1 6) (3 2 3 5) ())) (quote ((2 7) (2 2 2) (4 2 4) (2 4 2) (2 2 7) (2 1) (8 6) (8 4 1) (2 1 4 1) (2 1 6) (6 1) (4 1 8) (4 1 2 2) (6 2 3) (1 3 3) (8 2) (2 2 2 2) (2 3 4 2) (3 3 2 4) (2 2 2)))) (solve (quote ((1 1 1) (2 1 2) (1 2 1) (1 1 1) (2 2 2) (1 1 1) (1 1 1) (2 2 2) (1 1 1) () (11) (2 2 3) (2 4 1) (4 5 1) (17 1) (15 3) (13) (11) (2 7 2) (17))) (quote ((1) (4 2) (6 1) (2 2 5 1) (4 2 1 5 1) (4 1 6) (1 6) (3 1 6) (3 2 1 6) (4 1 6) (1 6) (2 4 1 6) (4 2 1 5 1) (2 5 1) (6 1) (4 1) (3 1) (2 2 2) (1 1 1) (5)))) (solve (quote (() (4 4) (2 3 3 2) (1 2 2) (2 1 1 2) (2 2) (2) (4) (4) (4) (6) (6) (2) () (9) (11) (3 3) (2 5 3) (2 3 3) ())) (quote (() (2) (2 1) (1 2) (1 2 2) (2 2 2) (1 3) (2 2 2) (2 5 2 1) (7 2 2) (7 2 2) (2 5 2 2) (2 2 2 1) (1 2) (2 3) (1 2 3) (1 2 3) (2 2) (1 1) ()))) (solve (quote ((20) (1 3 3 2) (3 4 1 1) (3 4 1) (3 4 1) (3 5 2) (3 6 3) (3 7 4) (3 8 5) (1 7 6) (20) (20) (1 4 3 5 3) (1 3 3 3 3) (1 2 4 1 4) (1 1 1 5 5) (1 2 6 6) (1 3 6 6) (1 4 6 6) (20))) (quote ((20) (1 7 2 1) (1 7 3 5) (1 4 4) (1 7 5 3) (1 7 6 2) (12 1) (20) (2 15) (1 14) (1 5 6) (1 5 5) (2 5 4) (3 5 1) (2 5 4) (1 5 5) (1 5 6) (1 14) (2 15) (20)))) (solve (quote ((1) (8) (6 1 2) (5 2 2) (5 2 2) (5 3 3) (5 4 3) (2 1 1 5 1 3) (2 1 2 5) (1 1 1) (1) (1) (1) (1) (1) (1) (1) (1) (1 1) (3))) (quote ((1) (3) (3) (5) (5) (5) (4 1 2) (3 1 1) (2 2 1) (2 3 6) (1 10) (8) (1 3) (2 1) (2 1) (3 1) (6) (4) (3) (2)))) (solve (quote (() (9) (1 1 1 1 3) (9 2) (1 3 1) (2 1 1 1 3) (2 1 1 1 2) (1 1 3) (9 3) (1 1 1 4 9) (12 1 1 1 1) (1 12) (3 1 1) (2 1 1 1 1 2) (2 1 1 2 1 2) (2 1 1) (14) (2 1 1 1 1 1 1) (12) ())) (quote ((3 3) (1 1 2 1 1) (3 2 3) (1 1 1 1) (10) (1 1 1 1 4) (3 2 10) (1 1 3 1 2) (11 2 1 1) (1 1 3 3) (4 2 7 1) (1 7 3) (6 1 2 1 1) (3 1 3) (1 1 1 1) (10) (1 1 1 1) (3 2 3) (1 1 2 1 1) (3 3)))) (solve (quote (() (1 1) (2 2) (3 3) (4 4) (4 4) (4 4) (4 4) (4 4) (3 3) (5) (3) (5) (11) (2 1 1 2) (2 1 1 2) (1 2 2 1) (1 2 2 1) (4 4) ())) (quote (() (4) (4 4) (4 2 1) (4 2 1) (4 1 2) (4 1 2) (4 5) (6) (4) (6) (4 5) (4 1 2) (4 1 2) (4 2 1) (4 2 1) (4 4) (4) () ()))) (solve (quote ((4 3) (3 5 2) (2 9 1) (1 11) (1 13) (1 2 1) (8 5) (9 5) (3 3 1 1) (4 4 2 2) (9 5) (9 5) (5 2 4) (6 5) (13) (4 4) (1 4 4 1) (2 8 1) (3 5 3) (5 7))) (quote ((5) (3) (2) (1 5) (11 4) (2 10 3) (3 2 8 2) (3 2 8 1) (4 2 9 1) (4 6 2 3) (12 1 2) (12 1 2) (4 2 3) (3 14) (3 2 9 1) (2 2 7 2) (4 7 2) (1 6 4) (2 1) (3 1)))) (solve (quote (() () (6) (2 2 3) (1 1 1 3 1) (1 2 1) (2 3 1) (3 4 1) (3 3 1) (4 3 4 1) (5 9) (6 7) (7 4) (6 3) (7 4) (7 3) (6 3) (6) () ())) (quote (() () (6) (10) (1 10) (1 8) (2 7) (1 7) (1 1 6) (3 2 4) (2 2 3) (1 1 1 2 1) (10 2) (9 3) (1 11) (1 7) (2 5) (6) () ()))) (solve (quote ((4 4) (3 2 1 1 1 1 1 3) (2 2 1 1 1 1 2) (2 1 1 1 1 1 1 2 2) (1 1 1 1 1 1 1 1 1 2) (1 1 1 1 1 2 1 2) (1 1 1 1 1 1 1 2 2) (2 13 3) (3 4) (3 4) (3 4) (3 4) (3 4) (4 5) (4 5) (5 6) (6 7) (8 9) (9 10) (20))) (quote ((20) (4 13) (2 1 1 12) (1 2 1 1 7) (2 1 2 5) (1 1 1 4) (1 1 2 3) (1 1 1 1 3) (1 2 2) (1 1 1 1 1) (1 1 2 2) (1 1 1 1 3) (1 2 3) (1 1 1 1 4) (1 2 1 5) (1 1 2 7) (1 5 12) (2 13) (20) (20))))