| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 13233 | GEC1506- Identify credit card (Simplest) |
|
| 13234 | GEC1506- Verify credit card (Medium) |
|
| 13235 | GEC1506- Credit card security code (Advanced) |
|
Description
In this problem, you need to process the numerical format of the Credit Card number to see which card brand the card belongs to.
As we know, A credit card number is the string of numeric digits that identifies the credit card. It's usually (but not always) displayed on the front of the card, and it generally (but not always) features 15 or 16 digits depending on which brand of the card it is.
Assuming that there is a credit card number as 5569608130275946, we can identify this card as a "Master Card".
To identify the card brand, we need to check the first 1~4 digits on the card, please check the table below:
Figure 1. The index table for credit cards numbers.
Note that, there are only 15 digits for brand "American Express", and the rest of the brands have 16 digits.
However, for this problem, all the digits are reversed as below.
Input
There will be only one line in the input as the reversed credit number, such as:
6495720318069655
(*The original digits would be like this:
5569608130275946
Output
The result after the identification process,
print "Visa Card" if the first 1 digit of the number is 4;
print "Master Card" if the first 2 digits of the number are 51~55;
print "American Express" if there are 15 digits in total and the first 3 digits of the number are 340~379;
print "JCB Card" if the first 3 digits of the number are 300~399, or the first 4 digits of the number are 1800 or 2131;
print "Unionpay Card" if the first 2 digits of the number are 62;
print "Unknown" if the digits don't match the criteria.
For the example input here, we should print "Master Card" as the output.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
In this problem, you need to process the numerical format of the credit card number to see whether the credit card is real or fake.
Assuming that there is a credit card number as 1234567891234563, the digits in the credit card number can show if the card is verified or not.
To make sure if the credit card number is verified, we need to follow the rules:
1. Make sure you got 15 or 16 digits in total, and list the digits from right to left, such as below:
2. For each digit, we multiply with 1 or 2. We multiply 1 for the odd digits, and multiply 2 for the even digits:
3.Sum all the multiplied result.
4.As a verified credit card number, the sum of all the digits divided by 10 should be 0.

Input
The 1st line to the 4th line are the possible credit card numbers, such as:
1234567891234563
1234567891234573
1234567891234583
1234567891234593
**Note that: There will be 15 or 16 digits in one line.
Output
The result after the verification process, print out the "verified card numbers" if they are verified.
For the example input here, the output will be:
1234567891234563
Sample Input Download
Sample Output Download
Tags
Discuss
Description
As credit card is so popular nowadays, the security of credit card is an important issue.
In this problem, you are asked to verify whether the credit card number and its security code match or not.
Input
The input contains
- One based number for security encoding; and
- One or more lines pairs for credit card information, where each line consists of a pair of credit card numbers (separated by space) and security code numbers
17
4024 7603 2331 3208,308
6011 1297 0941 1814,211
You are asked to verify these pairs by following rules:
(Take 1st pair as example)
1. Sum up all the credit card numbers.
4024+7603+2331+3208 = 17166
2. Encode the summed numbers using the following base-decimal format.
e.g.
base=17
17166 = 3 * 173 + 8 * 172 + 6*171 + 13 * 170
With this encoding method, 17166 is then encoded to 38613.
Note that in some cases, we may need more/less than the power of "3" times for the base number to encode.
Hint: You can get the power of the base number by following python code:
>>> result = 17 ** 2
>>>print(result)
289
>>> result = 17 ** 3
>>>print(result)
4913
3. The real security code number is the even position of the encoded number (Start from the right).
There are only 3 digits for a credit card security code.
From this example, an additional "0" is necessary to add in the beginning as we only get 2 digits (8 and 1).
The final verified security code is then found as these 3 digits (081).
In other words, if more than 3 digits you got, just keep the rightest 3 ones.
4. If the given security code (308) matches the one you encode (081), you return "correct", otherwise, "incorrect"
Output
The output is multiple lines of verification results based on given credit card pairs.
To solve this problem, except for the sys library for reading OJ input, you don't need any extra library by default.