Bayesian Card Game
(def NUM_CARDS 6)
(defn starting-odds []
(repeat NUM_CARDS 1))
(defn hint-less [odds]
(map * odds (range NUM_CARDS)))
(defn hint-more [odds]
(map * odds (reverse (range NUM_CARDS))))
(defn norm [odds]
(let [total (reduce + odds)]
(map #(/ % total) odds)))
(defn plot [odds]
(doseq [[chance card]
(map vector odds (range NUM_CARDS))]
(println (str card
": "
(apply str (repeat
(Math/floor (* 30 chance))
"#"))))))
(->
(starting-odds)
(hint-more)
(hint-less)
(hint-less)
(hint-less)
(hint-less)
(hint-less)
(norm)
(plot))