Skip to content

Instantly share code, notes, and snippets.

@nathell
Created August 2, 2014 13:46
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 nathell/c8cf4108b0264911bd52 to your computer and use it in GitHub Desktop.
Save nathell/c8cf4108b0264911bd52 to your computer and use it in GitHub Desktop.
(ns trzeciblank
(:require [clojure.string :as string]
[clojure.java.io :as io]
[clojure.set :refer :all]))
(def piatki (set (line-seq (io/reader "/home/nathell/scrabble/w5.txt"))))
(defn kandydaci [slowo]
(for [i (range 5) x "abcdefghijklmnoprstuwyząćęłńóśźż"
:let [kand (str (subs slowo 0 i) x (subs slowo (inc i)))]
:when (piatki kand)]
kand))
(defn szukaj
([slowo] (szukaj #{slowo} #{}))
([slowa widziane]
(if (empty? slowa)
widziane
(let [slowo (first slowa)
reszta (disj slowa slowo)
widziane (conj widziane slowo)
nowe (difference (set (kandydaci slowo)) widziane)]
(recur (union nowe reszta) widziane)))))
(print (string/join " " (map string/upper-case (sort (difference piatki (szukaj "blank"))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment