Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(defn euclidian-distance [[[x1 y1] [x2 y2]]]
(Math/sqrt (+ (Math/pow (- x1 x2) 2) (Math/pow (- y1 y2) 2))))

(def points (repeatedly (read-string (read-line))
#(map read-string (.split (read-line) " "))))

(println (->> (partition 2 1 points points)
(map euclidian-distance)
(reduce +)))
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(defn quadrilateral-area [[[x1 y1] [x2 y2]]]
(* (- (* x1 y2) (* x2 y1)) 0.5))

(def points (repeatedly (read-string (read-line))
#(map read-string (.split (read-line) " "))))

(println (->> (partition 2 1 points points)
(map quadrilateral-area)
(reduce +)))