Skip to content

Commit 005e090

Browse files
committed
Fix Credit Card examples
1 parent e9ca1be commit 005e090

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

week01/03.FinalRound/CreditCard/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
Implement a function, called `is_credit_card_valid(number)`, which returns True/False based on the following algorithm:
44

5-
* Each credit card number must contain odd count of digits.
6-
* We transform the number with the following steps (based on the fact that we start from index 0)
5+
- Each credit card number must contain odd count of digits.
6+
- We transform the number with the following steps (based on the fact that we start from index 0)
77
- All digits, read from right to left, at even positions (index), **remain the same.**
88
- Every digit, read from right to left, at odd position is replaced by the result, that is obtained from doubling the given digit.
9-
* After the transformation, we find the sum of all digits in the transformed number.
10-
* The number is valid, if the sum is divisible by 10.
9+
- After the transformation, we find the sum of all digits in the transformed number.
10+
- The number is valid, if the sum is divisible by 10.
1111

12-
For example: `79927398713` is valid, bacause:
12+
For example: `79927398715` is valid, bacause:
1313

14-
* When we double and replace all digits at odd position we get: `7 (18 = 2 * 9) 9 (4 = 2 * 2) 7 (6 = 2 * 3) 9 (16 = 2 * 8) 7 (2 = 2 * 1) 3`
15-
* The sum of all digits of the new number is 70, which is divisible by 10 => the card number is valid.
14+
- When we double and replace all digits at odd position we get: `7 (18 = 2 * 9) 9 (4 = 2 * 2) 7 (6 = 2 * 3) 9 (16 = 2 * 8) 7 (2 = 2 * 1) 5`
15+
- The sum of all digits of the new number is 90, which is divisible by 10 => the card number is valid.
1616

1717
More examples:
1818

19-
* `79927398713` is a valid number
20-
* `79927398715` is invalid number
19+
- `79927398713` is an invalid number
20+
- `79927398715` is a valid number

0 commit comments

Comments
 (0)