Skip to content

Instantly share code, notes, and snippets.

@hikoz
Created May 29, 2015 05:53
Show Gist options
  • Select an option

  • Save hikoz/a1331464559b744b4668 to your computer and use it in GitHub Desktop.

Select an option

Save hikoz/a1331464559b744b4668 to your computer and use it in GitHub Desktop.

Revisions

  1. hikoz created this gist May 29, 2015.
    13 changes: 13 additions & 0 deletions 1hour-5.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    (->>
    (let [[h & t] (range 1 10)]
    (reduce
    (fn [l h]
    (mapcat (fn [[a b s]]
    [[(conj a b) h (str s " + " h)]
    [(conj a b) (- h) (str s " - " h)]
    [a (bigint (str b h)) (str s h)]])
    l))
    [[[] h h]]
    t))
    (filter #(= (apply + (second %) (first %)) 100))
    (map #(nth % 2)))