Cody

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

Solution 1186926

Submitted on 12 May 2017 by Augusto Mazzei
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 = 122131221; y_correct = true; assert( isequal(isNumPalindrome(x),y_correct) && isempty(regexp(evalc('type isNumPalindrome'),'(str|printf|eval|flip|dec2base)')) )

y = 1 esp = 8 a = 1 b = 1 a = 2 b = 2 a = 2 b = 2 a = 1 b = 1 a = 3 b = 3 a = 1 b = 1 a = 2 b = 2 a = 2 b = 2 a = 1 b = 1 a = 0 b = 0

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

y = 1 esp = 3 a = 1 b = 1 a = 2 b = 2 a = 2 b = 2 a = 1 b = 1 a = 0 b = 0

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

y = 1 esp = 4 a = 1 b = 5 y = 0

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

y = 1 esp = 3 a = 9 b = 9 a = 8 b = 4 y = 0

Suggested Problems

More from this Author56

Community Treasure Hunt

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

Start Hunting!