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

Naheed & Sigrid - Edges - Adagrams #5

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

Conversation

sdbenezra
Copy link

Adagrams

Congratulations! You're submitting your assignment.

Comprehension Questions

Feature Feedback
What are the components that make up a method? method signature, block, return statement
What are the advantages of using git when collaboratively working on one code base? Each person can make changes individually and asynchronously and git can keep track of those changes and help merge them.
What kind of relationship did you and your pair have with the unit tests? We used them as a tool to check if we were on the right track with our methods.
Does your code use any methods from the Enumerable mixin? If so, where and why was it helpful? The only method we used was .each to iterate through our array of words when finding the word with the maximum score.
What was one method you and your pair used to debug code? We used pry.
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 how pairing forced us to slow down and plan our method of attack collaboratively instead of just throwing spaghetti at the wall. It was good practice for thinking about code methodically, and helped us practice explaining code with proper terminology. It was also nice to take turns with driving and thinking to look at the task from different perspectives.

@droberts-sea
Copy link

Adagrams

What We're Looking For

Feature Feedback
General
Answered comprehension questions yes
Both teammates contributed to the codebase yes
Small commits with meaningful commit messages yes
Code Requirements
draw_letters method
Uses appropriate data structure to store the letter distribution see inline
All tests for draw_letters pass yes
uses_available_letters? method
All tests for uses_available_letters? pass yes
score_word method
Uses appropriate data structure to store the letter scores see inline
All tests for score_word pass yes
highest_score_from method
Appropriately handles edge cases for tie-breaking logic yes
All tests for highest_score_from pass yes
Overall

This code is for the most part well-organized and easy to read, and does a good job of solving the problem at hand. The place where I see room for improvement is around your choice of data structures. For both draw_letters and score_word, you built something complex using arrays and missed a simpler solution that uses hashes. While it's impressive that you got the more complex solutions, hashes are an essential tool of the trade, and spending some extra time studying to become more comfortable with them is absolutely worth your while.

That being said, I am generally pretty happy with what I see. Keep up the hard work!

hand = []

initial_array = [["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]]

Choose a reason for hiding this comment

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

I like the idea of this data structure, but I think you could simplify it a bit by using a hash, where the keys are letters and the values are counts. Something like:

{
  "A" => 9,
  "B" => 2,
  # ...
}

word = input.chars
word.each do |letter|
if letters_in_hand.include?(letter)
letters_in_hand.delete_at(letters_in_hand.index(letter))

Choose a reason for hiding this comment

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

This isn't something we checked for in the tests, but it's worth pointing out that this method is destructive. By calling it, you modify the array letters_in_hand. To me this feels like an unexpected behavior - it's not obvious that "check whether this word is made up of letters in this hand" is a process that will change the hand itself. Unexpected behaviors are often where bugs can creep in, especially when there's more than one person working on something.

if %w[A E I O U L N R S T].include?(letter)
score += 1
elsif %w[D G].include?(letter)
score += 2

Choose a reason for hiding this comment

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

While using a big if statement like this works just fine, the information about letter scores is trapped in this code. If you wanted to use that information elsewhere (for example, to tell the user what the letters in their hand are worth) you would have to repeat it.

Instead, it might work well to store the data in a hash, something like this:

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

Then to get the score for a letter, you can say LETTER_SCORES[letter]

winning_word = ""
max_values = []
min_length = 10
hash = {}

Choose a reason for hiding this comment

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

The variable names array and hash here could use some improvement. While technically correct, they don't give the reader any information about how they're used or what sort of data they store. Instead you might use words_with_scores and best_word_and_score.

def is_in_english_dict?(input)
check = false
dictionary = CSV.open('assets/dictionary-english.csv')
word = input.downcase

Choose a reason for hiding this comment

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

Good work on the optional!

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