wordle_decoder 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0b40e0ae56b3869e0f27bf32298adfb5b147dd120e995f5c288e4dbd58dfbf9e
4
+ data.tar.gz: 524a6be77dfe9dce95dd8a19be2d38c6e91d9f07bfc91edc533476d3e9833125
5
+ SHA512:
6
+ metadata.gz: ca79c1d211eaf24132b951308df2c1a3c0c54e049dccfab634765835209dc8e391a81957c7832c2d415ab30801d953351d76f927718cd37eeb0c9c3e314469db
7
+ data.tar.gz: f5de50d444c980acec3478352ad3944ca03139f3a4247de7de172c932db43689cc82ebd6650bf6c05a2d1123277532c0f352aa13d040e7de4b8064a279e32a18
data/.rubocop.yml ADDED
@@ -0,0 +1,19 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Style/ClassAndModuleChildren:
13
+ Enabled: false
14
+
15
+ Style/Documentation:
16
+ Enabled: false
17
+
18
+ Layout/LineLength:
19
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-02-22
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in wordle_decoder.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "rubocop", "~> 1.21"
13
+
14
+ gem "cli-ui", "~> 1.5", ">= 1.5.1"
data/Gemfile.lock ADDED
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ wordle_decoder (0.1.0)
5
+ cli-ui (~> 1.5)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ cli-ui (1.5.1)
12
+ minitest (5.15.0)
13
+ parallel (1.21.0)
14
+ parser (3.1.0.0)
15
+ ast (~> 2.4.1)
16
+ rainbow (3.1.1)
17
+ rake (13.0.6)
18
+ regexp_parser (2.2.1)
19
+ rexml (3.2.5)
20
+ rubocop (1.25.1)
21
+ parallel (~> 1.10)
22
+ parser (>= 3.1.0.0)
23
+ rainbow (>= 2.2.2, < 4.0)
24
+ regexp_parser (>= 1.8, < 3.0)
25
+ rexml
26
+ rubocop-ast (>= 1.15.1, < 2.0)
27
+ ruby-progressbar (~> 1.7)
28
+ unicode-display_width (>= 1.4.0, < 3.0)
29
+ rubocop-ast (1.15.2)
30
+ parser (>= 3.0.1.1)
31
+ ruby-progressbar (1.11.0)
32
+ unicode-display_width (2.1.0)
33
+
34
+ PLATFORMS
35
+ arm64-darwin-21
36
+
37
+ DEPENDENCIES
38
+ cli-ui (~> 1.5, >= 1.5.1)
39
+ minitest (~> 5.0)
40
+ rake (~> 13.0)
41
+ rubocop (~> 1.21)
42
+ wordle_decoder!
43
+
44
+ BUNDLED WITH
45
+ 2.3.7
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Wordle Decoder
2
+
3
+ It guesses your guesses based on all those little 🟨, 🟩, and ⬛ emojis that we now love to share.
4
+
5
+ Given your Wordle share text, with some degree of confidence, the decoder will spit back the five-letter words it thinks you played.
6
+
7
+ ## Installation
8
+
9
+ $ gem install wordle_decoder
10
+
11
+ ## Usage
12
+
13
+ After entering the below at the command line, you should be prompted to enter your Wordle share and the Wordle word of the day.
14
+
15
+ $ wordle_decoder
16
+
17
+ ## Examples
18
+
19
+ TODO...
data/Rakefile ADDED
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ require "./lib/wordle_decoder/word_search"
7
+
8
+ Rake::TestTask.new(:test) do |t|
9
+ t.libs << "test"
10
+ t.libs << "lib"
11
+ t.test_files = FileList["test/**/test_*.rb"]
12
+ end
13
+
14
+ require "rubocop/rake_task"
15
+
16
+ RuboCop::RakeTask.new
17
+
18
+ task default: %i[test rubocop]
19
+
20
+ task :create_word_search_files do
21
+ sorted_words = load_words_sorted_by_frequency
22
+ most_common_words = sorted_words.pop(3_000)
23
+ most_common_words, less_common_words = most_common_words.partition { |r| r.split("").uniq.count == 5 }
24
+ File.write(lib_path("most_common_words.txt"), most_common_words.join("\n"))
25
+ File.write(lib_path("less_common_words.txt"), less_common_words.join("\n"))
26
+ File.write(lib_path("least_common_words.txt"), sorted_words.join("\n"))
27
+ end
28
+
29
+ task :output_most_common_letters do
30
+ words = load_wordle_words("allowed_answers.txt")
31
+ words.concat load_wordle_words("allowed_guesses.txt")
32
+ letter_count_tally = words.flat_map { _1.split("") }.tally
33
+ letter_count_tally = letter_count_tally.sort_by { -_2 }
34
+ puts letter_count_tally.first(10).map { _1.first }.join(" ")
35
+ end
36
+
37
+ task :output_most_common_letters_by_word_count do
38
+ words = load_wordle_words("allowed_answers.txt")
39
+ words.concat load_wordle_words("allowed_guesses.txt")
40
+ word_count_tally = ("a".."z").map { |l| [l, words.count { |word| word.include?(l) }] }
41
+ word_count_tally = word_count_tally.sort_by { -_2 }
42
+ puts word_count_tally.first(10).map { _1.first }.join(" ")
43
+ end
44
+
45
+ def load_words_sorted_by_frequency
46
+ file_path = lib_path("words_to_frequency_score.json")
47
+ if File.exist?(file_path)
48
+ WordleDecoder::WordSearch.words_to_frequency_score_hash.keys
49
+ else
50
+ File.write(file_path, build_words_to_frequency_score_hash.to_json)
51
+ build_words_to_frequency_score_hash.keys
52
+ end
53
+ end
54
+
55
+ def build_words_to_frequency_score_hash
56
+ words_by_freq_hash = JSON.parse(read_file("word_frequencies.json")).sort_by { _2 }
57
+ words_by_freq_hash.each_with_index { |array, index| array[1] = index / 100_000.to_f }
58
+ words_by_freq_hash.to_h
59
+ end
60
+
61
+ def load_wordle_words(file_name)
62
+ read_file(file_name).split("\n")
63
+ end
64
+
65
+ def read_file(file_name)
66
+ file_path = File.join(File.dirname(__FILE__), file_name)
67
+ File.read(file_path)
68
+ end
69
+
70
+ def lib_path(file_name)
71
+ File.join(File.dirname(__FILE__), "lib", file_name)
72
+ end