OFFSET
0,13
COMMENTS
LINKS
A. Karttunen, Table of n, a(n) for n = 0..2055
PROG
(MIT Scheme:)
(define (gentree-balance l) (let ((r (reverse l))) (let loop ((i 0) (j (- (length l) 1)) (l l) (r r) (z 0)) (cond ((= i j) (+ z (if (zero? z) (gentree-balance (car l)) 0))) ((> i j) z) (else (loop (+ i 1) (- j 1) (cdr l) (cdr r) (+ z (- (count-pars (car r)) (count-pars (car l))))))))))
(define (count-pars a) (cond ((not (pair? a)) 0) (else (+ 1 (count-pars (car a)) (count-pars (cdr a))))))
CROSSREFS
KEYWORD
sign
AUTHOR
Antti Karttunen, Dec 21 2008
STATUS
approved