-
-
Notifications
You must be signed in to change notification settings - Fork 556
luhn: update examples to reinforce manipulating from the right #549
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
Conversation
Related to #547 |
``` | ||
|
||
The first step of the Luhn algorithm is to double every second digit, | ||
starting from the right. We will be doubling | ||
|
||
``` | ||
_4_ 4_4 _8_ | ||
4_3_ 1_8_ 0_4_ 6_6_ |
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.
The key change.
@@ -77,7 +55,7 @@ Double the second digits, starting from the right | |||
Sum the digits | |||
|
|||
``` | |||
7+2+5+3+2+2+5+2+5+3+1+2+0+5+3+9 = 57 | |||
7+2+5+3+2+2+6+2+5+3+1+2+0+5+3+9 = 57 |
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.
Fixed a typo in this sum!
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.
I don't disagree with any change made herein, though now I claim that the commit message is inaccurate. The update to fix a typo is good but it has nothing to do with manipulating from the right, so it would fit in its own commit.
I pondered briefly whether it would be useful to keep some odd-length example in for the purpose of telling the student "double every second from the right doesn't mean you can just start at the leftmost digit" because that doesn't work for odd-length strings. But probably best left to the tests.
544b6ec
to
991ef70
Compare
@petertseng commit split into two! |
I agree on leaving the odd length examples to the tests; seems like the right place to discover that distinction if the (now multiple, consistent) clues from the description weren't enough. |
LGTM! |
Is there a "minimum number of approvals protocol" within this repo? I'm a little unclear as to when a PR is considered good to merge. Should I be merging this myself now that it has received 2 separate thumbs up? Thanks 🤓 |
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.
If there is a minimum number of approvals, it is not bigger then 3! 😄
Is there a "minimum number of approvals protocol" within this repo? I'm a little unclear as to when a PR is considered good to merge. Should I be merging this myself now that it has received 2 separate thumbs up? Thanks 🤓
Carry #549: Add generator for etl
This updates the luhn examples to operate on even-length strings. This reinforces the idea that the numbers to be doubled are counted from the right, not from the left. (The previous odd-length example string did not emphasize this distinction.)