Skip to content

Instantly share code, notes, and snippets.

@lamida
Created April 26, 2014 10:37
Show Gist options
  • Save lamida/11316810 to your computer and use it in GitHub Desktop.
Save lamida/11316810 to your computer and use it in GitHub Desktop.
;;; my solution
(define (min a b)
(if (< a b) a b))
(define (min3 a b c)
(min a (min b c)))
(define (square x)(* x x))
(define (sum-of-squares a b)
(+ (square a)(square b)))
(define (large-two-square a b c)
(cond ((= a (min3 a b c)) (sum-of-squares b c))
((= b (min3 a b c)) (sum-of-squares a c))
((= c (min3 a b c)) (sum-of-squares a b))
))
;;; solution from other
(define
(largest-two-square-sum x y z)
(if (= x (larger x y))
(sum-of-squares x (larger y z))
(sum-of-squares y (larger x z))
)
)
(define
(larger x y)
(if (> x y) x y)
)
(define
(sum-of-squares x y)
(+ (square x) (square y))
)
(define
(square x)
(* x x)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment