waylon-wordle 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +9 -0
- data/lib/waylon/wordle/solver.rb +5 -4
- data/lib/waylon/wordle/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6db7ed70378421cf71a537df618751aaeb7ce1bf203248dbc9bb480acabc5d67
|
4
|
+
data.tar.gz: 8413894c357ff8c94c4e30a1cb0ef23f0f3c2ec3f4b481413674aed3a8324b70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3b47236b1eec73f56138ca62f85be4f68cbf302555321374dd4128f563aa6c08d8ccd104730cca2b18ff556e0114cf6ac9e7ea0e66c47f4daf394f70b2a57b8
|
7
|
+
data.tar.gz: e827295dc9c1599243ebf462b649ba00c5b32d67ec45ea7764967abb1b3e4f74c4b7c435fc2bc98511baa9bd23e0093046c52988b422c4f255b1e2bcf1159409
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -10,3 +10,12 @@ require "rubocop/rake_task"
|
|
10
10
|
RuboCop::RakeTask.new
|
11
11
|
|
12
12
|
task default: %i[spec rubocop]
|
13
|
+
|
14
|
+
task :demo do
|
15
|
+
require "waylon/core"
|
16
|
+
require "waylon/wordle"
|
17
|
+
Waylon::Logger.logger = ::Logger.new("/dev/null")
|
18
|
+
Waylon::Cache.storage = Moneta.new(:Cookie)
|
19
|
+
Waylon::Storage.storage = Moneta.new(:Cookie)
|
20
|
+
require "waylon/rspec/test_server"
|
21
|
+
end
|
data/lib/waylon/wordle/solver.rb
CHANGED
@@ -14,7 +14,8 @@ module Waylon
|
|
14
14
|
answer = Waylon::Wordle.for_today.chars
|
15
15
|
attempts = [startword.chars]
|
16
16
|
attempts << make_attempt(answer, attempts) until attempts.last == answer || attempts.size == 6
|
17
|
-
|
17
|
+
|
18
|
+
attempts.compact
|
18
19
|
end
|
19
20
|
|
20
21
|
def make_attempt(answer, attempts)
|
@@ -22,11 +23,11 @@ module Waylon
|
|
22
23
|
near_hits = []
|
23
24
|
misses = []
|
24
25
|
|
25
|
-
attempts.each do |attempt|
|
26
|
+
attempts.compact.each do |attempt|
|
26
27
|
attempt.each_with_index do |letter, index|
|
27
28
|
if letter == answer[index]
|
28
29
|
hits[index] = letter
|
29
|
-
elsif answer.include?(letter)
|
30
|
+
elsif answer.include?(letter) && hits.count(letter) < answer.count(letter)
|
30
31
|
near_hits[index] ||= []
|
31
32
|
near_hits[index] << letter
|
32
33
|
else
|
@@ -53,7 +54,7 @@ module Waylon
|
|
53
54
|
next unless letters && !letters.empty?
|
54
55
|
|
55
56
|
return false if letters.include?(exploded_word[index])
|
56
|
-
return false unless exploded_word.
|
57
|
+
return false unless (letters - exploded_word).empty?
|
57
58
|
end
|
58
59
|
|
59
60
|
true
|