wordl-solver 0.2.51 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27cd3bdd02312caa90f00eb5c19a0bb9fcf3ba5ed3cee60a1decf90553549f9d
4
- data.tar.gz: b9882733e0ca569e86499135ea4d318133aede200b855a646d4a1fd8abdead02
3
+ metadata.gz: 2757d69b48f2b27ca57778b71d82ca52416c3ee7e1a763f6e2076a6b9b35222c
4
+ data.tar.gz: 20a741267326ea6932f72731472c471bd266cf2327c8fb6e92d029710a0c5dbd
5
5
  SHA512:
6
- metadata.gz: 4227cb660e43740fbcf488e6627d34c22cb8f216e89314502ecb0151dfdf1eef2fcc12df3c3c339c277d5e88cbaaa3316ccf9a17e6700608e2100fbbd6ced6bd
7
- data.tar.gz: 071b8c33e798867483147f2b4016b74e26f84a3595389101dc2f459ca454392ea78ee2cd9acc9bc6ecfff4c84265d5ffd3fd943ca4ae842c6109cd7250795de2
6
+ metadata.gz: 5b4c9c6e786ec0dde13934b8d75dcf363aafb80b6638099c6c1d294e00af334a2d8b97cc1994bdb3c6bf3ea778a09dee5a97abff2f61a5c76c47c4e695b3034c
7
+ data.tar.gz: d3c63f08a640c42d9763a07dfa04de9f29c98633082b09cfe1257d147700ca2f702d164fab8fc1d4986e1b39190a461ed6ea80e1c4b48b415538d7144a93b9d0
data/README.rdoc CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  Description goes here.
4
4
 
5
+ This is a tool I've built to help me solve wordle.
6
+ It does so by providing all the 5 letter words, ordering them by the frequency of the letters and filter them depending on the the colours.
7
+
8
+
9
+ ** Still To DO
10
+
11
+ - have the logic for when a letter appear twice or not
12
+ - allow to correct the inputs
13
+ - clean the code a bit more
14
+
5
15
  == Contributing to wordl-solver
6
16
 
7
17
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.51
1
+ 1.1.1
data/lib/wordl_solver.rb CHANGED
@@ -6,7 +6,6 @@ require 'fileutils'
6
6
  FILE_PATH = File.join(File.dirname(__FILE__), '5_words.csv')
7
7
 
8
8
  LETTER_WORDS = []
9
- LETTER_FRENQUENCY = %w[e t a o i n s h r d l c u m f w y g p b v k j x q z].reverse.freeze
10
9
 
11
10
  CSV.foreach(FILE_PATH) do |row|
12
11
  LETTER_WORDS << row[0]
@@ -77,9 +76,11 @@ class WordlSolver
77
76
  else
78
77
  @greens[t] = letters[1]
79
78
  end
79
+ @greys.reject! { |letter| @greens.include?(letter) || @yellows.values.flatten.include?(letter) }
80
80
  end
81
81
 
82
82
  def find_possible_words
83
+ @possible_words = @possible_words.empty? ? LETTER_WORDS : @possible_words
83
84
  filter_greens
84
85
  filter_yellows
85
86
  filter_greys
@@ -88,21 +89,22 @@ class WordlSolver
88
89
  def present_possible_words
89
90
  puts 'here are the existing words'
90
91
  hash_word_frequency = {}
92
+ set_letters_frequencies
91
93
  @possible_words.each do |word|
92
94
  count = 0
93
95
  word.chars.uniq.each do |char|
94
- count += LETTER_FRENQUENCY.index(char)
96
+ count += @frenquencies[char]
95
97
  end
96
98
  hash_word_frequency[word] = count
97
99
  end
98
100
  hash_word_frequency = hash_word_frequency.sort_by { |_k, v| v }
99
- hash_word_frequency.last(30).each do |word, count|
101
+ hash_word_frequency.each do |word, count|
100
102
  p "#{word} : #{count}"
101
103
  end
102
104
  end
103
105
 
104
106
  def filter_greens
105
- @possible_words = (@possible_words.empty? ? LETTER_WORDS : @possible_words).select do |word|
107
+ @possible_words.select! do |word|
106
108
  put_in = true
107
109
  @greens.each do |key, value|
108
110
  next if value.nil?
@@ -134,4 +136,14 @@ class WordlSolver
134
136
  def check_word_correct(letters)
135
137
  letters.length != 2 || !%w[s y g].include?(letters[0])
136
138
  end
139
+
140
+ def set_letters_frequencies
141
+ @frenquencies = {}
142
+ @possible_words.each do |word|
143
+ word.chars.each do |letter|
144
+ @frenquencies[letter] = 0 if @frenquencies[letter].nil?
145
+ @frenquencies[letter] += 1
146
+ end
147
+ end
148
+ end
137
149
  end
data/wordl-solver.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: wordl-solver 0.2.51 ruby lib
5
+ # stub: wordl-solver 1.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "wordl-solver".freeze
9
- s.version = "0.2.51"
9
+ s.version = "1.1.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["george kosmopoulos".freeze]
14
- s.date = "2022-04-29"
14
+ s.date = "2022-05-21"
15
15
  s.description = "This gem helps you solve wordl puzzles. It does so by asking you for the letters position you know, the letters you know exists and the ones you know don't exists. It then proposes words depending on how good they are by weighting the letters by their frequency in the english language.".freeze
16
16
  s.email = "gkosmo1@hotmail.com".freeze
17
17
  s.executables = ["wordl-solver".freeze]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordl-solver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.51
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - george kosmopoulos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-29 00:00:00.000000000 Z
11
+ date: 2022-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda