Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
solution
Browse files Browse the repository at this point in the history
  • Loading branch information
tlonist committed Nov 8, 2022
1 parent ad95771 commit 47b00eb
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions src/wordle/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
answer : [`p` `o` `w` `e` `r`]
input과 answer가 완벽히 일치하면 아래의 코드를 실행.
(dispatch [::events/update-status :solved])"
[input answer])

[input answer]
(when (= input answer)
(dispatch [::events/update-status :solved])))

(defn wordle-match?
"input : [`w` `a` `t` `e` `r`]
Expand All @@ -31,7 +32,14 @@
포함하지만 같은 위치가 아닌 경우 -> :contain
포함하고 위치가 같은 경우 -> :correct
포함하지 않는 경우 -> :none"
[input answer])
[input answer]
(let [answer-set (set answer)]
(->> input
(map (fn [c c']
(cond
(= c c') :correct
(contains? answer-set c') :contain
:else :none)) answer))))

(defn key-up-event [e]
(let [curr (re-frame/subscribe [::subs/curr])
Expand Down Expand Up @@ -110,6 +118,30 @@
[:h1 {:id "answer"} @answer])]))


(comment
(def input (vec (map char "WATER")))
(def answer (vec (map char "POWER")))

(->> input
(map (fn [c c']
(cond
(= c c') :correct
(contains? (set answer) c') :contains
:else :none)) answer))
(cond
(> 1 2) "correct"
(> 2 1) "yes!")

(contains? (set answer) "T")

;; :contain, :none, :correct
(->> input
(map (fn [c c']
(cond
false :contain
false :none
(= c c') :correct)) answer)))




Expand Down

0 comments on commit 47b00eb

Please sign in to comment.