;;; hw6.clj       YOUR-NAME-HERE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(def ACIDS
  {"UUU" "F" "UUC" "F" "UUA" "L" "UUG" "L" "UCU" "S" "UCC" "S" "UCA" "S" "UCG" "S"
   "UAU" "Y" "UAC" "Y" "UAA" "*" "UAG" "*" "UGU" "C" "UGC" "C" "UGA" "*" "UGG" "W"
   "CUU" "L" "CUC" "L" "CUA" "L" "CUG" "L" "CCU" "P" "CCC" "P" "CCA" "P" "CCG" "P"
   "CAU" "H" "CAC" "H" "CAA" "Q" "CAG" "Q" "CGU" "R" "CGC" "R" "CGA" "R" "CGG" "R"
   "AUU" "I" "AUC" "I" "AUA" "I" "AUG" "M" "ACU" "T" "ACC" "T" "ACA" "T" "ACG" "T"
   "AAU" "N" "AAC" "N" "AAA" "K" "AAG" "K" "AGU" "S" "AGC" "S" "AGA" "R" "AGG" "R"
   "GUU" "V" "GUC" "V" "GUA" "V" "GUG" "V" "GCU" "A" "GCC" "A" "GCA" "A" "GCG" "A"
   "GAU" "N" "GAC" "N" "GAA" "E" "GAG" "E" "GGU" "G" "GGC" "G" "GGA" "G" "GGG" "G"})

;;; binary tree functions
(defn root [btree]
  (nth btree 0))

(defn left-subtree [btree]
  (nth btree 1))

(defn right-subtree [btree]
  (nth btree 2))

(defn height [tree]
  (if (empty? tree)
    0
    (inc (max (height (left-subtree tree)) (height (right-subtree tree))))))

;;; COIN "class" using protocol & interface
(defprotocol CoinInterface
  (flip [this])
  (num-flips [this]))

(deftype Coin [options ^:unsynchronized-mutable flips]
  CoinInterface
  (flip [this]
    (do (set! flips (inc flips)) (if (< (rand) 0.5) (first options) (second options))))
  (num-flips [this] flips))

(defn make-coin
  ([] (Coin. [:HEADS, :TAILS] 0))
  ([options] (Coin. options 0)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;      ADD YOUR CODE BELOW HERE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

