[racket] Challenge: Game of life in 140 chars

From: David Van Horn (dvanhorn at ccs.neu.edu)
Date: Sun Feb 19 23:06:31 EST 2012

On 2/19/12 10:52 PM, Jeremiah Willcock wrote:
> Here's a 136-character version (after unnecessary spaces are removed):

(define (life s)
   (let* ((a bitwise-and)
          (s (bitwise-ior (* s #x111000101000111/10000000) s)))
     (a (* (a (- -1 s) (* s 4)) 3/32)
        (/ (- (expt 8 48) 1) 15))))

The let* isn't needed, right?  In which case, let will do... in which 
case, λ will do.  That gets you down to 131:

(define (life s)
   ((λ (a s)
      (a (* (a (- -1 s) (* s 4)) 3/32)
         (/ (- (expt 8 48) 1) 15)))
    bitwise-and
    (bitwise-ior (* s #x111000101000111/10000000) s)))

David


Posted on the users mailing list.