-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatch_words.rb
53 lines (39 loc) · 964 Bytes
/
match_words.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env ruby
require 'optparse'
require 'set'
require 'pp'
require_relative 'load_words'
options = {}
response = Load_words.get('http://www.puzzlers.org/pub/wordlists/ospd.txt')
# Put data into an array
a_body = response.body.split("\n").to_set
d_body = Hash[a_body.map {|x| [x, x]}]
optparse = OptionParser.new do |opts|
opts.banner = "Usage: boggle.rb [options]"
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
opts.on("-s", "--string STRING", "Pass in a string to be parsed" ) do |s|
options[:string] = s
end
end
optparse.parse!
@word = options[:string]
def match_word(word, array)
if array.has_key?(word)
puts "#{word} : is a word!"
end
end
match_word(@word, d_body)
#debug
#pp(d_body)
#puts options
#puts options[:string]
#puts ARGV
# Binary search (cut list in half)
# ( might be better to use a hash to lookup words)
# hash set
#
#
# f o
# o o