Exercise 5.1.5: (back)

;; check-color: symbol symbol symbol symbol -> symbol
;; (check-color target1 target2 guess1 guess2)
;; Example: (check-color 'red 'yellow 'red 'yellow) -> 'Perfect
;; Example: (check-color 'red 'yellow 'white 'yellow) -> 'OneColorAtCorrectPosition
;; Example: (check-color 'red 'yellow 'yellow 'blue) -> 'OneColorOccurs
;; Example: (check-color 'red 'yellow 'green 'blue) -> 'NothingCorrect
(define (check-color target1 target2 guess1 guess2)
  (cond
    [(and (symbol=? target1 guess1)(symbol=? target2 guess2)) 'Perfect]
    [(or (symbol=? target1 guess1)(symbol=? target2 guess2)) 'OneColorAtCorrectPosition]
    [(or (symbol=? target1 guess2)(symbol=? target2 guess1)) 'OneColorOccurs]
    [else 'NothingCorrect]))

    
;; Tests
> (check-color 'red 'yellow 'red 'yellow)
'Perfect

> (check-color 'red 'yellow 'white 'yellow)
'OneColorAtCorrectPosition

> (check-color 'red 'yellow 'yellow 'blue)
'OneColorOccurs

> (check-color 'red 'yellow 'green 'blue)
'NothingCorrect