Hacker News new | ask | show | jobs
by talloaktrees 3878 days ago
I'd love to see some example code for doing this.

I'm trying to implement it in Kotlin and am curious how it would compare.

1 comments

  (def mymap {"asd" 1 "qwe" 2 "rtz" 3 "foo" 4 "bar" 5 "quz" 6 "bnm" 7})

  (let [ints (->> (filter (comp odd? count key)  mymap)
                                   (sort-by (comp int last first))
                                   (map (fn [[s i]]
                                          (+ (count s) i))))]
                     (reduce + 0 (map * ints (reverse ints))))
Gives me 341