Cody

# Problem 42307. Long-digit Subtraction

Solution 669993

Submitted on 14 May 2015
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   Fail
%% a = '99999'; b = '87654'; %---------- c = '12345'; assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.

2   Fail
%% a = '99999'; b = '1234'; %---------- c = '98765'; assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.

3   Fail
%% a = '99999'; b = '98765'; %---------- c = '1234'; assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.

4   Fail
%% a = '99999'; b = '90909'; %---------- c = '9090'; assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.

5   Fail
%% a = '11111'; b = '1234'; %---------- c = '9877'; assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.

6   Fail
%% a = '10000'; b = '1'; %---------- c = '9999'; assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.

7   Fail
%% a = '10000000'; b = '9999999'; %------------- c = '1'; assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.

8   Fail
%% a = '100000000000000000000000000000000000000000000000000000000000000000000'; b = '1'; %-------------------------------------------------------------------------- c = '99999999999999999999999999999999999999999999999999999999999999999999'; assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.

9   Fail
%% a = '2135476542136876516521651162516'; b = '165267982494266414654661818517'; %------------------------------------ c = '1970208559642610101866989343999'; assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.

10   Fail
%% a = '1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'; b = '1'; %------------------------------------------------------------------------------------------------------------------------------------------------------------------ c = '999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999'; assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.

11   Fail
%% a = '1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'; b = '1'; %------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ c = '999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999'; assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.

12   Fail
%% switch randi(4) case 1 a = '99999'; b = '87654'; c = '12345'; case 2 a = '99999'; b = '1234'; c = '98765'; case 3 a = '10000000'; b = '9999999'; c = '1'; case 4 a = '99999'; b = '90909'; c = '9090'; end assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.

13   Fail
%% switch randi(4) case 1 a = '99999'; b = '98765'; c = '1234'; case 2 a = '10000'; b = '1'; c = '9999'; case 3 a = '99999'; b = '87654'; c = '12345'; case 4 a = '2135476542136876516521651162516'; b = '165267982494266414654661818517'; c = '1970208559642610101866989343999'; end assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.

14   Fail
%% switch randi(4) case 1 a = '11111'; b = '1234'; c = '9877'; case 2 a = '10000000'; b = '9999999'; c = '1'; case 3 a = '99999'; b = '98765'; c = '1234'; case 4 a = '99999'; b = '87654'; c = '12345'; end assert(strcmp(long_digit_subtraction(a,b),c))

Assertion failed.