Cody

Problem 42307. Long-digit Subtraction

Solution 669534

Submitted on 13 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))

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

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

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

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

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

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

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

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

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

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

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

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

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

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

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

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

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

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

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

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

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

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))

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

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))

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

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))

Error: Undefined function 'BigInteger' for input arguments of type 'char'.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!