Skip to content

Commit

Permalink
September 2023 solution
Browse files Browse the repository at this point in the history
  • Loading branch information
msszczep committed Sep 19, 2023
1 parent cbfe6ee commit 540704d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
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
34 changes: 34 additions & 0 deletions src/clj/puzzle_2023-09-10.clj
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]))

0 comments on commit 540704d

Please sign in to comment.