Logged In: YES

user_id=377168

;; Joerg Hoehles version: only positives: halves size and

doubles speed

;; based on Bruce Hoult's posting to cll "Cute Little

Problem"

(defun nines ()

(declare (optimize (speed 3) (safety 1)))

(let ((nums (make-array 10

:initial-contents (loop repeat 10 collect

(make-hash-table :size 450

:rehash-size 21.0s0)))))

(setf (gethash 9 (svref nums 1)) t)

(loop for n from 2 below 10 as h = (svref nums n) do;;

start [*]

(loop for p from 1 to (floor n 2) do

(loop for a being the hash-keys of (svref

nums p) do

(loop for b being the hash-keys of

(svref nums (- n p)) do

(setf (gethash (+ a b) h) t

(gethash (* a b) h) t

(gethash (abs (- a b)) h)

t)

unless (zerop b) do (setf

(gethash (/ a b) h) t)

unless (zerop a) do (setf

(gethash (/ b a) h) t))));; end [*]

collect (hash-table-size h)

collect ;; no format, just return result

(loop for i from 1 unless (gethash i h) do

(return i)))))