Cody

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

Solution 1603663

Submitted on 8 Aug 2018 by Srishti Saha
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 = 8 D = 1 2 2 1 3 1 2 2 1 flpD = 1 2 2 1 3 1 2 2 1 ans = logical 1

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

y = 3 D = 1 2 2 1 flpD = 1 2 2 1 ans = logical 1

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

y = 4 D = 1 2 3 4 5 flpD = 5 4 3 2 1 ans = logical 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 = 3 D = 9 8 4 9 flpD = 9 4 8 9 ans = logical 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!