Created
May 6, 2013 15:52
-
-
Save weejulius/5526009 to your computer and use it in GitHub Desktop.
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 char-diff | |
"the diff between char1 and (char21,char22)" | |
[char1 char21 char22] | |
(cond | |
(= char1 char21) 1 | |
(= char1 char22) 2 | |
:else 0)) | |
(defn word-chain? | |
[w1 w2] | |
(let [len-diff (- (count w1) (count w2))] | |
(if (or (= -1 len-diff) (= 0 len-diff)) | |
(loop [x1 w1 | |
x2 w2 | |
diff 0] | |
(if (> 2 diff) | |
(let [the-char-diff (char-diff (first x1) (first x2) (second x2))] | |
(println "p:" x1 x2 the-char-diff diff ) | |
(recur (next x1) (drop the-char-diff x2) (if (= 1 the-char-diff) diff (inc diff)))) | |
false))) | |
(if (= 1 len-diff) (recur w2 w1) false))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment