From f71f2558c34fa5a23309f63303bb49b85be62328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannah=20Teki=C3=A9?= Date: Wed, 12 Feb 2020 14:41:18 -0800 Subject: [PATCH 1/7] phase 3 complete --- adagrams.rb | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 adagrams.rb diff --git a/adagrams.rb b/adagrams.rb new file mode 100644 index 0000000..865dbf7 --- /dev/null +++ b/adagrams.rb @@ -0,0 +1,153 @@ +# writing a method called draw_letters + + +# wave 1 +# method draw_letters randomly generates 10 letters, stores them in an array, +# returns that array of letters +def draw_letters + compact_bag = { + "A": 9, + "B": 2, + "C": 2, + "D": 4, + "E": 12, + "F": 2, + "G": 3, + "H": 2, + "I": 9, + "J": 1, + "K": 1, + "L": 4, + "M": 2, + "N": 6, + "O": 8, + "P": 2, + "Q": 1, + "R": 6, + "S": 4, + "T": 6, + "U": 4, + "V": 2, + "W": 2, + "X": 1, + "Y": 2, + "Z": 1 + } + expanded_bag = [] + compact_bag.each do |letters, number| + number.times do + expanded_bag << letters + end + end + + random = [] + 10.times do + x = rand expanded_bag.length + while random.include? x + x = rand expanded_bag.length + end + random << x + end + + hand = random.map {|number| expanded_bag[number]} + +end + + +#wave 2 +# method uses_available_letters? takes a string and an array of letters +# to determine if the string can be made from the array of letters +# returns true if string is valid (can be made from array of letters) +# returns false if string is invalid (cannot be made from array of letters) +def uses_available_letters? (input, letters_in_hand) + input <= letters_in_hand.join +end + +#wave 3 +# method score_word takes string of characters +# and returns an integer representing the number of points +def score_word(word) #word is a string of characters + +score = 0 + +word.upcase.each_char do |char| + case char + when "A", "E", "I", "O", "U", "L", "N", "R", "S", "T" + score += 1 + when "D", "G" + score += 2 + when "B", "C", "M", "P" + score += 3 + when "F", "H", "V", "W", "Y" + score += 4 + when "K" + score += 5 + when "J", "X" + score += 8 + when "Q", "Z" + score += 10 + else + puts "Invalid char found." + end + end + + + + if [7,8,9,10].include? word.length + score += 8 + end + + return score + +end + + + +# puts uses_available_letters?("cat" ,["c","a","t", "t", "t"]) +# puts score_word("belvita") + + +my_hand = draw_letters + +# Wave 4 +# method has one parameter (word) +# returns a hash (winning word, score) the highest scoring word +# if tied using tie-breaking method (when choosing do the followings: prefer word with fewer letters; +# if multiple words have the same score, choose the one w/fewest letters unless one word has 10 letters, +# if letters and scores are the same, choose the first one you see) + +def highest_score_from(words) # words is going to be array of strings + all_scores = [] + words.each do |word| + score = score_word(word) + all_scores << {:word => word, :score => score} + end + #puts all_scores + highest_score = all_scores.max_by{|word_with_score| word_with_score[:score]} + p highest_score + +all_highscores = all_scores.select{|word_with_score| word_with_score[:score] == highest_score[:score]} +puts all_highscores + # return {winning_word, score} + +end + highest_score_from(["cat", "hannah", "cheezit", "itcheez"]) + + + + + + + + + + + + + +# letters = [] +# 10.times do +# letter_pool +# end + +# end \ No newline at end of file From 351b809d901d865fe453d818033f49a9b08a2114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannah=20Teki=C3=A9?= Date: Wed, 12 Feb 2020 16:49:17 -0800 Subject: [PATCH 2/7] phase 4 complete YAY --- adagrams.rb | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/adagrams.rb b/adagrams.rb index 865dbf7..515f026 100644 --- a/adagrams.rb +++ b/adagrams.rb @@ -112,7 +112,7 @@ def score_word(word) #word is a string of characters # Wave 4 # method has one parameter (word) # returns a hash (winning word, score) the highest scoring word -# if tied using tie-breaking method (when choosing do the followings: prefer word with fewer letters; +# if tied using tie-breaking method (when choosing do the followings: prefer word with fewer letters ; # if multiple words have the same score, choose the one w/fewest letters unless one word has 10 letters, # if letters and scores are the same, choose the first one you see) @@ -124,14 +124,56 @@ def highest_score_from(words) # words is going to be array of strings end #puts all_scores highest_score = all_scores.max_by{|word_with_score| word_with_score[:score]} - p highest_score + p "This is one max score: #{highest_score}" all_highscores = all_scores.select{|word_with_score| word_with_score[:score] == highest_score[:score]} -puts all_highscores +puts "This is ALL the words that match high score: #{all_highscores}" # return {winning_word, score} + #look in the all_highscores look at the hash and pull the word only + words = [] + all_highscores.each do |hash| + words << hash[:word] + end + + puts "This is our array of just words: #{words}" +# word = ["hhaannhhnn", "cat"] +# if word length != 10 +# then check for smallest word +# if word lenghs are == the same +# choose thes first word + +all_tens = words.select{|word| word.length == 10} +# all_tens = ["hhaannhhnn", "hannahnnaa"] here we are gonna select the first 10 letter word +# 1) if all_tens.size > 1 grab the first itm in the array +# 2) if all_tens.size == 1 grab the first time in the array +# 3) if all_tens.empty? then check for smallest word +winning_word = "" +if all_tens.size >= 1 + winning_word = all_tens[0] +else + all_smallest = words.min_by{|word| word.length} + if all_smallest.class == Array + winning_word = all_smallest[0] + else + winning_word = all_smallest + end end - highest_score_from(["cat", "hannah", "cheezit", "itcheez"]) + +puts "This is our winning word: #{winning_word}" + + + + +end + + + + + + + highest_score_from (["sugarmouses", "mousesugars","z"]) +# (["cat", "hannah", "cheezit", "itcheez"]) From b3aff2c5afaa041150a8cfa9288031e6e0433c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannah=20Teki=C3=A9?= Date: Thu, 13 Feb 2020 15:10:23 -0800 Subject: [PATCH 3/7] Cleaned up adagrams.rb --- adagrams.rb | 160 ++++++++++++++---------------------------- lib/adagrams.rb | 139 ++++++++++++++++++++++++++++++++++++ test/adagrams_test.rb | 2 +- 3 files changed, 192 insertions(+), 109 deletions(-) diff --git a/adagrams.rb b/adagrams.rb index 515f026..783de63 100644 --- a/adagrams.rb +++ b/adagrams.rb @@ -1,6 +1,3 @@ -# writing a method called draw_letters - - # wave 1 # method draw_letters randomly generates 10 letters, stores them in an array, # returns that array of letters @@ -32,8 +29,8 @@ def draw_letters "X": 1, "Y": 2, "Z": 1 - } - expanded_bag = [] + } + expanded_bag = [] compact_bag.each do |letters, number| number.times do expanded_bag << letters @@ -41,19 +38,18 @@ def draw_letters end random = [] + 10.times do x = rand expanded_bag.length - while random.include? x - x = rand expanded_bag.length + while random.include? x + x = rand expanded_bag.length end - random << x + random << x end hand = random.map {|number| expanded_bag[number]} - end - #wave 2 # method uses_available_letters? takes a string and an array of letters # to determine if the string can be made from the array of letters @@ -66,130 +62,78 @@ def uses_available_letters? (input, letters_in_hand) #wave 3 # method score_word takes string of characters # and returns an integer representing the number of points -def score_word(word) #word is a string of characters - -score = 0 - -word.upcase.each_char do |char| - case char - when "A", "E", "I", "O", "U", "L", "N", "R", "S", "T" - score += 1 - when "D", "G" - score += 2 - when "B", "C", "M", "P" - score += 3 - when "F", "H", "V", "W", "Y" - score += 4 - when "K" - score += 5 - when "J", "X" - score += 8 - when "Q", "Z" - score += 10 - else - puts "Invalid char found." +def score_word(word) + score = 0 + + word.upcase.each_char do |char| + case char + when "A", "E", "I", "O", "U", "L", "N", "R", "S", "T" + score += 1 + when "D", "G" + score += 2 + when "B", "C", "M", "P" + score += 3 + when "F", "H", "V", "W", "Y" + score += 4 + when "K" + score += 5 + when "J", "X" + score += 8 + when "Q", "Z" + score += 10 + else + puts "Invalid char found." end end - - if [7,8,9,10].include? word.length score += 8 end return score - end - - -# puts uses_available_letters?("cat" ,["c","a","t", "t", "t"]) -# puts score_word("belvita") - - -my_hand = draw_letters - # Wave 4 # method has one parameter (word) # returns a hash (winning word, score) the highest scoring word # if tied using tie-breaking method (when choosing do the followings: prefer word with fewer letters ; # if multiple words have the same score, choose the one w/fewest letters unless one word has 10 letters, # if letters and scores are the same, choose the first one you see) +def highest_score_from(words) + all_scores = [] -def highest_score_from(words) # words is going to be array of strings - all_scores = [] words.each do |word| - score = score_word(word) - all_scores << {:word => word, :score => score} - end - #puts all_scores - highest_score = all_scores.max_by{|word_with_score| word_with_score[:score]} - p "This is one max score: #{highest_score}" - -all_highscores = all_scores.select{|word_with_score| word_with_score[:score] == highest_score[:score]} -puts "This is ALL the words that match high score: #{all_highscores}" - # return {winning_word, score} - - #look in the all_highscores look at the hash and pull the word only + score = score_word(word) + all_scores << {:word => word, :score => score} + end + + highest_score = all_scores.max_by{|word_with_score| word_with_score[:score]} + p "This is one max score: #{highest_score}" + + all_highscores = all_scores.select{|word_with_score| word_with_score[:score] == highest_score[:score]} + puts "This is ALL the words that match high score: #{all_highscores}" + words = [] all_highscores.each do |hash| words << hash[:word] end puts "This is our array of just words: #{words}" -# word = ["hhaannhhnn", "cat"] -# if word length != 10 -# then check for smallest word -# if word lenghs are == the same -# choose thes first word - -all_tens = words.select{|word| word.length == 10} -# all_tens = ["hhaannhhnn", "hannahnnaa"] here we are gonna select the first 10 letter word -# 1) if all_tens.size > 1 grab the first itm in the array -# 2) if all_tens.size == 1 grab the first time in the array -# 3) if all_tens.empty? then check for smallest word -winning_word = "" -if all_tens.size >= 1 - winning_word = all_tens[0] -else - all_smallest = words.min_by{|word| word.length} - if all_smallest.class == Array - winning_word = all_smallest[0] + all_tens = words.select{|word| word.length == 10} + + winning_word = "" + if all_tens.size >= 1 + winning_word = all_tens[0] + else + all_smallest = words.min_by{|word| word.length} + if all_smallest.class == Array + winning_word = all_smallest[0] else winning_word = all_smallest end + end + puts "This is our winning word: #{winning_word}" + return {:word => winning_word, :score => highest_score} end -puts "This is our winning word: #{winning_word}" - - - - -end - - - - - - - highest_score_from (["sugarmouses", "mousesugars","z"]) -# (["cat", "hannah", "cheezit", "itcheez"]) - - - - - - - - - - - - - -# letters = [] -# 10.times do -# letter_pool -# end - -# end \ No newline at end of file +highest_score_from (["sugarmouses", "mousesugars","z"]) \ No newline at end of file diff --git a/lib/adagrams.rb b/lib/adagrams.rb index e69de29..783de63 100644 --- a/lib/adagrams.rb +++ b/lib/adagrams.rb @@ -0,0 +1,139 @@ +# wave 1 +# method draw_letters randomly generates 10 letters, stores them in an array, +# returns that array of letters +def draw_letters + compact_bag = { + "A": 9, + "B": 2, + "C": 2, + "D": 4, + "E": 12, + "F": 2, + "G": 3, + "H": 2, + "I": 9, + "J": 1, + "K": 1, + "L": 4, + "M": 2, + "N": 6, + "O": 8, + "P": 2, + "Q": 1, + "R": 6, + "S": 4, + "T": 6, + "U": 4, + "V": 2, + "W": 2, + "X": 1, + "Y": 2, + "Z": 1 + } + expanded_bag = [] + compact_bag.each do |letters, number| + number.times do + expanded_bag << letters + end + end + + random = [] + + 10.times do + x = rand expanded_bag.length + while random.include? x + x = rand expanded_bag.length + end + random << x + end + + hand = random.map {|number| expanded_bag[number]} +end + +#wave 2 +# method uses_available_letters? takes a string and an array of letters +# to determine if the string can be made from the array of letters +# returns true if string is valid (can be made from array of letters) +# returns false if string is invalid (cannot be made from array of letters) +def uses_available_letters? (input, letters_in_hand) + input <= letters_in_hand.join +end + +#wave 3 +# method score_word takes string of characters +# and returns an integer representing the number of points +def score_word(word) + score = 0 + + word.upcase.each_char do |char| + case char + when "A", "E", "I", "O", "U", "L", "N", "R", "S", "T" + score += 1 + when "D", "G" + score += 2 + when "B", "C", "M", "P" + score += 3 + when "F", "H", "V", "W", "Y" + score += 4 + when "K" + score += 5 + when "J", "X" + score += 8 + when "Q", "Z" + score += 10 + else + puts "Invalid char found." + end + end + + if [7,8,9,10].include? word.length + score += 8 + end + + return score +end + +# Wave 4 +# method has one parameter (word) +# returns a hash (winning word, score) the highest scoring word +# if tied using tie-breaking method (when choosing do the followings: prefer word with fewer letters ; +# if multiple words have the same score, choose the one w/fewest letters unless one word has 10 letters, +# if letters and scores are the same, choose the first one you see) +def highest_score_from(words) + all_scores = [] + + words.each do |word| + score = score_word(word) + all_scores << {:word => word, :score => score} + end + + highest_score = all_scores.max_by{|word_with_score| word_with_score[:score]} + p "This is one max score: #{highest_score}" + + all_highscores = all_scores.select{|word_with_score| word_with_score[:score] == highest_score[:score]} + puts "This is ALL the words that match high score: #{all_highscores}" + + words = [] + all_highscores.each do |hash| + words << hash[:word] + end + + puts "This is our array of just words: #{words}" + all_tens = words.select{|word| word.length == 10} + + winning_word = "" + if all_tens.size >= 1 + winning_word = all_tens[0] + else + all_smallest = words.min_by{|word| word.length} + if all_smallest.class == Array + winning_word = all_smallest[0] + else + winning_word = all_smallest + end + end + puts "This is our winning word: #{winning_word}" + return {:word => winning_word, :score => highest_score} +end + +highest_score_from (["sugarmouses", "mousesugars","z"]) \ No newline at end of file diff --git a/test/adagrams_test.rb b/test/adagrams_test.rb index 90ec44d..ec43f03 100644 --- a/test/adagrams_test.rb +++ b/test/adagrams_test.rb @@ -1,4 +1,4 @@ -require 'minitest/autorun' +wrequire 'minitest/autorun' require 'minitest/reporters' require 'minitest/skip_dsl' From 21c22a4abae540788dfc3472bc25729d9dc226db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannah=20Teki=C3=A9?= Date: Thu, 13 Feb 2020 16:02:48 -0800 Subject: [PATCH 4/7] 4 waves passed --- adagrams.rb | 139 ------------------------------------------ lib/adagrams.rb | 61 +++++++++--------- test/adagrams_test.rb | 4 +- 3 files changed, 32 insertions(+), 172 deletions(-) delete mode 100644 adagrams.rb diff --git a/adagrams.rb b/adagrams.rb deleted file mode 100644 index 783de63..0000000 --- a/adagrams.rb +++ /dev/null @@ -1,139 +0,0 @@ -# wave 1 -# method draw_letters randomly generates 10 letters, stores them in an array, -# returns that array of letters -def draw_letters - compact_bag = { - "A": 9, - "B": 2, - "C": 2, - "D": 4, - "E": 12, - "F": 2, - "G": 3, - "H": 2, - "I": 9, - "J": 1, - "K": 1, - "L": 4, - "M": 2, - "N": 6, - "O": 8, - "P": 2, - "Q": 1, - "R": 6, - "S": 4, - "T": 6, - "U": 4, - "V": 2, - "W": 2, - "X": 1, - "Y": 2, - "Z": 1 - } - expanded_bag = [] - compact_bag.each do |letters, number| - number.times do - expanded_bag << letters - end - end - - random = [] - - 10.times do - x = rand expanded_bag.length - while random.include? x - x = rand expanded_bag.length - end - random << x - end - - hand = random.map {|number| expanded_bag[number]} -end - -#wave 2 -# method uses_available_letters? takes a string and an array of letters -# to determine if the string can be made from the array of letters -# returns true if string is valid (can be made from array of letters) -# returns false if string is invalid (cannot be made from array of letters) -def uses_available_letters? (input, letters_in_hand) - input <= letters_in_hand.join -end - -#wave 3 -# method score_word takes string of characters -# and returns an integer representing the number of points -def score_word(word) - score = 0 - - word.upcase.each_char do |char| - case char - when "A", "E", "I", "O", "U", "L", "N", "R", "S", "T" - score += 1 - when "D", "G" - score += 2 - when "B", "C", "M", "P" - score += 3 - when "F", "H", "V", "W", "Y" - score += 4 - when "K" - score += 5 - when "J", "X" - score += 8 - when "Q", "Z" - score += 10 - else - puts "Invalid char found." - end - end - - if [7,8,9,10].include? word.length - score += 8 - end - - return score -end - -# Wave 4 -# method has one parameter (word) -# returns a hash (winning word, score) the highest scoring word -# if tied using tie-breaking method (when choosing do the followings: prefer word with fewer letters ; -# if multiple words have the same score, choose the one w/fewest letters unless one word has 10 letters, -# if letters and scores are the same, choose the first one you see) -def highest_score_from(words) - all_scores = [] - - words.each do |word| - score = score_word(word) - all_scores << {:word => word, :score => score} - end - - highest_score = all_scores.max_by{|word_with_score| word_with_score[:score]} - p "This is one max score: #{highest_score}" - - all_highscores = all_scores.select{|word_with_score| word_with_score[:score] == highest_score[:score]} - puts "This is ALL the words that match high score: #{all_highscores}" - - words = [] - all_highscores.each do |hash| - words << hash[:word] - end - - puts "This is our array of just words: #{words}" - all_tens = words.select{|word| word.length == 10} - - winning_word = "" - if all_tens.size >= 1 - winning_word = all_tens[0] - else - all_smallest = words.min_by{|word| word.length} - if all_smallest.class == Array - winning_word = all_smallest[0] - else - winning_word = all_smallest - end - end - puts "This is our winning word: #{winning_word}" - return {:word => winning_word, :score => highest_score} -end - -highest_score_from (["sugarmouses", "mousesugars","z"]) \ No newline at end of file diff --git a/lib/adagrams.rb b/lib/adagrams.rb index 783de63..065c1f5 100644 --- a/lib/adagrams.rb +++ b/lib/adagrams.rb @@ -3,32 +3,32 @@ # returns that array of letters def draw_letters compact_bag = { - "A": 9, - "B": 2, - "C": 2, - "D": 4, - "E": 12, - "F": 2, - "G": 3, - "H": 2, - "I": 9, - "J": 1, - "K": 1, - "L": 4, - "M": 2, - "N": 6, - "O": 8, - "P": 2, - "Q": 1, - "R": 6, - "S": 4, - "T": 6, - "U": 4, - "V": 2, - "W": 2, - "X": 1, - "Y": 2, - "Z": 1 + "A" => 9, + "B" => 2, + "C" => 2, + "D" => 4, + "E" => 12, + "F" => 2, + "G" => 3, + "H" => 2, + "I" => 9, + "J" => 1, + "K" => 1, + "L" => 4, + "M" => 2, + "N" => 6, + "O" => 8, + "P" => 2, + "Q" => 1, + "R" => 6, + "S" => 4, + "T" => 6, + "U" => 4, + "V" => 2, + "W" => 2, + "X" => 1, + "Y" => 2, + "Z" => 1 } expanded_bag = [] compact_bag.each do |letters, number| @@ -36,7 +36,7 @@ def draw_letters expanded_bag << letters end end - + random = [] 10.times do @@ -46,7 +46,7 @@ def draw_letters end random << x end - + hand = random.map {|number| expanded_bag[number]} end @@ -56,7 +56,7 @@ def draw_letters # returns true if string is valid (can be made from array of letters) # returns false if string is invalid (cannot be made from array of letters) def uses_available_letters? (input, letters_in_hand) - input <= letters_in_hand.join + letters_in_hand.join.include? input end #wave 3 @@ -133,7 +133,6 @@ def highest_score_from(words) end end puts "This is our winning word: #{winning_word}" - return {:word => winning_word, :score => highest_score} + return {:word => winning_word, :score => (highest_score[:score])} end -highest_score_from (["sugarmouses", "mousesugars","z"]) \ No newline at end of file diff --git a/test/adagrams_test.rb b/test/adagrams_test.rb index ec43f03..d7a20b1 100644 --- a/test/adagrams_test.rb +++ b/test/adagrams_test.rb @@ -1,4 +1,4 @@ -wrequire 'minitest/autorun' +require 'minitest/autorun' require 'minitest/reporters' require 'minitest/skip_dsl' @@ -42,7 +42,7 @@ test_word = 'DOG' is_valid = uses_available_letters? test_word, drawn_letters - + expect(is_valid).must_equal false end From 3063da08854d8376111e3e18f584740865aba12e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannah=20Teki=C3=A9?= Date: Thu, 13 Feb 2020 16:34:24 -0800 Subject: [PATCH 5/7] we did all 5 --- lib/adagrams.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/adagrams.rb b/lib/adagrams.rb index 065c1f5..f68a07a 100644 --- a/lib/adagrams.rb +++ b/lib/adagrams.rb @@ -1,3 +1,5 @@ +require 'csv' + # wave 1 # method draw_letters randomly generates 10 letters, stores them in an array, # returns that array of letters @@ -136,3 +138,13 @@ def highest_score_from(words) return {:word => winning_word, :score => (highest_score[:score])} end +# wave 5 +# check if the the input is found in the english dictionary +# add a method called is_in_english_dict? +# has one parameter: input, which is a string +# returns a boolean t/f + +def is_in_english_dict? (input) + array_of_dictionary = CSV.read('../assets/dictionary-english.csv').map(&:to_a) + return array_of_dictionary.include? input +end \ No newline at end of file From 065e23c2dfb78cbd7885669c8b0e5d856727676b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannah=20Teki=C3=A9?= Date: Fri, 14 Feb 2020 14:06:51 -0800 Subject: [PATCH 6/7] refactored to use smaller methods --- lib/adagrams.rb | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/adagrams.rb b/lib/adagrams.rb index f68a07a..cceffbb 100644 --- a/lib/adagrams.rb +++ b/lib/adagrams.rb @@ -95,6 +95,8 @@ def score_word(word) return score end + + # Wave 4 # method has one parameter (word) # returns a hash (winning word, score) the highest scoring word @@ -115,27 +117,36 @@ def highest_score_from(words) all_highscores = all_scores.select{|word_with_score| word_with_score[:score] == highest_score[:score]} puts "This is ALL the words that match high score: #{all_highscores}" - words = [] + tied_words = [] all_highscores.each do |hash| - words << hash[:word] + tied_words << hash[:word] end - puts "This is our array of just words: #{words}" - all_tens = words.select{|word| word.length == 10} + winning_word = break_ties(tied_words) + + puts "This is our winning word: #{winning_word}" + return {:word => winning_word, :score => (highest_score[:score])} +end + +# method break_ties applies tie-breaking logic to a set of words with the same score +# parameter: array of words that share the same score +# returns the resulting winning word after tie-breaking rules have been applied +def break_ties(tied_words) + puts "This is our array of just words: #{tied_words}" + all_tens = tied_words.select{|word| word.length == 10} winning_word = "" if all_tens.size >= 1 winning_word = all_tens[0] else - all_smallest = words.min_by{|word| word.length} + all_smallest = tied_words.min_by{|word| word.length} if all_smallest.class == Array winning_word = all_smallest[0] else winning_word = all_smallest end end - puts "This is our winning word: #{winning_word}" - return {:word => winning_word, :score => (highest_score[:score])} + return winning_word end # wave 5 From 67dc8ec12b2818c6d3297e008d98509e32fb7c71 Mon Sep 17 00:00:00 2001 From: Angela Nguyen Date: Fri, 14 Feb 2020 17:10:07 -0800 Subject: [PATCH 7/7] Cleaned up stray line break --- lib/adagrams.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/adagrams.rb b/lib/adagrams.rb index cceffbb..53e0e07 100644 --- a/lib/adagrams.rb +++ b/lib/adagrams.rb @@ -95,8 +95,6 @@ def score_word(word) return score end - - # Wave 4 # method has one parameter (word) # returns a hash (winning word, score) the highest scoring word