Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defparameter KEY "ljoxqyyw")
- (defun countbits (ba)
- (reduce #'+ ba))
- (defun getrow (rown)
- (hash (concatenate 'string KEY "-" (write-to-string rown))))
- (defun total-bits ()
- (let ((bitc 0))
- (dotimes (i 128 bitc)
- (incf bitc (countbits (getrow i))))))
- (defun get-bitmap (nrows)
- (make-array (list nrows 128)
- :initial-contents
- (loop
- for i upto (1- nrows)
- collect (getrow i))))
- (defun colorize ()
- (let ((bitmap (get-bitmap 128))
- (colorized (make-array '(128 128) :initial-element 'nil))
- (groups 0))
- (labels ((color (x y)
- (when (and (= 1 (aref bitmap x y))
- (not (aref colorized x y)))
- (setf (aref colorized x y) groups)
- (color (if (/= 0 x) (1- x) x) y)
- (color (if (/= 127 x) (1+ x) x) y)
- (color x (if (/= 0 y) (1- y) y))
- (color x (if (/= 127 y) (1+ y) y)))))
- (dotimes (i 128 (values colorized groups))
- (dotimes (j 128)
- (when (and (= 1 (aref bitmap i j))
- (not (aref colorized i j)))
- (incf groups)
- (color i j)))))))
Advertisement
Advertisement
Advertisement
RAW Paste Data
Copied
Advertisement