Skip to content

Instantly share code, notes, and snippets.

@kolharsam
Last active May 11, 2020
Embed
What would you like to do?
Cassidy's Interview Question - 10/5/20
;; Simple to implement I guess the real problem is of double/float precision
;; Will be updating once I learn more about those concepts within Clojure
(defn is-in-golden-ratio?
"Returns true if the pair of numbers are in the golden ratio"
[x y]
(let [x-y-ratio (quot x y)
greatest (max x y)
sum-ratio (quot (+ x y) greatest)]
(= x-y-ratio sum-ratio)))
(is-in-golden-ratio? 2 5)
;; => false
(is-in-golden-ratio? 1 0.618)
;; true
(is-in-golden-ratio? 61.77 38.22)
;; true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment