Skip to content

Commit

Permalink
214-intermediate: converted the native array to a hashmap before retu…
Browse files Browse the repository at this point in the history
…rning it
  • Loading branch information
Amith George authored and Amith George committed May 15, 2015
1 parent 44eb22c commit 4ec0260
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/rdp/214_intermediate_arr.clj
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
(for [^long y (range (:height canvas))
^long x (range (:width canvas))]
[x y]))
colorCounts))
(zipmap (range) colorCounts)))

(defn- solve
[input-file]
Expand All @@ -94,9 +94,10 @@
(defn- solve-arr
[input-file]
(let [input (read-input-file input-file)
colorCounts (visible-color-frequencies-arr input)]
(doseq [line (map vector (range) (seq colorCounts))]
(println (line 0) (line 1)))))
color-map (visible-color-frequencies-arr input)
sorted (sort-by key (remove #(zero? (val %1)) color-map))]
(doseq [line sorted]
(println (key line) (val line)))))

(defn -main
([] (-main "0" "false"))
Expand Down

0 comments on commit 4ec0260

Please sign in to comment.