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

Kay and Laura.rb #21

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

Conversation

lauracodecreations
Copy link

Adagrams

Congratulations! You're submitting your assignment.

Comprehension Questions

Feature Feedback
What are the components that make up a method? method signature, body block, parameters
What are the advantages of using git when collaboratively working on one code base? you make sure you are both working on the most updated version of the file.
What kind of relationship did you and your pair have with the unit tests? we learned how to debug them, create them, and how to use pry with it, and their syntax
Does your code use any methods from the Enumerable mixin? If so, where and why was it helpful? yes, it helped us to more efficiently iterate through the data structure. We used max_by to select max score and .sort_by to sort the strings by length and select, to select the key that matched the value
What was one method you and your pair used to debug code? pry, and irb
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? how we improved our communication as the days passed, and how we became more efficient presenting and emerging ideas especially using the white board

@CheezItMan
Copy link

Adagrams

What We're Looking For

Feature Feedback
General
Answered comprehension questions Check
Both teammates contributed to the codebase I assume so
Small commits with meaningful commit messages Small commits, for your messages I suggest you avoid mentioning waves and talk about the functionality added.
Code Requirements
draw_letters method Check, but it's a bit awkward. I left some notes in the codebase.
Uses appropriate data structure to store the letter distribution Well done!
All tests for draw_letters pass Check
uses_available_letters? method Check, but you have some redundant code here. I left notes in the code.
All tests for uses_available_letters? pass Check
score_word method Check
Uses appropriate data structure to store the letter scores Nice!
All tests for score_word pass Check
highest_score_from method Yes, but you have some inefficiencies here. You loop through the tied words and each time the loop goes, it sorts the list again.
Appropriately handles edge cases for tie-breaking logic It works.
All tests for highest_score_from pass Check
Overall Overall you did ok, you had some inefficiencies and need to refactor your code.

def draw_letters

# all letters
letters = %W(a a a a a a a a a b b c c d d d d e e e e e e e e e e e e f f g g g h h i i i i i i i i i j k l l l l m m n n n n n n o o o o o o o o p p q r r r r r r s s s s t t t t t t u u u u v v w w x y y z )

Choose a reason for hiding this comment

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

Good data structure to use!

10.times do
# check if index is in indices_used array , if true generate new random index
while indices_used.include?(index)
index = Random.rand(min..max)

Choose a reason for hiding this comment

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

Just a note, this loop could potentially go a long time. You would do better to remove an element once you've selected it.

result << true
else
# user used a letter that does not exists
result << false

Choose a reason for hiding this comment

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

Maybe you should just return false.

input.each_char do |letter|
# check if letter exists in letters_in_han
if letters_in_hand.include?(letter)
result << true

Choose a reason for hiding this comment

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

What if a letter appears twice in input, but not in letters_in_hand

end
final_results << result.all? { |value| value == true}

input.each_char do |letter|

Choose a reason for hiding this comment

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

This seems to be doing what the above did, but better. Avoid duplication of effort.

group4 = %w(F H V W Y)
group5 = %w(J X)
group6 = %w(Q Z)
word.upcase.each_char do |letter|

Choose a reason for hiding this comment

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

👍

score = data.select{ |k, v| k == winner}.values[0]
return {:word => winner, :score => score}
else # select shortest word and return it as a winner
winner = ties_words.sort_by {|x| x.length}.first

Choose a reason for hiding this comment

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

You have a loop and inside that you're sorting each iteration. This is a bit inefficient.

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