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
(defn l->n [input] | |
"Given a string and the sequence a = 1, b = 2, ... z = 26, compute the total for the string. | |
Get a bonus point if the sequence 'zachary' appears in the string." | |
(let [point-values (zipmap (map char "abcdefghijklmnopqrstuvwxyz") | |
(range 1 27)) | |
bonus-point (if (re-find #"zachary" (clojure.string/lower-case input)) 1 0)] | |
(->> input | |
(map char) | |
(map point-values) | |
(cons bonus-point) |
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
(defn get-wordboxes [word] | |
"Given a word like 'cat', make all possible wordboxes in English. Here's an example wordbox: | |
CAT | |
O*E | |
GUN | |
Note that the words 'cog', 'ten' and 'gun' come from the word 'cat'. | |
The code below is too slow for words of four-letters-long or longer. I was hoping to make a full-fledged |
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
(defn letters->numbers [letters] | |
(let [letter-map (zipmap (map char "abcdefghijklmnopqrstuvwxyz") | |
(range 1 27))] | |
(->> letters | |
(map char) | |
(map letter-map) | |
(reduce +)))) |
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
(defn p112-take1 [n d] | |
(letfn [(recast-to-vec [acc] | |
(let [num-left (count (re-seq #"\[" (apply str acc))) | |
num-right (count (re-seq #"\]" (apply str acc))) | |
updated-seq (concat acc (repeat (- num-left num-right) "]"))] | |
(read-string (apply str (interpose " " updated-seq))))) | |
(recast-to-int [s] | |
(Integer. (clojure.string/replace s #"[\]\[]" "")))] | |
(loop [acc-value 0 | |
acc-structure [] |
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
(defn scramboni [rack] | |
"Find all playable words in a given Scrabble rack. Use asterisks for blanks." | |
(letfn [(every-but-n? [n pred coll] | |
(->> coll | |
(map (comp (fn [x] (if x :true :false)) pred)) | |
frequencies | |
(merge {:false 0}) | |
:false | |
(>= n)))] | |
(let [scrabble-words (->> "/home/mitchells/Desktop/npr_sunday_puzzle_solutions/resources/ospd3.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
import sys | |
text = sys.argv[1] | |
print text |
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
(defn subanagram-generator [submitted-word] | |
(let [words (->> (slurp "/Users/msszczep1/Scripts/npr_puzzle_scripts/ni2.txt") | |
(clojure.string/split-lines)) | |
submitted-word-freqs (merge | |
(zipmap "abcdefghijklmnopqrstuvwxyz" (repeat 26 0)) | |
(frequencies (clojure.string/lower-case submitted-word)))] | |
(->> words | |
(filter (fn [word] | |
(let [lc-word (clojure.string/lower-case word)] | |
(every? #(<= ((frequencies lc-word) %) |
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
| Surround parens | M-shift-9 | | |
| slurp right | ctrl-shift-right_arrow | | |
| barf right | ctrl-shift-left_arrow | | |
| slurf left | ctrl-shift-9 | |
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
port module SubanagramGenerator exposing (..) | |
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (..) | |
import Html.App as App | |
import String exposing (toLower, toList) | |
import Ni2Dictionary | |
import Char exposing (isLower) | |
import Dict exposing (Dict) |
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
(ns faceoff.core) | |
;; Make deck of cards, shuffle | |
;; loop: | |
;; does a player have zero cards? | |
;; if yes: game over | |
;; if no: faceoff | |
;; determine winner, winner gets cards added | |
;; if tie: | |
;; does 1 player have < 5 cards |