Created
December 14, 2018 00:38
-
-
Save nloadholtes/4ac40268476635bb43abc92c092299ed to your computer and use it in GitHub Desktop.
IntrepidSubduedDatasets created by nloadholtes - https://repl.it/@nloadholtes/IntrepidSubduedDatasets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Enter your code here. Read input from STDIN. Print output to STDOUT | |
;; | |
;; | |
;; Sample data | |
;; | |
;;4 | |
;;0 0 | |
;;0 1 | |
;;1 1 | |
;;1 0 | |
(import '(java.io BufferedReader StringReader)) | |
(require '[clojure.string :as str]) | |
(defn make-ints [x] | |
(mapv | |
#(Integer/parseInt %) | |
(str/split x #" ")) | |
) | |
;; Doing first? | |
(defn distance [x y] | |
(println "X: " x) | |
(println "Y: " y) | |
(Math/sqrt | |
(+ | |
(Math/pow (- (x 1) (x 0) ) 2) | |
(Math/pow (- (y 1) (y 0) ) 2) | |
)) | |
) | |
(defn startit [] | |
(def test-data (BufferedReader. (StringReader. "4\n0 0\n0 1\n1 1\n1 0\n"))) | |
(def data (line-seq test-data)) | |
;;(def data (line-seq (java.io.BufferedReader. *in*))) | |
(def total-points (first data)) | |
(def data (rest data)) ;; Stored as newline seperated strings | |
(def start-point (first data)) | |
(def data (nthrest data 1)) | |
(println "total points:" total-points) | |
(println "data:" data) | |
(println "Starting point:" start-point) | |
(def data (concat data start-point)) | |
(println "Real data: " data) | |
data | |
;; Expected answer: 4 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment