Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns lisp.core
- (:gen-class)
- (:require [clojure.string :as s]))
- (defn -main
- "I don't do a whole lot ... yet."
- [& args]
- (println "Hello, World!"))
- (map inc (range 10))
- ;; => (1 2 3 4 5 6 7 8 9 10)
- (def f
- (as-> (slurp "/Users/tommy/programming/pscsta/student_data/fezr.in") x
- (s/split x #"\s+")
- (rest x)
- (map read-string x)))
- (s/join ", " f)
- ;; => "1, 258, 304, 2, 1014, 1019, 1017, 1024, 4, 3, 7, 6, 9, 502, 502, 3512, 3519, 2, 2384, 2407, 1756, 1766, 3, 684, 702, 702, 721, 784, 789"
- (defn read [[head & rest]]
- (if head
- (cons (take (* 2 head) rest)
- (read (drop (* 2 head) rest)))
- nil))
- (defn printn [s]
- (for [x s]
- (println x)))
- (println "---")
- (range 1 5)
- (printn) (for [x (read f)]
- (count
- (distinct
- (flatten
- (map (fn [[a b]] (range a (inc b)))
- (partition 2 x))))))
- ;; => (47 11 16 35 44)
Add Comment
Please, Sign In to add comment