(define (weird x)
  (cond ((= x 1) 1)
        ((even? x) (weird (/ x 2)))
        (else (weird (+ (* x 3) 1)))))

(define (depth-weird x)
  (define (iter-weird n depth)
    (cond ((= n 1) depth)
          ((even? n) (iter-weird (/ n 2) (+ depth 1)))
          (else (iter-weird (+ (* 3 n) 1) (+ depth 1)))))
  (iter-weird x 0))

(define (weird-table min max)
  (define (iter-table min table)
    (cond (( min (+ max 1)) (display ""))
        ((display min) (display "\t") (display (depth-weird min)) (newline)))
          (iter-table (+ min 1) table))
  (iter-table min (display"")))