Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Enter your code here. Read input from STDIN. Print output to STDOUT
- ;
- (require '[clojure.string :as str])
- (defn dis [a b]
- (Math/sqrt (+ (Math/pow (- (first b) (first a)) 2) (Math/pow (- (second b) (second a)) 2)))
- )
- (defn split-to-double [input]
- (->> (str/split input #"\s")
- (map #(Double/parseDouble %))
- (into [])
- )
- )
- (defn get-points-vector [number-of-points]
- (->> #(split-to-double (read-line))
- (repeatedly number-of-points)
- (into [])
- )
- )
- (let [points (Integer/parseInt (read-line))
- points_vector (get-points-vector points)
- ]
- (loop [x points_vector r 0]
- (if (empty? (rest x))
- (do
- (println (+ r (dis (first x) (first points_vector) )))
- )
- (recur (rest x) (+ r (dis (first x) (second x))))
- )
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement