wordl-solver 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/wordl-solver.rb +17 -16
- data/wordl-solver.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56ce5f7a8f29124bd5053d1c3fa132c27ed5bca0afad0c7b9e08fd9a8b955426
|
4
|
+
data.tar.gz: 96b0e2b206b9fbd70cca2f1173981b5ae4b00f21f22b18a3522a40cb06a71fcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d79901c808526549dbdb936daac69306e8e13dac03bb349e0428ae49e4266bbcf1ac51ccdde73ba662513d9907d04a7b4881d3c1666a3d3a39db36640852339
|
7
|
+
data.tar.gz: c3c86f6da385c609973fd5572f8237a981e57672b7a0e15fb6b660976c7da8e2f58cd4a68a9232196aca688e59870593522d9da7c5063b1832c082b2754bda48
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/lib/wordl-solver.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'csv'
|
2
|
+
require 'fileutils'
|
3
3
|
|
4
|
-
FILE_PATH = File.join(
|
4
|
+
FILE_PATH = File.join(File.dirname(__FILE__), '5_words.csv')
|
5
5
|
|
6
6
|
LETTER_WORDS = []
|
7
|
-
LETTER_FRENQUENCY = %w
|
7
|
+
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].freeze
|
8
8
|
|
9
9
|
CSV.foreach(FILE_PATH) do |row|
|
10
10
|
LETTER_WORDS << row[0]
|
11
11
|
end
|
12
12
|
|
13
13
|
class WordlSolver
|
14
|
-
|
15
14
|
def initialize
|
16
15
|
@yellows = {
|
17
16
|
0 => [],
|
@@ -36,12 +35,12 @@ class WordlSolver
|
|
36
35
|
end
|
37
36
|
|
38
37
|
def run
|
39
|
-
answer =
|
40
|
-
while answer !=
|
38
|
+
answer = ''
|
39
|
+
while answer != 'y'
|
41
40
|
ask_for_letters_and_colours
|
42
41
|
find_possible_words
|
43
42
|
present_possible_words
|
44
|
-
puts
|
43
|
+
puts 'have you found it ? (y/n)'
|
45
44
|
answer = gets.chomp
|
46
45
|
end
|
47
46
|
end
|
@@ -49,8 +48,8 @@ class WordlSolver
|
|
49
48
|
private
|
50
49
|
|
51
50
|
def ask_for_letters_and_colours
|
52
|
-
puts
|
53
|
-
puts
|
51
|
+
puts 'Type in order color initial then the letter'
|
52
|
+
puts '(s for silver, y for yellow and g for green)'
|
54
53
|
5.times do |t|
|
55
54
|
puts @greens[t]
|
56
55
|
if @greens[t].nil?
|
@@ -71,7 +70,7 @@ class WordlSolver
|
|
71
70
|
puts "for position #{t + 1} this #{@greens[t]}"
|
72
71
|
end
|
73
72
|
end
|
74
|
-
|
73
|
+
[@greens, @yellows, @greys]
|
75
74
|
end
|
76
75
|
|
77
76
|
def find_possible_words
|
@@ -81,8 +80,8 @@ class WordlSolver
|
|
81
80
|
end
|
82
81
|
|
83
82
|
def present_possible_words
|
84
|
-
puts
|
85
|
-
hash_word_frequency =
|
83
|
+
puts 'here are the existing words'
|
84
|
+
hash_word_frequency = {}
|
86
85
|
@possible_words.each do |word|
|
87
86
|
count = 0
|
88
87
|
word.chars.each do |char|
|
@@ -90,7 +89,7 @@ class WordlSolver
|
|
90
89
|
end
|
91
90
|
hash_word_frequency[word] = count
|
92
91
|
end
|
93
|
-
hash_word_frequency = hash_word_frequency.sort_by { |
|
92
|
+
hash_word_frequency = hash_word_frequency.sort_by { |_k, v| v }
|
94
93
|
hash_word_frequency.first(30).each do |word, count|
|
95
94
|
p "#{word} : #{count}"
|
96
95
|
end
|
@@ -109,18 +108,20 @@ class WordlSolver
|
|
109
108
|
end
|
110
109
|
|
111
110
|
def filter_yellows
|
111
|
+
yellow_letters = @yellows.values.flatten.uniq
|
112
112
|
@possible_words.select! do |word|
|
113
113
|
possible = true
|
114
114
|
word.chars.each_with_index do |letter, index|
|
115
115
|
possible = false if @yellows[index].include?(letter)
|
116
116
|
end
|
117
|
+
possible = false unless yellow_letters.all? { |letter| word.include?(letter) }
|
117
118
|
possible
|
118
119
|
end
|
119
120
|
end
|
120
121
|
|
121
122
|
def filter_greys
|
122
|
-
@possible_words.
|
123
|
-
|
123
|
+
@possible_words.reject! do |word|
|
124
|
+
@greys.any? { |letter| word.include?(letter) }
|
124
125
|
end
|
125
126
|
end
|
126
127
|
|
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.
|
5
|
+
# stub: wordl-solver 0.2.3 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "wordl-solver".freeze
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.3"
|
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-
|
14
|
+
s.date = "2022-04-22"
|
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.
|
4
|
+
version: 0.2.3
|
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-
|
11
|
+
date: 2022-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|