wordl-solver 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +18 -20
- data/VERSION +1 -1
- data/lib/{wordl-solver.rb → wordl_solver.rb} +19 -13
- data/wordl-solver.gemspec +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c953f3a69eea327f2201cc9ece27658ef958970737d557caf0a8b92d7b4ef9bf
|
4
|
+
data.tar.gz: cf9e13b893eb0b03de435080dc0d7af50a19903614fc2b20e34dd614f773bf25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d08f9d52496afc64c5bafdd81ea55318d13049e9fe2053ff1a416f550bfffdb00cadd2639b96a1800e0bb9205d1176c604098bbd00178a3ab9575e4353f9520
|
7
|
+
data.tar.gz: 6dd04312d1638daca91c843a6beae75e300e3b666c11e4e7a8df07f65b99b9537bef3b7a4e75d0cea9679bd4a2df72788f83f8632adc6466d27f8763131f30b9
|
data/Rakefile
CHANGED
@@ -1,16 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler"
|
5
3
|
begin
|
6
4
|
Bundler.setup(:default, :development)
|
7
5
|
rescue Bundler::BundlerError => e
|
8
|
-
|
9
|
-
|
6
|
+
warn e.message
|
7
|
+
warn "Run `bundle install` to install missing gems"
|
10
8
|
exit e.status_code
|
11
9
|
end
|
12
|
-
require
|
13
|
-
require
|
10
|
+
require "rake"
|
11
|
+
require "juwelier"
|
14
12
|
Juwelier::Tasks.new do |gem|
|
15
13
|
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
16
14
|
gem.name = "wordl-solver"
|
@@ -22,30 +20,30 @@ Juwelier::Tasks.new do |gem|
|
|
22
20
|
gem.authors = ["george kosmopoulos"]
|
23
21
|
gem.files.include "lib/*"
|
24
22
|
# dependencies defined in Gemfile
|
25
|
-
gem.executables = [
|
23
|
+
gem.executables = ["wordl-solver"]
|
26
24
|
end
|
27
25
|
Juwelier::RubygemsDotOrgTasks.new
|
28
|
-
require
|
26
|
+
require "rake/testtask"
|
29
27
|
Rake::TestTask.new(:test) do |test|
|
30
|
-
test.libs <<
|
31
|
-
test.pattern =
|
28
|
+
test.libs << "lib" << "test"
|
29
|
+
test.pattern = "test/**/test_*.rb"
|
32
30
|
test.verbose = true
|
33
31
|
end
|
34
32
|
|
35
33
|
desc "Code coverage detail"
|
36
34
|
task :simplecov do
|
37
|
-
ENV[
|
38
|
-
Rake::Task[
|
35
|
+
ENV["COVERAGE"] = "true"
|
36
|
+
Rake::Task["test"].execute
|
39
37
|
end
|
40
38
|
|
41
|
-
task :
|
39
|
+
task default: :test
|
42
40
|
|
43
|
-
require
|
41
|
+
require "rdoc/task"
|
44
42
|
Rake::RDocTask.new do |rdoc|
|
45
|
-
version = File.exist?(
|
43
|
+
version = File.exist?("VERSION") ? File.read("VERSION") : ""
|
46
44
|
|
47
|
-
rdoc.rdoc_dir =
|
45
|
+
rdoc.rdoc_dir = "rdoc"
|
48
46
|
rdoc.title = "wordl-solver #{version}"
|
49
|
-
rdoc.rdoc_files.include(
|
50
|
-
rdoc.rdoc_files.include(
|
47
|
+
rdoc.rdoc_files.include("README*")
|
48
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
51
49
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'csv'
|
2
4
|
require 'fileutils'
|
3
5
|
|
4
6
|
FILE_PATH = File.join(File.dirname(__FILE__), '5_words.csv')
|
5
7
|
|
6
|
-
LETTER_WORDS = []
|
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
|
+
LETTER_WORDS = [].freeze
|
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
|
8
10
|
|
9
11
|
CSV.foreach(FILE_PATH) do |row|
|
10
12
|
LETTER_WORDS << row[0]
|
@@ -59,18 +61,22 @@ class WordlSolver
|
|
59
61
|
puts "sorry, didn't catch that, try again:"
|
60
62
|
letters = gets.chomp
|
61
63
|
end
|
62
|
-
|
63
|
-
@greys << letters[1]
|
64
|
-
elsif letters[0] == 'y'
|
65
|
-
@yellows[t] << letters[1]
|
66
|
-
else
|
67
|
-
@greens[t] = letters[1]
|
68
|
-
end
|
64
|
+
sort_letter_upon_color(letters, t)
|
69
65
|
else
|
70
66
|
puts "for position #{t + 1} this #{@greens[t]}"
|
71
67
|
end
|
72
68
|
end
|
73
|
-
|
69
|
+
end
|
70
|
+
|
71
|
+
def sort_letter_upon_color(letters, t)
|
72
|
+
case letters[0]
|
73
|
+
when 's'
|
74
|
+
@greys << letters[1]
|
75
|
+
when 'y'
|
76
|
+
@yellows[t] << letters[1]
|
77
|
+
else
|
78
|
+
@greens[t] = letters[1]
|
79
|
+
end
|
74
80
|
end
|
75
81
|
|
76
82
|
def find_possible_words
|
@@ -84,13 +90,13 @@ class WordlSolver
|
|
84
90
|
hash_word_frequency = {}
|
85
91
|
@possible_words.each do |word|
|
86
92
|
count = 0
|
87
|
-
word.chars.each do |char|
|
88
|
-
count += LETTER_FRENQUENCY.index(char)
|
93
|
+
word.chars.uniq.each do |char|
|
94
|
+
count += LETTER_FRENQUENCY.index(char)
|
89
95
|
end
|
90
96
|
hash_word_frequency[word] = count
|
91
97
|
end
|
92
98
|
hash_word_frequency = hash_word_frequency.sort_by { |_k, v| v }
|
93
|
-
hash_word_frequency.
|
99
|
+
hash_word_frequency.last(30).each do |word, count|
|
94
100
|
p "#{word} : #{count}"
|
95
101
|
end
|
96
102
|
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.
|
5
|
+
# stub: wordl-solver 0.2.4 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.4"
|
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-28"
|
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]
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
"VERSION",
|
30
30
|
"bin/wordl-solver",
|
31
31
|
"lib/5_words.csv",
|
32
|
-
"lib/
|
32
|
+
"lib/wordl_solver.rb",
|
33
33
|
"wordl-solver.gemspec"
|
34
34
|
]
|
35
35
|
s.homepage = "http://github.com/gkosmo/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.4
|
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-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|
@@ -101,7 +101,7 @@ files:
|
|
101
101
|
- VERSION
|
102
102
|
- bin/wordl-solver
|
103
103
|
- lib/5_words.csv
|
104
|
-
- lib/
|
104
|
+
- lib/wordl_solver.rb
|
105
105
|
- wordl-solver.gemspec
|
106
106
|
homepage: http://github.com/gkosmo/wordl-solver
|
107
107
|
licenses:
|