            (replace \. \/))))
 
 (defn- title->fn [title]
-  (.toLowerCase (cs/replace title #"[^\w]" "-")))
+  (.toLowerCase (cs/replace title #"\W" "-")))
 
 (defn- drop-replace-me [fn]
   (let [t (slurp fn)

;; Allow something that might have quotes to live in a string.
(defn- enquote [s]
  (cs/replace s  "\"" "\\\""))
;; XXX - Format too?
(defn- expand-prob [prob tests]
  (->>
   (map #(cs/replace % #"\b__\b" (str prob "-solution")) tests)
   (map #(cs/replace % "\\r?\\n" "\n")) ; XXX \r isn't getting replaced.
   (map #(cs/join " " ["(is" % "\"" (enquote %) "\")"]))
   (cs/join "\n")))



(def fore-url "http://4clojure.com/api/problem/")

(defn get-prob [n]
  (let [req (http/get (str fore-url n) {:as :json
                                        :throw-exceptions false})]
    (if (= (req :status) 200)
      ;; we don't need scores here and it's polluting debugging logs
      (dissoc (req :body) :scores))))

(defn fore-prob [project prob-num]
  (if-let [prob (get-prob prob-num)]
    (try
      (let [title (prob :title)]
        (if-not (write-tests project prob) ; spit returns nil by default hence
                                           ; the inversion of logic.
          (println (str "Problem \"" title "\" added!"))
          (println (str "Problem \"" title "\" has already been added!"))))
      (catch Exception e
        (println (str "Failed setting problem " prob-num ": " (.getMessage e)))
        (shutdown-agents)))
    (println "Cannot get problem" prob-num "(HTTP status != 200).")))
