-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
(def words | ||
(->> "resources/ospd3.txt" | ||
slurp | ||
clojure.string/split-lines)) | ||
|
||
(defn filter-word-count [n] | ||
(set (filter (comp (partial = n) count) words))) | ||
|
||
(def fives (filter-word-count 5)) | ||
(def sixes (filter-word-count 6)) | ||
|
||
(def lingo-five (group-by first fives)) | ||
|
||
(def lingo-five-count-by-first-letter | ||
(mapv #(vector (key %) (count (val %))) lingo-five)) | ||
|
||
(reverse (sort-by second lingo-five-count-by-first-letter)) | ||
|
||
(def all-fives-frequencies (frequencies (apply str fives))) | ||
|
||
(reverse (sort-by val all-fives-frequencies)) | ||
|
||
(def fives-percentages | ||
(reverse (sort-by last (mapv #(vector (key %) (val %) (float (/ (val %) (count (apply str fives))))) all-fives-frequencies)))) | ||
|
||
(def scoresheet | ||
(apply hash-map (flatten (map (juxt first last) fives-percentages)))) | ||
|
||
(defn calc-score [word] | ||
(->> word | ||
(map char) | ||
(map scoresheet) | ||
(apply +) | ||
(* 100) | ||
Math/floor | ||
int)) | ||
|
||
; highest scores | ||
(take 20 (reverse (sort-by second (map (juxt identity calc-score) fives)))) | ||
|
||
; calculate highest score for each starting letter | ||
|
||
(group-by first (mapv (juxt first identity calc-score) fives)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; https://www.npr.org/2023/05/07/1174544511/sunday-puzzle-seeing-double | ||
; Think of part of the human body whose name is a compound word like | ||
; fingertip or toenail. Add an N and rearrange the result to get another | ||
; part of the body whose name is also a compound word. What body parts are these? | ||
|
||
(defn clean-up-word [word] | ||
(clojure.string/replace (clojure.string/lower-case word) #"[^a-z]" "")) | ||
|
||
(def body-parts | ||
(->> "resources/body_parts.txt" | ||
slurp | ||
clojure.string/split-lines | ||
(mapv clean-up-word))) | ||
|
||
(defn subanagram? [base compare] | ||
(let [base-frequencies | ||
(merge | ||
(zipmap "abcdefghijklmnopqrstuvwxyz" (repeat 26 0)) | ||
(frequencies base)) | ||
compare-frequencies | ||
(frequencies compare)] | ||
(every? #(<= (compare-frequencies %) | ||
(base-frequencies %)) | ||
(keys compare-frequencies)))) | ||
|
||
(def answer | ||
(for [b body-parts | ||
:let [f (filter (fn [x] (and (= (count x) (dec (count b))) | ||
(subanagram? b x))) body-parts)] | ||
:when (and (not (empty? f)))] | ||
[b f])) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
https://www.npr.org/2023/04/30/1172903467/sunday-puzzle-palindrome-zone | ||
|
||
The "zh" sound can be spelled in many different ways in English — like the "s" in MEASURE; like the "g" in BEIGE; like the "z" in AZURE; like the "j" in MAHARAJAH; and like the "x" in LUXURY as some people pronounce it. The "zh" sound can also be spelled as a "t" in one instance. We know of only one common word this is true of, not counting its derivatives. What word is it? | ||
|
||
grep ' ZH ' cmudict-1.7b.txt | grep T | more |