Created
August 10, 2017 21:13
-
-
Save sheki/881569a80596a5c50dd768d6bf7f9b9b to your computer and use it in GitHub Desktop.
rickandmorty
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
(defn square | |
"square of a number" | |
[a] | |
(* a a)) | |
(defn square_sum | |
"sum of square of 2 numbers" | |
[a b] | |
(+ (square a) (square b))) | |
(defn square_sum_equal | |
"sum squares if equal" | |
[a b] | |
(if (> a b) (square_sum a a) | |
(square_sum a b))) | |
(defn largest_square_sum | |
"takes 3 numbers and returns the square of the largest 3" | |
[a b c] | |
(cond | |
(= a b) (square_sum_equal a c) | |
(= a c) (square_sum_equal a b) | |
(= b c) (square_sum_equal b a) | |
(and (> a b) (> a c) (> b c)) (square_sum a b) | |
(and (> a b) (> a c) (> c b)) (square_sum a c) | |
(and (> b a) (> b c) (> a c)) (square_sum a b) | |
(and (> b a) (> b c) (> c a)) (square_sum b c) | |
(and (> c a) (> c b) (> b a)) (square_sum b c) | |
(and (> c a) (> c b) (> a b)) (square_sum a c))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment