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

More By Author:

Check out these other kata created by treffynnon

Stats:

CreatedApr 4, 2016
PublishedApr 4, 2016
Warriors Trained9147
Total Skips234
Total Code Submissions37136
Total Times Completed5952
JavaScript Completions2484
CoffeeScript Completions19
Python Completions1583
Haskell Completions133
Ruby Completions331
Java Completions704
C# Completions347
C Completions231
TypeScript Completions102
C++ Completions227
Total Stars111
% of votes with a positive feedback rating91% of 905
Total "Very Satisfied" Votes761
Total "Somewhat Satisfied" Votes127
Total "Not Satisfied" Votes17
Ad
Contributors
  • treffynnon Avatar
  • g964 Avatar
  • anter69 Avatar
  • kazk Avatar
  • Voile Avatar
  • realfg Avatar
  • clcraig Avatar
  • FArekkusu Avatar
  • TheJambo Avatar
  • user8436785 Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad