Cody

Problem 45490. Luhn's Algorithm

Solution 2266114

Submitted on 9 May 2020 by Nikolaos Nikolaou
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x = '0'; assert(isequal(luhn(x),'00'));

m = 1×0 empty char array s = '0' y = '00'

2   Pass
x = '1'; assert(isequal(luhn(x),'12'));

m = 1×0 empty char array s = '2' y = '12'

3   Pass
x = '5'; assert(isequal(luhn(x),'51'));

m = 1×0 empty char array s = '1' y = '51'

4   Pass
x = '9'; assert(isequal(luhn(x),'99'));

m = 1×0 empty char array s = '9' y = '99'

5   Pass
x = '10'; assert(isequal(luhn(x),'101'));

m = '1' s = '1' y = '101'

6   Pass
x = '80'; assert(isequal(luhn(x),'808'));

m = '8' s = '8' y = '808'

7   Pass
x = '080'; assert(isequal(luhn(x),'0808'));

m = '8' s = '8' y = '0808'

8   Pass
x = '180'; assert(isequal(luhn(x),'1800'));

m = '8' s = '10' y = '1800'

9   Pass
x = '1234567890'; assert(isequal(luhn(x),'12345678907'));

m = '97531' s = '47' y = '12345678907'