Cody

# Problem 172. Test if a Number is a Palindrome without using any String Operations

Solution 2792497

Submitted on 5 Aug 2020
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
x = 122131221; y_correct = true; assert( isequal(isNumPalindrome(x),y_correct) && isempty(regexp(evalc('type isNumPalindrome'),'(str|printf|eval|flip|dec2base)')) )

divisor = 1 divisor = 10 divisor = 100 divisor = 1000 divisor = 10000 divisor = 100000 divisor = 1000000 divisor = 10000000 divisor = 100000000 y = logical 1

Error using idivide>idivide_check (line 87) At least one argument must belong to an integer class. Error in idivide (line 42) idivide_check(a,b); Error in isNumPalindrome (line 9) leading = idivide(n, divisor) Error in Test1 (line 3) assert( isequal(isNumPalindrome(x),y_correct) && isempty(regexp(evalc('type isNumPalindrome'),'(str|printf|eval|flip|dec2base)')) )

2   Fail
x = 1221; y_correct = true; assert( isequal(isNumPalindrome(x),y_correct) && isempty(regexp(evalc('type isNumPalindrome'),'(str|printf|eval|flip|dec2base)')) )

divisor = 1 divisor = 10 divisor = 100 divisor = 1000 y = logical 1

Error using idivide>idivide_check (line 87) At least one argument must belong to an integer class. Error in idivide (line 42) idivide_check(a,b); Error in isNumPalindrome (line 9) leading = idivide(n, divisor) Error in Test2 (line 3) assert( isequal(isNumPalindrome(x),y_correct) && isempty(regexp(evalc('type isNumPalindrome'),'(str|printf|eval|flip|dec2base)')) )

3   Fail
x = 12345; y_correct = false; assert( isequal(isNumPalindrome(x),y_correct) && isempty(regexp(evalc('type isNumPalindrome'),'(str|printf|eval|flip|dec2base)')) )

divisor = 1 divisor = 10 divisor = 100 divisor = 1000 divisor = 10000 y = logical 1

Error using idivide>idivide_check (line 87) At least one argument must belong to an integer class. Error in idivide (line 42) idivide_check(a,b); Error in isNumPalindrome (line 9) leading = idivide(n, divisor) Error in Test3 (line 3) assert( isequal(isNumPalindrome(x),y_correct) && isempty(regexp(evalc('type isNumPalindrome'),'(str|printf|eval|flip|dec2base)')) )

4   Fail
x = 9849; y_correct = false; assert( isequal(isNumPalindrome(x),y_correct) && isempty(regexp(evalc('type isNumPalindrome'),'(str|printf|eval|flip|dec2base)')) )

divisor = 1 divisor = 10 divisor = 100 divisor = 1000 y = logical 1

Error using idivide>idivide_check (line 87) At least one argument must belong to an integer class. Error in idivide (line 42) idivide_check(a,b); Error in isNumPalindrome (line 9) leading = idivide(n, divisor) Error in Test4 (line 3) assert( isequal(isNumPalindrome(x),y_correct) && isempty(regexp(evalc('type isNumPalindrome'),'(str|printf|eval|flip|dec2base)')) )