Open
Conversation
CheezItMan
reviewed
Sep 23, 2020
Collaborator
CheezItMan
left a comment
There was a problem hiding this comment.
Well done Aimee & Ida. You hit the learning goals here. I like the use of Enumerable methods here. It's quite well done and very compact.
| @@ -0,0 +1,139 @@ | |||
| # frozen_string_literal: true | |||
|
|
|||
| a = Array.new(9) { 'A' } | |||
Collaborator
There was a problem hiding this comment.
This method works, but it's pretty long-hand.
Comment on lines
+30
to
+41
| ALPHABET = [a, b, c, d, e, f, g, h, i, j, k, l, m, n, | ||
| o, p, q, r, s, t, u, v, w, x, y, z].flatten | ||
|
|
||
| SCORE_CHART = [ | ||
| { 1 => %w[A E I O U L N R S T] }, | ||
| { 2 => %w[D G] }, | ||
| { 3 => %w[B C M P] }, | ||
| { 4 => %w[F H V W Y] }, | ||
| { 5 => %w[K] }, | ||
| { 8 => %w[J X] }, | ||
| { 10 => %w[Q Z] } | ||
| ].freeze |
Collaborator
There was a problem hiding this comment.
I like how you included these constants at the top for reference.
Comment on lines
+43
to
+47
| # wave 1 | ||
| def draw_letters | ||
| ten_letters = ALPHABET.sample(10) | ||
| return ten_letters | ||
| end |
Comment on lines
+73
to
+75
| count = letter_frequency[letter] | ||
| count += 1 | ||
| letter_frequency[letter] = count |
Collaborator
There was a problem hiding this comment.
A little simplification.
Suggested change
| count = letter_frequency[letter] | |
| count += 1 | |
| letter_frequency[letter] = count | |
| letter_frequency[letter] += 1 |
Comment on lines
+57
to
+64
| count = letter_count[letter] | ||
| if count == 0 | ||
| false | ||
| else | ||
| count -= 1 | ||
| letter_count[letter] = count | ||
| true | ||
| end |
Collaborator
There was a problem hiding this comment.
This works, but you can simplify it a bit.
Suggested change
| count = letter_count[letter] | |
| if count == 0 | |
| false | |
| else | |
| count -= 1 | |
| letter_count[letter] = count | |
| true | |
| end | |
| letter_count[letter] -= 1 | |
| letter_count[letter] < 0 |
| end | ||
|
|
||
| # wave 3 | ||
| def score_word(word) |
Collaborator
There was a problem hiding this comment.
👍
Really clever use of select, and include?.
Comment on lines
+101
to
+102
| # wave 4 | ||
| def highest_score_from(words) |
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.
Assignment Submission: Adagrams
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection
Enumerablemixin? If so, where and why was it helpful?