Skip to content
This repository has been archived by the owner on Mar 5, 2020. It is now read-only.

Java solution to the Luhny Bin #1

Closed
wants to merge 24 commits into from
Closed

Conversation

bdurette
Copy link

Here's my Java solution to the Luhny Bin problem. It memoizes the "Luhny Sums" (odd and even) of potential credit card numbers at each character offset in the input stream. It uses the lookup table to compute the check values for 14 through 16 digit numbers ending at any given character and masks accordingly.

Some potential improvements:

  1. Store information in the mask step to eliminate the need to remask overlapping regions.
  2. Save memory by not storing the entire lookup table in memory. Each time a non-credit-card character is encountered, the table can be cleared. This is only necessary if long inputs are expected.

All in all, a fun problem. Thanks!

@bdurette
Copy link
Author

Pull request now includes some additional tests:

  1. Don't assume CC #'s will be in 4 digit segments (if delimited).
  2. Don't assume that delimiters will only be one character long.

youngnh pushed a commit to youngnh/luhnybin that referenced this pull request Nov 16, 2011
@bdurette bdurette closed this Jun 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants