Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
Created March 5, 2017 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisguitarguy/c681d9575cc8fd77c9d7c3f51535d6f8 to your computer and use it in GitHub Desktop.
Save chrisguitarguy/c681d9575cc8fd77c9d7c3f51535d6f8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env boot
(require '[clojure.string :as string])
(defn- str->int [s]
(Integer/parseInt s))
(defn- make-heights [s]
(let [is (map str->int (string/split s #"\s+"))
cs (map #(char (+ 97 %)) (range 26))]
(zipmap cs is)))
(defn- word-area [heights word]
(let [ca (char-array word)
hs (map heights ca)]
(* (count word) (apply max hs))))
(defn -main [& args]
(let [heights (make-heights (read-line))]
(println (word-area heights (read-line)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment