From 5f8c308ec26a83a7d260dece93bc00a46ccdb408 Mon Sep 17 00:00:00 2001 From: quin quintero Date: Thu, 13 Feb 2020 16:32:14 -0800 Subject: [PATCH 1/4] first commit from quin --- .DS_Store | Bin 0 -> 8196 bytes adagrams.rb | 127 ++++++++++++++++++++++++++++++++++++++++++++ lib/.DS_Store | Bin 0 -> 6148 bytes lib/adagrams.rb | 137 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 264 insertions(+) create mode 100644 .DS_Store create mode 100644 adagrams.rb create mode 100644 lib/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8cf6334d4ebee37977e914e562f802ec2048fd0c GIT binary patch literal 8196 zcmeHM&2G~`5T0#9aS{PRLTZk_AaN)tNq=%cNFk($9*_`0Z~)ZWjhk9^>?(E|K?ur) zcL3giN8t&05FP-&*nn6?b_dL?T$-CqBZQ+h$=*6!5PaXGz*N! z+0WRDK64u=z$Y4zLw$OG6)ZfaKU3n;NGIB^7h3>Op9#&?SaYbd1{^4s2?iDpYh5 zicUhWEOdn;maP3|~)!v2o=IVEMH;4}0AaW7Gzf=$5_kKx3 zk7yN)7(X5*6lY?;WnxQoh&T_cxL_U7F}@J=sXNaSYZ;bBN90q;^Dm75l!?z#fcVUH zi=T_5+);d@@9w*M68Ldat^N=zx%{=&>y}ltiZ_aHJ4ex|lQ_vRZaIV3eDusoj$GY; z5kPnCC z0%k&FQgD+-NWm#Yx=%HD4@Z3*@wc+jL7A?)KU%=)4zKpwZK9{$Fuu|I~z3%1( zTx^J?+^zGuyh-M`ylHLR2V+y?RH1qQOC3yO6u7JcIW<9r>;IkQ-~TVWjNuyvi~?6! z0g-Qa+AUn*pT8@!*UGiF4c~{eaokj)q@dvtJ}=90;OrlU=-Ya%sd1_hBQWzJK+0em JqrhKP;5SMaLf`-Z literal 0 HcmV?d00001 diff --git a/adagrams.rb b/adagrams.rb new file mode 100644 index 0000000..fa3f293 --- /dev/null +++ b/adagrams.rb @@ -0,0 +1,127 @@ +# Yesenia Torres + Quin Quintero +# adagrams.rb + +# Gems +require "minitest" +require 'pry' +# require "minitest-reporters" +# require "minitest-skip" + +# WAVE 1 +def draw_letters + letter_pool = { + #letter => quantity + :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 + } + + # Create a hand + random_hash = letter_pool.to_a.sample(10).to_h + # puts random_hash + # Subtract letter that has been used from the letter pool + random_hash.each do |key, value| + if random_hash[key] == letter_pool[key] && letter_pool[key] > 1 + letter_pool[key] = value - 1 + else + letter_pool.delete(key) + end + end + # puts letter_pool + # Create hand array + hand = random_hash.map do |letter, quantity| + letter.to_s + end + binding.pry + return hand +end + + +# Check anagram uses letters from the drawn hand +def uses_available_letters?(input, letters_in_hand) + available_letters = letters_in_hand.sort.join.upcase + + user_input = input.split("").sort.join.upcase + + + return available_letters.include? user_input + +end + +# WAVE 3 + +# Calculate score +def score_word(word) + score = 0 + upcased_word = word.upcase + array = upcased_word.split("") + + # Add bonus points + if word.length >= 7 && word.length <=10 + score += 8 + end + + # Update score depending on letters used + array.each do |letter| + if ["A", "E", "I", "O", "U", "L", "N", "R", "S", "T"].include? letter + score +=1 + elsif ["D", "G"].include? letter + score += 2 + elsif ["B", "C", "M", "P"].include? letter + score += 3 + elsif ["F", "H", "V", "W", "Y"].include? letter + score +=4 + elsif ["K"].include? letter + score += 5 + elsif ["J", "X"].include? letter + score += 8 + elsif ["Q", "Z"]. include? letter + score += 10 + else + score += 0 + end + end + + return score +end + +# WAVE 4 + +# Return highest score +def highest_score_from(words, score_word = :score_word) + + highest_hash = {} + + # create a hash of the words and their scores + words.each do |word| + highest_hash.merge!("#{word}": score_word(word.upcase)) + end + + # ------------------------------------------------ our attempt to integrate logic, not currently working + + shortest_word_length = words[0].length + highest_scored_word = "" + highest_score = 0 + + # we want to be able to iterate through esach of the tied highest words and pull out the winner of the tie + highest_hash.each do |word, score| + #will return word if greater than 10 automatically + if word.to_s.length == 10 + highest_scored_word = word.to_s + highest_score = score + break + else + if word.to_s.length <= shortest_word_length + + highest_scored_word = word.to_s + highest_score = score + end + + end + end + return {highest_scored_word => highest_score} +end + +#uts uses_available_letters?("x", ["y", "e", "s"]) +puts draw_letters.to_s diff --git a/lib/.DS_Store b/lib/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5b0c860fcde8691e0e4626de8d8773bcc1439e98 GIT binary patch literal 6148 zcmeHKu}TC{3{3QjgKMs|e5I9OZSy$p3TuBr*8`iA1I2zTzso=KW|AN*iy(rHOdxOa zvYCCmQ*1V7=9{KHd%d@-qyPObSQ=DIf);fE4(h0_?r8$;=s=#?}*X;j0_&4+al%$;$kOKco0bgwIwi~=s_14+TvDY^EJ)AWka2n#E nV2O4NjCPC-+wnydWnE*8>%DMH3_9{b2kK{ly2zx!Un_6|%48eC literal 0 HcmV?d00001 diff --git a/lib/adagrams.rb b/lib/adagrams.rb index e69de29..b4a3a79 100644 --- a/lib/adagrams.rb +++ b/lib/adagrams.rb @@ -0,0 +1,137 @@ +# Yesenia Torres + Quin Quintero +# adagrams.rb + +# Gems +require "minitest" + +# require "minitest-reporters" +# require "minitest-skip" + +# WAVE 1 +def draw_letters + letter_pool = { + #letter => quantity + :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 + } + + # Create a hand + random_hash = letter_pool.to_a.sample(10).to_h + # puts random_hash + # Subtract letter that has been used from the letter pool + random_hash.each do |key, value| + if random_hash[key] == letter_pool[key] && letter_pool[key] > 1 + letter_pool[key] = value - 1 + else + letter_pool.delete(key) + end + end + # puts letter_pool + # Create hand array + hand = random_hash.map do |letter, quantity| + letter.to_s + end + + return hand +end + + +# Check anagram uses letters from the drawn hand +def uses_available_letters?(input, letters_in_hand) + available_letters = letters_in_hand.sort.join.upcase + + user_input = input.split("").sort.join.upcase + + + return available_letters.include? user_input + +end + +# WAVE 3 + +# Calculate score +def score_word(word) + score = 0 + upcased_word = word.upcase + array = upcased_word.split("") + + # Add bonus points + if word.length >= 7 && word.length <=10 + score += 8 + end + + # Update score depending on letters used + array.each do |letter| + if ["A", "E", "I", "O", "U", "L", "N", "R", "S", "T"].include? letter + score +=1 + elsif ["D", "G"].include? letter + score += 2 + elsif ["B", "C", "M", "P"].include? letter + score += 3 + elsif ["F", "H", "V", "W", "Y"].include? letter + score +=4 + elsif ["K"].include? letter + score += 5 + elsif ["J", "X"].include? letter + score += 8 + elsif ["Q", "Z"]. include? letter + score += 10 + else + score += 0 + end + end + + return score +end + +# WAVE 4 + +# Return highest score +def highest_score_from(words, score_word = :score_word) + + highest_hash = {} + # create a hash of the words and their scores + words.each do |word| + #highest_hash.merge!("#{word}": score_word(word.upcase)) + highest_hash[word] = score_word(word.upcase) + end + # ------------------------------------------------ our attempt to integrate logic, not currently working + + shortest_word_length = words[0].length + highest_scored_word = "" + highest_score = 0 + + # we want to be able to iterate through esach of the tied highest words and pull out the winner of the tie + highest_hash.each do |word, score| + #will return word if greater than 10 automatically + if word.length == 10 + highest_scored_word = word + highest_score = score + return {highest_scored_word => highest_score} + else + + # if highest_score < score + # highest_score = score + # highest_scored_word = word + # elsif highest_score == score + # if highest_scored_word.length < word.length + # return {highest_scored_word => highest_score} + # else highest_scored_word.length > word.length + # return {word => score} + # end + # end + # iword.to_s.length <= shortest_word_length + + # highest_scored_word = word.to_s + # highest_score = score + # return {highest_scored_word => highest_score} + # end + end + end + #return {highest_scored_word => highest_score} +end + +#uts uses_available_letters?("x", ["y", "e", "s"]) +puts highest_score_from(["x", "xx", "xxx", "xxxx"]) From 6391c35b32849d61692d3c595d9031d14f27e90e Mon Sep 17 00:00:00 2001 From: Yesenia Date: Thu, 13 Feb 2020 22:40:21 -0800 Subject: [PATCH 2/4] Fixed Wave 4 method. --- lib/adagrams.rb | 105 ++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 58 deletions(-) diff --git a/lib/adagrams.rb b/lib/adagrams.rb index b4a3a79..87a816c 100644 --- a/lib/adagrams.rb +++ b/lib/adagrams.rb @@ -1,13 +1,12 @@ # Yesenia Torres + Quin Quintero # adagrams.rb -# Gems require "minitest" - # require "minitest-reporters" # require "minitest-skip" # WAVE 1 + def draw_letters letter_pool = { #letter => quantity @@ -17,36 +16,35 @@ def draw_letters :W => 2, :X => 1,:Y => 2,:Z => 1 } - # Create a hand - random_hash = letter_pool.to_a.sample(10).to_h - # puts random_hash - # Subtract letter that has been used from the letter pool - random_hash.each do |key, value| + # Create a hand + random_hash = letter_pool.to_a.sample(10).to_h + # puts random_hash + # Subtract letter that has been used from the letter pool + random_hash.each do |key, value| if random_hash[key] == letter_pool[key] && letter_pool[key] > 1 letter_pool[key] = value - 1 else letter_pool.delete(key) end - end - # puts letter_pool - # Create hand array - hand = random_hash.map do |letter, quantity| - letter.to_s - end + end + + # Create hand array + hand = random_hash.map do |letter, quantity| + letter.to_s + end return hand end +# WAVE 2 -# Check anagram uses letters from the drawn hand +# Check user input is using the letters from the drawn hand def uses_available_letters?(input, letters_in_hand) available_letters = letters_in_hand.sort.join.upcase user_input = input.split("").sort.join.upcase - return available_letters.include? user_input - end # WAVE 3 @@ -89,49 +87,40 @@ def score_word(word) # WAVE 4 # Return highest score -def highest_score_from(words, score_word = :score_word) - - highest_hash = {} - # create a hash of the words and their scores - words.each do |word| - #highest_hash.merge!("#{word}": score_word(word.upcase)) - highest_hash[word] = score_word(word.upcase) +def highest_score_from(words) + # Create a hash of the words and their scores results + score_results = {} + words.each do |word| + score_results[word] = score_word(word.upcase) end - # ------------------------------------------------ our attempt to integrate logic, not currently working - - shortest_word_length = words[0].length - highest_scored_word = "" - highest_score = 0 - - # we want to be able to iterate through esach of the tied highest words and pull out the winner of the tie - highest_hash.each do |word, score| - #will return word if greater than 10 automatically - if word.length == 10 - highest_scored_word = word - highest_score = score - return {highest_scored_word => highest_score} - else + + # Find highest score in score_results + highest_pair = score_results.max_by {|key, value| value} + highest_score = highest_pair[1] + + # Collect a hash of the tied highest words + tied_highest_words = score_results.select {|key, value| value == highest_score} + + # If there is no tie for the highest word, return the winning word/score pair + winner = "" + if tied_highest_words.to_a.length == 1 + winner = tied_highest_words + return {:word => tied_highest_words.keys[0], :score => highest_score} # return final result in appropriate format + end - # if highest_score < score - # highest_score = score - # highest_scored_word = word - # elsif highest_score == score - # if highest_scored_word.length < word.length - # return {highest_scored_word => highest_score} - # else highest_scored_word.length > word.length - # return {word => score} - # end - # end - # iword.to_s.length <= shortest_word_length - - # highest_scored_word = word.to_s - # highest_score = score - # return {highest_scored_word => highest_score} - # end - end + # If there is a tie, apply logic to find the tie breaker + tie_breaker = tied_highest_words.keys + tie_winner = tie_breaker.first # intentionally use .first so that if multiple words are the same score and the same length, the first one in the supplied list is chosen + tie_breaker.each do |word| + # A word with length 10 automatically wins the tie + if word.length == 10 + tie_winner = word + return {:word => tie_winner, :score => highest_score} + # Or the shortest length word wins the tie + elsif word.length < tie_winner.length + tie_winner = word + end end - #return {highest_scored_word => highest_score} -end -#uts uses_available_letters?("x", ["y", "e", "s"]) -puts highest_score_from(["x", "xx", "xxx", "xxxx"]) + return {:word => tie_winner, :score => highest_score} +end \ No newline at end of file From 1d51bb350d9a9533fd622c199c3e8838ad47dafb Mon Sep 17 00:00:00 2001 From: quin quintero Date: Fri, 14 Feb 2020 10:51:33 -0800 Subject: [PATCH 3/4] added correct tabbing --- .DS_Store | Bin 8196 -> 8196 bytes adagrams.rb | 127 --------------------------------------------- lib/adagrams.rb | 134 ++++++++++++++++++++++++------------------------ 3 files changed, 67 insertions(+), 194 deletions(-) delete mode 100644 adagrams.rb diff --git a/.DS_Store b/.DS_Store index 8cf6334d4ebee37977e914e562f802ec2048fd0c..f5f06ca70c402bb54e65c7e0712cad2b78cb5df2 100644 GIT binary patch delta 60 zcmZp1XmOa}FDk&mz`)4B0HjJ7iam4klaq4tlQtGkW1rZ-yP2JXg@aLGvy(tP%jOc9 P3Ct54cs8?3{AC9K(@7AR delta 87 zcmZp1XmOa}FDl5uz`)4BAi%&-#E{64%TUaq$56Dfa2or>2Hwr=94s7Q72H6%6d+EA cshWIFSb~c|<3AWMFl^=#h-cZnP$Zcf07|kJ&Hw-a diff --git a/adagrams.rb b/adagrams.rb deleted file mode 100644 index fa3f293..0000000 --- a/adagrams.rb +++ /dev/null @@ -1,127 +0,0 @@ -# Yesenia Torres + Quin Quintero -# adagrams.rb - -# Gems -require "minitest" -require 'pry' -# require "minitest-reporters" -# require "minitest-skip" - -# WAVE 1 -def draw_letters - letter_pool = { - #letter => quantity - :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 - } - - # Create a hand - random_hash = letter_pool.to_a.sample(10).to_h - # puts random_hash - # Subtract letter that has been used from the letter pool - random_hash.each do |key, value| - if random_hash[key] == letter_pool[key] && letter_pool[key] > 1 - letter_pool[key] = value - 1 - else - letter_pool.delete(key) - end - end - # puts letter_pool - # Create hand array - hand = random_hash.map do |letter, quantity| - letter.to_s - end - binding.pry - return hand -end - - -# Check anagram uses letters from the drawn hand -def uses_available_letters?(input, letters_in_hand) - available_letters = letters_in_hand.sort.join.upcase - - user_input = input.split("").sort.join.upcase - - - return available_letters.include? user_input - -end - -# WAVE 3 - -# Calculate score -def score_word(word) - score = 0 - upcased_word = word.upcase - array = upcased_word.split("") - - # Add bonus points - if word.length >= 7 && word.length <=10 - score += 8 - end - - # Update score depending on letters used - array.each do |letter| - if ["A", "E", "I", "O", "U", "L", "N", "R", "S", "T"].include? letter - score +=1 - elsif ["D", "G"].include? letter - score += 2 - elsif ["B", "C", "M", "P"].include? letter - score += 3 - elsif ["F", "H", "V", "W", "Y"].include? letter - score +=4 - elsif ["K"].include? letter - score += 5 - elsif ["J", "X"].include? letter - score += 8 - elsif ["Q", "Z"]. include? letter - score += 10 - else - score += 0 - end - end - - return score -end - -# WAVE 4 - -# Return highest score -def highest_score_from(words, score_word = :score_word) - - highest_hash = {} - - # create a hash of the words and their scores - words.each do |word| - highest_hash.merge!("#{word}": score_word(word.upcase)) - end - - # ------------------------------------------------ our attempt to integrate logic, not currently working - - shortest_word_length = words[0].length - highest_scored_word = "" - highest_score = 0 - - # we want to be able to iterate through esach of the tied highest words and pull out the winner of the tie - highest_hash.each do |word, score| - #will return word if greater than 10 automatically - if word.to_s.length == 10 - highest_scored_word = word.to_s - highest_score = score - break - else - if word.to_s.length <= shortest_word_length - - highest_scored_word = word.to_s - highest_score = score - end - - end - end - return {highest_scored_word => highest_score} -end - -#uts uses_available_letters?("x", ["y", "e", "s"]) -puts draw_letters.to_s diff --git a/lib/adagrams.rb b/lib/adagrams.rb index 87a816c..57d3daa 100644 --- a/lib/adagrams.rb +++ b/lib/adagrams.rb @@ -8,80 +8,80 @@ # WAVE 1 def draw_letters - letter_pool = { + letter_pool = { #letter => quantity - :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 } # Create a hand - random_hash = letter_pool.to_a.sample(10).to_h + random_hash = letter_pool.to_a.sample(10).to_h # puts random_hash # Subtract letter that has been used from the letter pool - random_hash.each do |key, value| - if random_hash[key] == letter_pool[key] && letter_pool[key] > 1 - letter_pool[key] = value - 1 - else - letter_pool.delete(key) - end + random_hash.each do |key, value| + if random_hash[key] == letter_pool[key] && letter_pool[key] > 1 + letter_pool[key] = value - 1 + else + letter_pool.delete(key) + end end # Create hand array - hand = random_hash.map do |letter, quantity| - letter.to_s - end + hand = random_hash.map do |letter, quantity| + letter.to_s + end - return hand + return hand end # WAVE 2 # Check user input is using the letters from the drawn hand def uses_available_letters?(input, letters_in_hand) - available_letters = letters_in_hand.sort.join.upcase + available_letters = letters_in_hand.sort.join.upcase - user_input = input.split("").sort.join.upcase + user_input = input.split("").sort.join.upcase - return available_letters.include? user_input + return available_letters.include? user_input end # WAVE 3 # Calculate score def score_word(word) - score = 0 - upcased_word = word.upcase - array = upcased_word.split("") + score = 0 + upcased_word = word.upcase + array = upcased_word.split("") # Add bonus points - if word.length >= 7 && word.length <=10 - score += 8 - end + if word.length >= 7 && word.length <=10 + score += 8 + end # Update score depending on letters used - array.each do |letter| - if ["A", "E", "I", "O", "U", "L", "N", "R", "S", "T"].include? letter - score +=1 - elsif ["D", "G"].include? letter - score += 2 - elsif ["B", "C", "M", "P"].include? letter - score += 3 - elsif ["F", "H", "V", "W", "Y"].include? letter - score +=4 - elsif ["K"].include? letter - score += 5 - elsif ["J", "X"].include? letter - score += 8 - elsif ["Q", "Z"]. include? letter - score += 10 - else - score += 0 - end + array.each do |letter| + if ["A", "E", "I", "O", "U", "L", "N", "R", "S", "T"].include? letter + score +=1 + elsif ["D", "G"].include? letter + score += 2 + elsif ["B", "C", "M", "P"].include? letter + score += 3 + elsif ["F", "H", "V", "W", "Y"].include? letter + score +=4 + elsif ["K"].include? letter + score += 5 + elsif ["J", "X"].include? letter + score += 8 + elsif ["Q", "Z"]. include? letter + score += 10 + else + score += 0 end + end - return score + return score end # WAVE 4 @@ -89,38 +89,38 @@ def score_word(word) # Return highest score def highest_score_from(words) # Create a hash of the words and their scores results - score_results = {} - words.each do |word| - score_results[word] = score_word(word.upcase) - end + score_results = {} + words.each do |word| + score_results[word] = score_word(word.upcase) + end # Find highest score in score_results - highest_pair = score_results.max_by {|key, value| value} - highest_score = highest_pair[1] + highest_pair = score_results.max_by {|key, value| value} + highest_score = highest_pair[1] # Collect a hash of the tied highest words - tied_highest_words = score_results.select {|key, value| value == highest_score} + tied_highest_words = score_results.select {|key, value| value == highest_score} # If there is no tie for the highest word, return the winning word/score pair - winner = "" - if tied_highest_words.to_a.length == 1 - winner = tied_highest_words - return {:word => tied_highest_words.keys[0], :score => highest_score} # return final result in appropriate format - end + winner = "" + if tied_highest_words.to_a.length == 1 + winner = tied_highest_words + return {:word => tied_highest_words.keys[0], :score => highest_score} # return final result in appropriate format + end # If there is a tie, apply logic to find the tie breaker - tie_breaker = tied_highest_words.keys - tie_winner = tie_breaker.first # intentionally use .first so that if multiple words are the same score and the same length, the first one in the supplied list is chosen - tie_breaker.each do |word| + tie_breaker = tied_highest_words.keys + tie_winner = tie_breaker.first # intentionally use .first so that if multiple words are the same score and the same length, the first one in the supplied list is chosen + tie_breaker.each do |word| # A word with length 10 automatically wins the tie - if word.length == 10 - tie_winner = word - return {:word => tie_winner, :score => highest_score} + if word.length == 10 + tie_winner = word + return {:word => tie_winner, :score => highest_score} # Or the shortest length word wins the tie - elsif word.length < tie_winner.length - tie_winner = word - end - end + elsif word.length < tie_winner.length + tie_winner = word + end + end - return {:word => tie_winner, :score => highest_score} + return {:word => tie_winner, :score => highest_score} end \ No newline at end of file From def9813e88f0a773008f50af41dcf419c78159f2 Mon Sep 17 00:00:00 2001 From: quin quintero Date: Fri, 14 Feb 2020 13:51:06 -0800 Subject: [PATCH 4/4] changed data structure from hash to array --- .DS_Store | Bin 8196 -> 8196 bytes lib/adagrams.rb | 33 +++++++-------------------------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/.DS_Store b/.DS_Store index f5f06ca70c402bb54e65c7e0712cad2b78cb5df2..5a59f9b04311c9cef25db70327c8ffeaa266fbfa 100644 GIT binary patch delta 20 bcmZp1XmQwZUx?k*R7b(c++g!FAvs quantity - :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 - } - - # Create a hand - random_hash = letter_pool.to_a.sample(10).to_h - # puts random_hash - # Subtract letter that has been used from the letter pool - random_hash.each do |key, value| - if random_hash[key] == letter_pool[key] && letter_pool[key] > 1 - letter_pool[key] = value - 1 - else - letter_pool.delete(key) - end - end - - # Create hand array - hand = random_hash.map do |letter, quantity| - letter.to_s - end - - return hand + letter_pool = ["A", "A", "A", "A", "A", "A", "A", "A", "A", "B", "B", "C", "C", "D", "D", "D", "D", "E", "E","E", "E","E", "E" ,"E", "E","E", "E", "E", "E", + "F", "F", "G", "G", "G", "H", "H", "I", "I", "I", "I", "I", "I", "I", "I", "I", "J", "K", "L", "L", "L", "L", "M", "M", "N", "N", "N", "N", "N", "N", + "O", "O", "O", "O", "O", "O", "O", "O", "P", "P", "Q", "R", "R", "R", "R", "R", "R", "S", "S", "S", "S", + "T", "T", "T", "T", "T", "T", "U", "U", "U", "U", "V", "V", "W", "W", "X", "Y", "Y", "Z" + ] + random_hash = letter_pool.sample(10) + return random_hash end # WAVE 2