Cody

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

Solution 525321

Submitted on 10 Nov 2014 by goc3
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 x = 22131221 y = 1 2 x = 2131221 y = 1 2 2 x = 131221 y = 1 2 2 1 x = 31221 y = 1 2 2 1 3 x = 1221 y = 1 2 2 1 3 1 x = 221 y = 1 2 2 1 3 1 2 x = 21 y = 1 2 2 1 3 1 2 2 x = 1 y = 1 2 2 1 3 1 2 2 1 x = 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 x = 221 y = 1 2 x = 21 y = 1 2 2 x = 1 y = 1 2 2 1 x = 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 x = 2345 y = 1 2 x = 345 y = 1 2 3 x = 45 y = 1 2 3 4 x = 5 y = 1 2 3 4 5 x = 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 = 9 x = 849 y = 9 8 x = 49 y = 9 8 4 x = 9 y = 9 8 4 9 x = 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!