-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sockets - Bita and Maria #25
base: master
Are you sure you want to change the base?
Conversation
AdagramsWhat We're Looking For
|
@@ -0,0 +1,12 @@ | |||
# wirte a method with no parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future make sure to clean up files you aren't using.
if index.nil? | ||
return false | ||
else | ||
letters_in_hand.delete_at(index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this deletes letters as it finds them if the user inputs an invalid word the letters it does use will be deleted.
For example:
$ ruby wave-2-game.rb
Welcome to Adagrams!
Let's draw 10 letters from the letter pool...
You have drawn the letters:
N, K, E, I, W, V, R, A, A, E
Please input a word that only uses the letters from the letter bank
NAAA
You entered in a word that contains characters not in the letter bank
Please input a word that only uses the letters from the letter bank
NA
You entered in a word that contains characters not in the letter bank
Please input a word that only uses the letters from the letter bank
end | ||
|
||
scores_hash = Hash[words.zip scores] | ||
puts "scores_hash #{scores_hash}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future you should remove debugging puts
before submitting an assignment.
Leaving the puts
in means the user will see extra output when they try to play the game.
$ ruby wave-4-game.rb
Welcome to Adagrams!
Let's draw 10 letters from the letter pool...
You have drawn the letters:
L, E, M, G, E, F, O, N, D, R
Please input your submission for the longest anagram you can come up with
LEMG
Your submitted anagram scored 7 points
Should we play another round?
Enter y to replay
y
Let's draw 10 letters from the letter pool...
You have drawn the letters:
O, P, Z, E, E, O, D, J, H, T
Please input your submission for the longest anagram you can come up with
OPZEE
Your submitted anagram scored 16 points
Should we play another round?
Enter y to replay
scores_hash {"LEMG"=>7, "OPZEE"=>16}
winner_score {"OPZEE"=>16}
winner_score.length 1
Thanks for playing Adagrams!
The highest score from this game was OPZEE, which was worth 16 points
Goodbye!
puts "scores_hash #{scores_hash}" | ||
winner_score = scores_hash.select { |_key, value| value == scores_hash.values.max } | ||
puts "winner_score #{winner_score}" | ||
puts "winner_score.length #{winner_score.length}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debugging puts
.
elsif long_words.length > 1 | ||
winner = long_words[0] | ||
else | ||
short_words = winner_score.min_by { |key, _value| key.length } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to use more descriptive names. For example in this case you could do something like:
short_words = winner_score.min_by { |word, _score| word.length }
Adagrams
Congratulations! You're submitting your assignment.
Comprehension Questions
Enumerable
mixin? If so, where and why was it helpful?