Created
March 5, 2017 17:58
-
-
Save chrisguitarguy/c681d9575cc8fd77c9d7c3f51535d6f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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