Rachael and Li #21
Conversation
kaidamasaki
left a comment
There was a problem hiding this comment.
Great job! You made good use of several enumerable methods to clean your code up and just generally seemed to have a focus on keeping your code concise.
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
| 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 | ✅ |
| Descriptive/Readable | ✅ |
| Concise | ✅ |
| Logical/Organized | ✅ |
|
|
||
| def uses_available_letters?(input, letters_in_hand) | ||
| result = [] | ||
| input_arr = input.split("") |
There was a problem hiding this comment.
You can make this a little clearer using chars:
| input_arr = input.split("") | |
| input_arr = input.chars |
| temp_pool = letters_in_hand.map do |letter| | ||
| letter | ||
| end |
There was a problem hiding this comment.
Good job making a copy of the data before you modified it!
Tip: You can make a copy more easily using dup.
| temp_pool = letters_in_hand.map do |letter| | |
| letter | |
| end | |
| temp_pool = letters_in_hand.dup |
| input_arr.each do |letter| | ||
| if temp_pool.include?(letter) | ||
| temp_pool.slice!(temp_pool.index(letter)) | ||
| result << true | ||
| else | ||
| result << false | ||
| end | ||
| end | ||
| if result.include?(false) | ||
| return false | ||
| else | ||
| return true | ||
| end |
There was a problem hiding this comment.
You can simplify this using an early return:
| input_arr.each do |letter| | |
| if temp_pool.include?(letter) | |
| temp_pool.slice!(temp_pool.index(letter)) | |
| result << true | |
| else | |
| result << false | |
| end | |
| end | |
| if result.include?(false) | |
| return false | |
| else | |
| return true | |
| end | |
| input_arr.each do |letter| | |
| if temp_pool.include?(letter) | |
| temp_pool.slice!(temp_pool.index(letter)) | |
| else | |
| return false | |
| end | |
| end | |
| return true |
This is a common pattern that comes in handy.
| words = ['AAAAAAAAAA', 'EEEEEEEEEE'] | ||
| print highest_score_from(words) No newline at end of file |
There was a problem hiding this comment.
It looks like you forgot to remove some code you used for testing in a few places.
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?