Skip to content

Instantly share code, notes, and snippets.

@fcanas
Created May 25, 2015 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fcanas/bafc60e2d8ee5489264d to your computer and use it in GitHub Desktop.
Save fcanas/bafc60e2d8ee5489264d to your computer and use it in GitHub Desktop.
Your Ride is Here
(ns your-ride-is-here-test
[:require [clojure.test :refer :all]])
(defn decode [e]
(mod (reduce (fn [total, value] (* total value)) 1 (map (fn [a] (- (int a) 64)) (seq e))) 47)
)
(defn ride [group, comet]
(if (= (decode group) (decode comet)) "GO" "STAY")
)
(def test-data
(shuffle [
["COMETQ","HVNGAT","GO"],
["STARAB","USACO","STAY"],
["EARTH","LEFTB","GO"],
["PULSAR","VENUS","STAY"],
["KANSAS","UTAH","STAY"],
["APPLE","URSA","GO"],
["MSFT","MARS","STAY"],
["PLUTO","BKHOLE","STAY"],
["COWSBC","RIGHT","GO"],
["DRKMTR","SNIKER","STAY"]]))
(deftest basic-test
(doseq [[group comet result] test-data]
(testing (str "Group " group " and comet " comet)
(is (= (ride group comet) result) (str "should " result)))))
(run-tests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment