wordle_decoder 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/wordle_decoder +93 -75
- data/lib/wordle_decoder/version.rb +1 -1
- data/lib/wordle_decoder/wordle_share.rb +19 -0
- data/lib/wordle_decoder.rb +8 -12
- 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: dca5b9fbafa87be192d4a5768b878564412854bdb8838e1e9ac55d1eb0244d4a
|
4
|
+
data.tar.gz: b9ec7358da606b398da0f653fc62d4ac2c8f697fc91f6a43dcf478c77a7f68d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2fb07120f3c105302ae4b251cd3f7df6a80be4ca5aadc81cae29410bf63137024c277c3c862337b4b10bf7e4bda9ad8901626f01de27309e9e189d8a22a172b
|
7
|
+
data.tar.gz: 9f21c02dc2d567e2e613482181ffe0a24b6d5e8b567f99333e76cc346d161dd67376c69a8615afc611754467da375380fd4282094e68cb452610afe8d568eff2
|
data/bin/wordle_decoder
CHANGED
@@ -8,16 +8,28 @@ require "cli/ui"
|
|
8
8
|
|
9
9
|
CLI::UI::StdoutRouter.enable
|
10
10
|
|
11
|
-
print CLI::UI.fmt("\n
|
11
|
+
print CLI::UI.fmt("\n Share your wordle:\n\n{{blue:>}} ")
|
12
12
|
|
13
13
|
input_lines = []
|
14
14
|
until WordleDecoder::WordleShare.final_line?(input_line = gets)
|
15
15
|
input_lines << input_line
|
16
|
+
if WordleDecoder::WordleShare.exit_program?(input_line)
|
17
|
+
puts "\n Goodbye!\n\n"
|
18
|
+
return
|
19
|
+
elsif WordleDecoder::WordleShare.needs_help?(input_line)
|
20
|
+
help_text = WordleDecoder::WordleShare.help_to_terminal
|
21
|
+
input_lines << "\n"
|
22
|
+
input_lines << help_text
|
23
|
+
input_lines << "\n"
|
24
|
+
print CLI::UI.fmt(help_text)
|
25
|
+
elsif input_lines.all? { |l| l.strip.empty? }
|
26
|
+
print CLI::UI.fmt("{{blue:>}} ")
|
27
|
+
end
|
16
28
|
end
|
17
29
|
input_lines << input_line
|
18
30
|
|
19
|
-
clear_pasted_text_lines = input_lines.reverse_each.map { |line| "\033[A\r
|
20
|
-
clear_pasted_text_lines << "\033[A\r"
|
31
|
+
clear_pasted_text_lines = input_lines.reverse_each.map { |line| "\033[A\r #{" " * line.length}" }
|
32
|
+
clear_pasted_text_lines << "\033[A\r "
|
21
33
|
puts clear_pasted_text_lines.join
|
22
34
|
|
23
35
|
wordle_share = WordleDecoder::WordleShare.new(input_lines)
|
@@ -47,78 +59,84 @@ CLI::UI::Spinner.spin("Acting like I'm doing something.") do |spinner|
|
|
47
59
|
end
|
48
60
|
spinner.update_title("Fine, I'll do it")
|
49
61
|
|
50
|
-
decoder.
|
51
|
-
|
62
|
+
if decoder.best_guess
|
63
|
+
spinner.update_title("\r I decoded your wordle hints!}}")
|
64
|
+
else
|
65
|
+
no_guess_messages = ["You stumped me!", "Are you messing with me?", "Are you sure that was the word of the day?"]
|
66
|
+
spinner.update_title("\r 🤨 #{no_guess_messages.sample}}}")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
if decoder.best_guess
|
71
|
+
puts CLI::UI.fmt("\n {{blue:{{underline:Guesses}} {{underline:Confidence}}}}")
|
72
|
+
puts CLI::UI.fmt(decoder.to_terminal)
|
52
73
|
end
|
53
74
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
"I enjoyed our time together!"].freeze
|
122
|
-
|
123
|
-
puts CLI::UI.fmt("\n #{comments.sample}\n " \
|
75
|
+
salutations = ["Maybe some of those are your words!",
|
76
|
+
"I tried!",
|
77
|
+
"How'd I do?",
|
78
|
+
"Did I get it?",
|
79
|
+
"I'm also guessing you're great!",
|
80
|
+
"Don't spill your coffee.",
|
81
|
+
"Shout out to friends for sending me their wordles.",
|
82
|
+
"Shout out to https://www.youtube.com/watch?v=v68zYyaEmEA for word frequency source.",
|
83
|
+
"I hope you had a great time.",
|
84
|
+
"Hope to see you again.",
|
85
|
+
"Was great guessing you.",
|
86
|
+
"Thinking about heading to sleep.",
|
87
|
+
"Sometimes I just throw out mostly random stuff.",
|
88
|
+
"I didn't mean to offend.",
|
89
|
+
"I try not to be random...",
|
90
|
+
"I'm open source :)",
|
91
|
+
"I'd fork you to make me better.",
|
92
|
+
"TLDR: Another programmer played wordle.",
|
93
|
+
"How was I with my words?",
|
94
|
+
"I'm written in Ruby and bite like a python.",
|
95
|
+
"Here's an emoji ❤️",
|
96
|
+
"🤔 🤨 🧐",
|
97
|
+
"All my thinking to you.",
|
98
|
+
"I've learned about wordle and your people.",
|
99
|
+
"I'm not learning anything at the moment.",
|
100
|
+
"I wish I had time to machine learn you ;)",
|
101
|
+
"No, you have a great personality!",
|
102
|
+
"This one might be weird, if it's your first.",
|
103
|
+
"Is my strategy as good as yours?",
|
104
|
+
"I'm biased, but so are you!",
|
105
|
+
"I'd love to learn your strategy ;)",
|
106
|
+
"I'd grow neurons for you.",
|
107
|
+
"How well can you play without me guessing?",
|
108
|
+
"If you're seeing this, we probably know each other.",
|
109
|
+
"I hope things aren't getting too weird.",
|
110
|
+
"❤️ ❤️ ❤️",
|
111
|
+
"No, you're great!",
|
112
|
+
"Do you decode often?",
|
113
|
+
"All the best five-letter words to you!",
|
114
|
+
"My friends call me the wordle decoder.",
|
115
|
+
"Everything I am is written.",
|
116
|
+
"May my written code speak truly.",
|
117
|
+
"Who guessed better?",
|
118
|
+
"No excuse, but my thoughts are in a constant array.",
|
119
|
+
"Your words complete me.",
|
120
|
+
"Like peering into a soul.",
|
121
|
+
"I hope I didn't embarass myself.",
|
122
|
+
"I hope I didn't embarrass myself.",
|
123
|
+
"I hope I didn't embaras myself.",
|
124
|
+
"Can you decode my five letter word?",
|
125
|
+
"Sometimes I'm off by one...",
|
126
|
+
"Something's fishy...",
|
127
|
+
"Did you put something on me?",
|
128
|
+
"I'm only wrong about five letter words...",
|
129
|
+
"Your words are beautiful.",
|
130
|
+
"You make this wordle a better place!",
|
131
|
+
"What in the wordle was I thinking?",
|
132
|
+
"Those words you gave me were so good.",
|
133
|
+
"I truly enjoyed those words, thank you!",
|
134
|
+
"What lovely words you have!",
|
135
|
+
"I hope my words were as good as yours!",
|
136
|
+
"Please enjoy the rest of your day!",
|
137
|
+
"I may not be positive about your words, but I am about you!",
|
138
|
+
"Thank you for spending time with me!",
|
139
|
+
"I enjoyed our time together!"].freeze
|
140
|
+
|
141
|
+
puts CLI::UI.fmt("\n\n #{salutations.sample}\n " \
|
124
142
|
"{{blue:https://github.com/mattruzicka/wordle_decoder}}}}\n\n")
|
@@ -8,6 +8,23 @@ class WordleDecoder
|
|
8
8
|
ANSWER_LINES.any? { input_lines.include?(_1) }
|
9
9
|
end
|
10
10
|
|
11
|
+
NEEDS_HELP_INPUTS = %w[help what wordle wat ? man okay yes no test].freeze
|
12
|
+
|
13
|
+
def self.needs_help?(input)
|
14
|
+
NEEDS_HELP_INPUTS.include?(input.strip.downcase)
|
15
|
+
end
|
16
|
+
|
17
|
+
EXIT_PROGRAM_INPUTS = %w[exit no nvm].freeze
|
18
|
+
|
19
|
+
def self.exit_program?(input)
|
20
|
+
EXIT_PROGRAM_INPUTS.include?(input.strip)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.help_to_terminal
|
24
|
+
"\n {{italic:Copy and paste those 🟨, 🟩, and ⬛" \
|
25
|
+
" emojis from your wordle share.}} \n\n{{blue:>}} "
|
26
|
+
end
|
27
|
+
|
11
28
|
def self.wordle_answers
|
12
29
|
@wordle_answers ||= load_worldle_ansers
|
13
30
|
end
|
@@ -36,6 +53,8 @@ class WordleDecoder
|
|
36
53
|
|
37
54
|
def find_answer
|
38
55
|
title_line = input_lines.detect { |line| line.match?(GAME_DAY_REGEX) }
|
56
|
+
return unless title_line
|
57
|
+
|
39
58
|
game_day = title_line.match(GAME_DAY_REGEX).captures.first&.to_i
|
40
59
|
self.answer = self.class.wordle_answers[game_day]
|
41
60
|
end
|
data/lib/wordle_decoder.rb
CHANGED
@@ -14,10 +14,6 @@ class WordleDecoder
|
|
14
14
|
@wordle_share = wordle_share
|
15
15
|
end
|
16
16
|
|
17
|
-
def to_terminal
|
18
|
-
@to_terminal ||= format_to_terminal
|
19
|
-
end
|
20
|
-
|
21
17
|
def best_guess
|
22
18
|
@best_guess ||= guesses.first
|
23
19
|
end
|
@@ -38,6 +34,14 @@ class WordleDecoder
|
|
38
34
|
lines.join("\n")
|
39
35
|
end
|
40
36
|
|
37
|
+
def to_terminal
|
38
|
+
str = +"\n"
|
39
|
+
best_guess.words_with_scores.reverse_each do |word, guess_score|
|
40
|
+
str << " #{word.to_terminal} #{word.confidence_score(guess_score)}\n"
|
41
|
+
end
|
42
|
+
str << " {{green:#{@wordle_share.answer}}}\n"
|
43
|
+
end
|
44
|
+
|
41
45
|
private
|
42
46
|
|
43
47
|
def initialize_and_sort_guesses
|
@@ -55,12 +59,4 @@ class WordleDecoder
|
|
55
59
|
WordPosition.new(line, index, @wordle_share.answer_chars)
|
56
60
|
end
|
57
61
|
end
|
58
|
-
|
59
|
-
def format_to_terminal
|
60
|
-
str = +"\n"
|
61
|
-
best_guess.words_with_scores.reverse_each do |word, guess_score|
|
62
|
-
str << " #{word.to_terminal} #{word.confidence_score(guess_score)}\n"
|
63
|
-
end
|
64
|
-
str << " {{green:#{@wordle_share.answer}}}\n\n"
|
65
|
-
end
|
66
62
|
end
|