Skip to content

Commit c90db9b

Browse files
author
Christopher
committed
added checks to ensure -l > -g and remove chosen word from list during recursion
1 parent addfb7f commit c90db9b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/xkcd_936/core.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646

4747
(defn randomWordFromOptions [words options]
4848
(let [randomWord (string/join \space (take 1 (secureShuffle words)))]
49+
(remove randomWord words)
4950
(cond
5051
(and (>= (count randomWord) (:lte options)) (<= (count randomWord) (:gte options))) randomWord
5152
:else (randomWordFromOptions words options))))
@@ -66,6 +67,7 @@
6667
(let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]
6768
(cond
6869
(:help options) (exit 0 summary)
70+
(> (:lte options) (:gte options)) (exit 0 "Minimum Characters (-l) should be greater than Maximum Characters (-g)")
6971
errors (exit 1 errors))
7072
(let [wordList (lines fileName)]
7173
(loop [i 0]

0 commit comments

Comments
 (0)