Created
December 11, 2017 22:51
-
-
Save tommy-mor/6cd7028d4cb45dd71290c065073e1d36 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.