Last active
August 29, 2015 14:17
-
-
Save ka8725/30242197b455c1b9c02d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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