7 kyu
Credit card issuer checking
1,583 of 5,952treffynnon
Description:
Given a credit card number we can determine who the issuer/vendor is with a few basic knowns.
Complete the function get_issuer()
that will use the values shown below to determine the card issuer for a given card number. If the number cannot be matched then the function should return the string Unknown
.
| Card Type | Begins With | Number Length |
|------------|----------------------|---------------|
| AMEX | 34 or 37 | 15 |
| Discover | 6011 | 16 |
| Mastercard | 51, 52, 53, 54 or 55 | 16 |
| VISA | 4 | 13 or 16 |
Examples
get_issuer(4111111111111111) == "VISA"
get_issuer(4111111111111) == "VISA"
get_issuer(4012888888881881) == "VISA"
get_issuer(378282246310005) == "AMEX"
get_issuer(6011111111111117) == "Discover"
get_issuer(5105105105105100) == "Mastercard"
get_issuer(5105105105105106) == "Mastercard"
get_issuer(9111111111111111) == "Unknown"
Algorithms
Similar Kata:
Stats:
Created | Apr 4, 2016 |
Published | Apr 4, 2016 |
Warriors Trained | 9147 |
Total Skips | 234 |
Total Code Submissions | 37136 |
Total Times Completed | 5952 |
JavaScript Completions | 2484 |
CoffeeScript Completions | 19 |
Python Completions | 1583 |
Haskell Completions | 133 |
Ruby Completions | 331 |
Java Completions | 704 |
C# Completions | 347 |
C Completions | 231 |
TypeScript Completions | 102 |
C++ Completions | 227 |
Total Stars | 111 |
% of votes with a positive feedback rating | 91% of 905 |
Total "Very Satisfied" Votes | 761 |
Total "Somewhat Satisfied" Votes | 127 |
Total "Not Satisfied" Votes | 17 |