-
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
2 changed files
with
35 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
target/ | ||
resources/enwiki-20200820-all-titles-clean.txt | ||
resources/enwiki-* | ||
wqc_2019.clj | ||
.lein-repl-history | ||
resources/all_en_wikipedia_titles_20210420.txt |
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,34 @@ | ||
; https://www.npr.org/2023/09/10/1198507860/sunday-puzzle-switch-it-out | ||
|
||
; Name a creature that has a world capital in its name. Replace the capital | ||
; with another creature and you'll get another world capital. What is it? | ||
|
||
(defn clean-up-word [word] | ||
(clojure.string/replace (clojure.string/lower-case word) #"[^a-z]" "")) | ||
|
||
(def animals-to-use | ||
(->> (slurp "resources/wordnet_data_cleaned.noun") | ||
clojure.string/split-lines | ||
(map #(clojure.string/split % #" ")) | ||
(map (juxt #(nth % 4) second)) | ||
(filter (comp (partial = "05") last)) | ||
(map first) | ||
(filter (comp (partial < 2) count)) | ||
(mapv clean-up-word) | ||
distinct)) | ||
|
||
(def world-capitals | ||
(->> "resources/world-capitals.txt" | ||
slurp | ||
clojure.string/split-lines | ||
(map #(clojure.string/split % #",")) | ||
(map last) | ||
(map clean-up-word) | ||
sort)) | ||
|
||
(def solution? | ||
(for [w world-capitals | ||
:let [f (filter #(re-find (re-pattern w) %) animals-to-use)] | ||
:when (not (empty? f))] | ||
[w f])) | ||
|