Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Scheme Programming Language

8 kweenz


X-No-Archive:

i woz lookn thru SICP nd i cin diz 8 kweenz puzzl!! lol!!!

http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-15.html#%_sec_2.2.3

da nx wk i wrk on exasize 2.42 nd 2.43. itz hard nd stuff cuz
no 1 eva sez da answer nd i think exasize 2.43 izza trick kwestshun
nd alelson nd sussman just wanna b kool like mean cats r kool!!!!

i think that exasize 2.42 izza exponential process and da mods 4
exasize 2.43 izza exponential process to. der iz no difference in
da speed. cud som 1 plz confirm dis

thats all i haf to say so i guess ill go hang my self with my socks

bye bye

;; my soln to 2.42
;; SICP (2ed.) pg 125
(define (queens board-size)
  (define (queen-cols k)
    (if (= k 0)
        (list empty-board)
        (filter
         (lambda (positions) (safe? k positions))
         (flatmap
          (lambda (rest-of-queens)
            (map (lambda (new-row)
                   (adjoin-position new-row k rest-of-queens))
                 (enumerate-interval 1 board-size)))
          (queen-cols (- k 1))))))
  (queen-cols board-size))

;; list of prospective board positions for new queen
(define (adjoin-position new-row k rest-of-queens)
  (append rest-of-queens (list (list new-row k))))

; a predicate to determine if two queens threaten each other
; (from Lisp 3ed, Winston and Horn pg289)
(define (threat? i j a b) ; One queen at (i,j) other at (a,b)
  (or (= i a) ; same row
      (= j b) ; same column
      (= (- i j) (- a b)) ; SW-NE diagonal
      (= (+ i j) (+ a b)))) ; NW-SE diagonal

; a predicate to tell us if the position (n,m) for the new
; queen is safe (from Winston and Horn pg289)
(define (conflict? n m board)
  (cond ((null? board) board)
        ((threat? n
                  m
                  (car (car board))
                  (cadr (car board)))
         #t)
        (else (conflict? n m (cdr board)))))

(define (safe? k positions)
  (let ((nk-pair (car (last-pair positions))) ; new queen
        (k-minus-1-board (except-last-pair positions))) ; other queens
    (or (= k 1) ; no conflicts if only one queen
        (not (conflict? (car nk-pair) k k-minus-1-board)))))

(define empty-board ())

(define (filter predicate sequence)
  (cond ((null? sequence) sequence)
        ((predicate (car sequence))
         (cons (car sequence)
               (filter predicate (cdr sequence))))
        (else (filter predicate (cdr sequence)))))

(define (flatmap proc seq)
  (fold-right append () (map proc seq)))

(define (enumerate-interval low high)
  (if (> low high)
      ()
      (cons low (enumerate-interval (+ low 1) high))))
;; end of my soln

nullius.fil@gmail.com writes:
> i woz lookn thru SICP nd i cin diz 8 kweenz puzzl!! lol!!!

> http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-15.html#%_sec_2.2.3

> da nx wk i wrk on exasize 2.42 nd 2.43. itz hard nd stuff cuz
> no 1 eva sez da answer nd i think exasize 2.43 izza trick kwestshun
> nd alelson nd sussman just wanna b kool like mean cats r kool!!!!

> i think that exasize 2.42 izza exponential process and da mods 4
> exasize 2.43 izza exponential process to. der iz no difference in
> da speed. cud som 1 plz confirm dis

S vs vlz n rpns, l vdrt mx crr n ngls crrctmnt!

--
__Pascal Bourguignon__                     http://www.informatimago.com/

HANDLE WITH EXTREME CARE: This product contains minute electrically
charged particles moving at velocities in excess of five hundred
million miles per hour.

Pascal Bourguignon wrote:
> nullius.fil@gmail.com writes:
>> i woz lookn thru SICP nd i cin diz 8 kweenz puzzl!! lol!!!

> S vs vlz n rpns, l vdrt mx crr n ngls crrctmnt!

s vs pvz lr cc vs pvz prgrmmr n frtrn

Ben Goetter <ben.goet@gmail.com> writes:
> Pascal Bourguignon wrote:
>> nullius.fil@gmail.com writes:
>>> i woz lookn thru SICP nd i cin diz 8 kweenz puzzl!! lol!!!

>> S vs vlz n rpns, l vdrt mx crr n ngls crrctmnt!

> s vs pvz lr cc vs pvz prgrmmr n frtrn

Trs bn! ;-)

--
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.

Ben Goetter writes:
> Pascal Bourguignon wrote:
>> nullius.fil@gmail.com writes:
>>> i woz lookn thru SICP nd i cin diz 8 kweenz puzzl!! lol!!!

>> S vs vlz n rpns, l vdrt mx crr n ngls crrctmnt!
> s vs pvz lr cc vs pvz prgrmmr n frtrn

Just a small nitpick: insiders spell it simply as "FTN" (note the
capitalisation) :-).

Isn't amazing how humour can transform disgusting in enjoyable?  Maybe
that's just its definition.

--
Emlio C. Lopes                            Ich leb und wei nit wie lang,
Munich, Germany                            ich stirb und wei nit wann,
                                           ich fahr und wei nit wohin,
                 (Martinus von Biberach)   mich wundert, dass ich frhlich bin!

Emilio Lopes wrote:
> Isn't amazing how humour can transform disgusting in enjoyable?  Maybe
> that's just its definition.

I think that an element of the disgusting may actually be a
necessary part of humor.

Even so-called "clean" jokes usually involve at least one
character so utterly deprived of intellect or socialization
as to be disgusting to us.

                                Bear

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc