Skip to content

Instantly share code, notes, and snippets.



Created Oct 27, 2009
What would you like to do?
(ns main.test
(:use clojure.contrib.str-utils
[ :only (spit)]))
(def input "Source.txt")
(def output "red.txt")
(defn remove-newlines
"Removes all \ns from the string."
(apply str (remove #(= % \newline) s)))
(defn get-nums [s]
(last (.split s ">")))
(defn find-nums [s]
(let [parted (re-partition #"<font color=\"red\">[0-9]+" s)]
(map get-nums (map first (partition 1 2 (rest parted))))))
(defn spit-nums [s]
(spit output (apply str (interpose "\n" s))))
(defn main []
(spit-nums (find-nums (remove-newlines (slurp input)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment