lita-onewheel-word-jumble 0.0.0 → 0.1.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 482f6f8107f35dc725420e9108b45ec578cbbc3976f0a23c5d24cc128be77086
|
4
|
+
data.tar.gz: d3110600c51e6ae5f495e4c5bd2aa15aa010fc6861be2322e17b8ce586168b84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '048cacb26f33cf9442361744601ed4eced796d9f2cc8e16194bf9dc1bca6601daa79d111167e26dff9203d92269524ba31c5ec2666bfed356e769a00f3222fda'
|
7
|
+
data.tar.gz: 87f95e3225988a9998411b49325a9a3687bf314aa76b0237569fa518fd9d47aee7feee8360c41c0bd616ad205bd7a5d36c7db1e1f4b38ed4123a379f091759bf
|
@@ -7,6 +7,7 @@ module Lita
|
|
7
7
|
def words(response)
|
8
8
|
Lita.logger.debug('Loading words...')
|
9
9
|
|
10
|
+
# Build the dict of words
|
10
11
|
words = {}
|
11
12
|
File.open(File.expand_path('../../words', File.dirname(__FILE__))).each_line do |l|
|
12
13
|
l.chomp!
|
@@ -17,20 +18,26 @@ module Lita
|
|
17
18
|
len = response.matches[0][1].to_i
|
18
19
|
|
19
20
|
if len == 0
|
21
|
+
min_len = 3
|
20
22
|
len = letters.length
|
23
|
+
else
|
24
|
+
min_len = len
|
21
25
|
end
|
22
26
|
|
23
|
-
|
27
|
+
Lita.logger.debug "Searching for alternatives to #{letters} with a length between #{min_len} and #{len}"
|
24
28
|
|
25
29
|
combos = []
|
26
30
|
|
27
|
-
|
28
|
-
|
31
|
+
for n in (min_len..len) do
|
32
|
+
Lita.logger.debug "Checking for #{n} length words..."
|
33
|
+
letters.split(//).permutation(n).to_a.map(&:join).each do |combo|
|
34
|
+
combos.push combo if words[combo] == 1
|
35
|
+
end
|
29
36
|
end
|
30
37
|
|
31
38
|
combo_str = combos.sort.uniq.join ", "
|
32
39
|
|
33
|
-
Lita.logger.info
|
40
|
+
Lita.logger.info "Returning: #{combo_str}"
|
34
41
|
|
35
42
|
response.reply(combo_str)
|
36
43
|
end
|
@@ -15,6 +15,20 @@ describe Lita::Handlers::OnewheelWordJumble, lita_handler: true do
|
|
15
15
|
send_command 'words aelb'
|
16
16
|
expect(replies.last).to_not be(nil)
|
17
17
|
expect(replies.count).to be(1)
|
18
|
-
expect(replies.last).to
|
18
|
+
expect(replies.last).to eq('abe, abel, able, alb, albe, ale, bae, bal, bale, bea, beal, bel, bela, blae, elb, lab, lea')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'solves yer jumble' do
|
22
|
+
send_command 'words aelb 4'
|
23
|
+
expect(replies.last).to_not be(nil)
|
24
|
+
expect(replies.count).to be(1)
|
25
|
+
expect(replies.last).to eq('abel, able, albe, bale, beal, bela, blae')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'solves yer jumble' do
|
29
|
+
send_command 'words aelb 3'
|
30
|
+
expect(replies.last).to_not be(nil)
|
31
|
+
expect(replies.count).to be(1)
|
32
|
+
expect(replies.last).to eq('abe, alb, ale, bae, bal, bea, bel, elb, lab, lea')
|
19
33
|
end
|
20
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-onewheel-word-jumble
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kreps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|