Skip to content
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

Implemented functions to pass rake tests and make wave_5 file into a playable Adagrams game #3

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

Beatress
Copy link

Assignment Submission: Adagrams

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

Reflection

Feature Feedback
What are the components that make up a method? A method is made of a method signature and a body. The method signature contains the method name and the parameters it takes as input. The method body is where the method performs the necessary functions before returning (explicitly or implicitly) a value
What are the advantages of using git when collaboratively working on one code base? Changes are backed up incrementally so it is easy to revert back to a previous stage of the process. Teammates can use push and pull to quickly get up to speed with each other without cumbersome zipping and emailing/slacking files.
What kind of relationship did you and your pair have with the unit tests? The unit tests were a useful way of checking when we were finished, although we often used RubyMine's debugger or put statements to verify as we went. I think we passed rake on our first go each time! Although we later found some bugs in playing the game that were not uncovered by rake
Does your code use any methods from the Enumerable mixin? If so, where and why was it helpful? We used several Enumerable methods including .map to call the score_word method to find the score for each word, .max_by to find the highest score, and min_by to find the shortest word length.
What was one method you and your pair used to debug code? We used a mix of running tests in the console (with puts statements) and using the RubyMine debugger
What are two discussion points that you and your pair discussed when giving/receiving feedback from each other that you would be willing to share? We discussed prioritizing the roles of driver and navigator and ensuring that each person made a conscious effort to stay within their relative role while working. We also discussed points where we taught/learned from each other and how that helped us while we were working.

Copy link

@beccaelenzil beccaelenzil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adagrams

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Correctly creates and calls methods with proper syntax (parameters, return statements, etc.) ✔️
Uses correct syntax for conditional logic and iteration ✔️
Practices git with at least 3 small commits and meaningful commit messages ✔️
Utilizes unit tests to verify code; tests can run using the command $ rake and we see test successes and/or failures ✔️
Practices pair programming; the reflection question on pair programming is answered ✔️

Functional Requirements

Functional Requirement yes/no
For the draw_letters method, there is an appropriate data structure to store the letter distribution. (You are more likely to draw an 'E' than an 'X'.) ✔️
Utilizes unit tests to verify code; all tests for draw_letters and uses_available_letters? pass ✔️
Utilizes unit tests to verify code; all tests for score_word pass ✔️
Utilizes unit tests to verify code; all tests for highest_score_from pass ✔️

Overall Feedback

Great work on this project! It is clear that the learning goals around manipulating data and writing methods were met. You've made good use of enumerables to work through some tricky logic. Keep in mind that comments are a great tool to increase the readability of your code. Keep up the hard work!

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 4+ in Code Review && 3+ in Functional Requirements ✔️
Yellow (Approaches Standards) 3+ in Code Review && 2+ in Functional Requirements
Red (Not at Standard) 0-2 in Code Review or 0,1 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Concise

def score_word(word)
score = 0
word.upcase!
word.each_char do |char|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this case statement works, it means that the information about which letter has which score is locked into this piece of code, and can't easily be used elsewhere. For example, if you wanted to display the value of each letter in a hand, you would need to repeat this work.

An alternative approach would be to store the letter scores in a hash, something like this:

LETTER_SCORES = {
  "A" => 1
  "B" => 3,
  "C" => 3,
  "D" => 2,
  # ...
}

return find_winner(smallest_length, winning_hash, max_score)
end

def is_in_english_dict?(input)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work implementing this feature.

Comment on lines +83 to +113
def find_winner(length, winning_hash, max_score)
winning_words = []
winning_hash.each_key do |word|
winning_words << word if word.length == length
end

unless winning_words.empty?
winner = {
word: winning_words[0],
score: max_score
}
return winner
end
return nil
end


def highest_score_from(words)

scores = words.map{|word| score_word(word)}
max_hash = Hash[words.zip scores]

max_score = max_hash.max_by{|k, v| v}[1]
winning_hash = max_hash.keep_if{|k, v| v == max_score}

smallest_length = winning_hash.min_by { |k, v| k.length}[0].length

winner = find_winner(10, winning_hash, max_score)
return winner if winner != nil

return find_winner(smallest_length, winning_hash, max_score)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding comments to these two methods two describe each of their roles. You've packed in nice use of enumerable methods, and done a good job breaking out logic, but it's a little tricky to read these methods and easily understand what is being done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants