00:02
Good day, ladies and gentlemen.
00:04
Today we're looking at problem number 814.
00:08
It is credit card validation.
00:12
Now, this problem, again, is another bit of a, well, the bit of a tedious one.
00:21
There's a few steps to it.
00:22
So i'm just going to talk you through the basic idea of it, and then i'm going to show you the code as to how i get it.
00:31
And really, the author pretty much lays out the solution in section 6 .2, or at least gives you the basic idea.
00:43
The major difference between 6 .29, and this one is that in this one, it's really treating it as a string instead of a, instead of, i guess, what it was before was just not even sure.
01:00
Was it integers? i'm not even sure.
01:02
Anyhow, so this time we're treating it more as a string.
01:05
So the basic idea goes like this.
01:10
You know, that first of all, the card has to be between 12 and 17, well, greater than 12 and less than 17.
01:20
And that you have to break the card into the odd.
01:25
Digits and the even digits and the odd digits.
01:29
On the even digits, so the digits 0, 2, 4, so on and so forth, you take each digit and then you multiply it by 2.
01:42
And of course, if the value is less than 10, you just add that value to what i call even sum.
01:52
Otherwise, you take the digits of the value and you add this value to the even sum.
02:05
So in other words, you break if we have, oops, i'm sorry about that.
02:13
I hate this when this happens.
02:17
So if it's an even number, you take, for instance, if it's 12, then you, this is really annoying.
02:38
Yeah.
02:43
So if it's 12, you add that together 1 plus 2 to get 3.
02:48
And then you take all those values and you add that to even some.
03:02
Okay.
03:04
And then with the odd values, you just add all the entries up to get the odd sum.
03:11
And then you add the odds sum up and even sum, and you mod that by 10.
03:18
And if it's zero, you return true.
03:21
And it helps you return false...