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.
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
C19Ruby- Sarah Kim #19
base: main
Are you sure you want to change the base?
C19Ruby- Sarah Kim #19
Changes from all commits
d957899
6d53b37
d0d1dd0
de82185
2ffffc7
ad525c3
6a830b7
0e87f4a
335d4e9
05e63f1
c971784
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way of choosing letters randomly doesn't quite meet the requirements. Notice that your solution is just as likely to draw a
Z
as it is to draw anE
. The requirements say, "Since there are 12E
s but only 1Z
, it should be 12 times as likely for the user to draw anE
as aZ
". It turns out, our tests don’t test for that. (That test is quite hard to write!) Think about how you might modify your code to fulfill this requirement.Regarding
random.choice
: when bringing in functions from imported modules (that we haven’t covered in the curriculum), please consider including a comment about how you understand the function to work, and how you researched it. Now that we’ve discussed Big O, it’s also useful to think about what the time/space complexity of the function might be. Thinking about how we can implement this functionality ourselves can help us gain insight into what that might be.Remember that not every language has the same built-in functions, so we should be able to implement this same functionality ourselves. In the projects, we don’t ask for any features that we don’t think you should be able to write yourself. For drawing a random hand, the only external function that would be “required” is a way to pick a random number (such as
randint
). At this stage in our coding journeys, it’s often more valuable to re-implement things by hand to practice thinking about how to break down and approach the problem than to use a single library function to solve the problem for us.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice way of handling this!
[suggestion] You can make the cases slightly more concise by inverting the conditions, combining them, and early returning only in the
if
body. Early-returning in anif
means the rest of the loop body is naturally an "else":There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] since you don't modify
letter_score
, it can be extracted out of the function as a constant. You might call itLETTER_SCORE
if you did that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments are good, and sometimes you can have too much of a good thing! In most of this function, your comments are almost exactly the same as the lines of code they document. We avoid that in industry because the lines of code may change, but devs aren't always careful about changing the comments to match. It's also more for humans to read, but doesn't give them extra information.
What comments might you write to describe what this code is doing without describing how it does it (since that is what's most likely to change later)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[idea] If you think it's more readable (which you might not!), you can combine these cases together and rely on the order of operations rules of
or
andand
to give you equivalent boolean logic: