Skip to content

Instantly share code, notes, and snippets.

@ka8725
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ka8725/30242197b455c1b9c02d to your computer and use it in GitHub Desktop.
Save ka8725/30242197b455c1b9c02d to your computer and use it in GitHub Desktop.
#lang racket
(require rackunit)
;; BEGIN
(define (sqr x)
(* x x))
(define (max x y)
(if (> x y) x y))
(define (min x y)
(if (< x y) x y))
(define (sum-of-squares-of-top-two x y z)
(+
(sqr (max x y))
(sqr (max z (min x y)))))
;; END
(check-equal? (sum-of-squares-of-top-two 1 2 3) 13)
(check-equal? (sum-of-squares-of-top-two 3 4 2) 25)
(check-equal? (sum-of-squares-of-top-two 5 3 4) 41)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment