Sockets - Bita and Maria #25
Open
MariaWissler wants to merge 10 commits into
Open
Conversation
AdagramsWhat We're Looking For
|
kaidamasaki
reviewed
Mar 4, 2019
| @@ -0,0 +1,12 @@ | |||
| # wirte a method with no parameters | |||
There was a problem hiding this comment.
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.
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.
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}" |
| 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.
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 }
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adagrams
Congratulations! You're submitting your assignment.
Comprehension Questions
Enumerablemixin? If so, where and why was it helpful?