Skip to content

Instantly share code, notes, and snippets.

@chase-lambert
Last active November 16, 2023 03:09
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 chase-lambert/c4e09bf2c6da035c93d20ff2257236d8 to your computer and use it in GitHub Desktop.
Save chase-lambert/c4e09bf2c6da035c93d20ff2257236d8 to your computer and use it in GitHub Desktop.
rendezvous with cassidoo challenge: 23-11-06
(ns score-word-game
(:require [clojure.test :refer [deftest is]]))
(defn score-word-game [word-list letter-scores]
(let [word-score (fn [word]
(let [letter-score (reduce + (map letter-scores word))]
(* (count word) letter-score)))]
(apply max-key word-score word-list)))
(deftest score-word-game-test
(let [word-list ["apple" "banana" "cherry" "date" "fig"]
letter-scores (zipmap "abcdefghijklmnopqrstuvwxyz" (range 1 27))]
(is (= "cherry" (score-word-game word-list letter-scores)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment