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

Implement Luhn #237

Closed
IanWhitney opened this issue Dec 21, 2016 · 2 comments
Closed

Implement Luhn #237

IanWhitney opened this issue Dec 21, 2016 · 2 comments
Assignees

Comments

@IanWhitney
Copy link
Contributor

Following the current test suite implement the luhn exercise

@IanWhitney IanWhitney self-assigned this Dec 21, 2016
@IanWhitney
Copy link
Contributor Author

Assigning myself because I've started work on this.

@IanWhitney
Copy link
Contributor Author

New test suite in place (exercism/problem-specifications#474), so now I can get back to work on implementing this for the Rust track.

IanWhitney pushed a commit to IanWhitney/xrust that referenced this issue Jan 14, 2017
Closes exercism#237

This mostly follows the current test suite
(exercism/problem-specifications#491), with one change.

The final canonical test adds an alphabetical character to a known
invalid string and then asserts that it's still invalid.

Instead what the test should do is alter a known-valid string and show
that it is now invalid.

That's what I've done here. I'll also propose the change to canonical
test suite.
IanWhitney added a commit that referenced this issue Jan 15, 2017
* Implement Luhn

Closes #237

This follows the current test suite as of right now

https://github.com/exercism/x-common/blob/41b9fe8e9c2513f4443e1cad1f286f53b2720ce9/exercises/luhn/canonical-data.json

* Place Luhn before Largest Series Product

I don't think my solution is that far from what people will do. The
[existing crate](https://lunemec.github.io/rust-luhn/src/luhn2/src/lib.rs.html)
uses another crate to handle digits > 10 after doubling. If people go
down that path their solutions will vary a bit from mine, but not by a
bunch.

So the solution mostly requires a good handle on

- Converting a string to digits
- Working with iteration

The conversion of a string to digits is also part of Largest Series
Product, so we could put the exercise to right before LSP to reinforce
that concept.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant