Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions parser.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
require 'pry'

def kinda_like?(fuzzy_word, exact_word)
# implement with your code here
# breaking the method up into pieces is encouraged
if fuzzy_word == exact_word
return true
elsif fouls(fuzzy_word, exact_word) < 2
return true
else
return false
end
end

#def another_private_method
#end
def fouls(w1,w2)
array_w2 = w2.chars
array_w1.each do |x|
array_w2.delete(x)
end
z = 0
wd1 = w1.chars
wd2 = w2.chars
z = 1 if wd1.last == wd2.last && wd1.first == wd2.first && w1.size != w2.size
array_w2.count + jumbled(w1,w2) + z
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like z is derived from first and last letters, but, jumbled also is derived from first and last letters... is there a way to DRY this up?

end

def jumbled(w1,w2)
if w1.chars.last == w2.chars.last
0
elsif w1.chars.first != w2.chars.first
2
else
1
end
end

#def some_private_method
#end
# p fouls("cawffee", "coffee")
# p fouls("bog", "dog")
p kinda_like?("doge", "dog") == true
p kinda_like?("bog", "dog") == true
p kinda_like?("flow", "wolf") == false
p kinda_like?("cawffee", "coffee") == false