Cody

# Problem 2848. Digital Neighbourhood

Solution 561084

Submitted on 20 Jan 2015 by James
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 = 132; y_correct = 123; assert(isequal(find_neighbour(x),y_correct))

a = 9 b = 5 ans = 123

2   Pass
%% x = 182; y_correct = 218; assert(isequal(find_neighbour(x),y_correct))

a = 36 b = 2 ans = 218

3   Pass
%% x = 172; y_correct = [127; 217]; % there are two such numbers, one of them is enough, but you can return both y = sort(find_neighbour(x)); fprintf('%d founded.\n',y) y = y(:); assert(any(y_correct==y))

a = 45 b = 2 ans = 217 217 founded.

4   Pass
%% x = 1; y_correct = 10; assert(isequal(find_neighbour(x),y_correct))

a = 9 b = 1 ans = 10

5   Pass
%% x = 10; y_correct = 1; assert(isequal(find_neighbour(x),y_correct))

a = 9 b = 1 ans = 1

6   Pass
%% x = 100; y_correct = 10; assert(isequal(find_neighbour(x),y_correct))

a = 90 b = 2 ans = 10

7   Pass
%% x = 99; y_correct = 909; assert(isequal(find_neighbour(x),y_correct))

a = 810 b = 1 ans = 909

8   Pass
%% x = 199; y_correct = 919; assert(isequal(find_neighbour(x),y_correct))

a = 720 b = 2 ans = 919

9   Pass
%% x = 1099; y_correct = 991; assert(isequal(find_neighbour(x),y_correct))

a = 108 b = 13 ans = 991

10   Pass
%% x = 123455; y_correct = 123545; assert(isequal(find_neighbour(x),y_correct))

a = 90 b = 679 ans = 123545

11   Pass
%% x = 56565656; y_correct = 56565665; assert(isequal(find_neighbour(x),y_correct))

a = 9 b = 5167 ans = 56565665

12   Pass
%% x = 8761199; y_correct = 8761919; assert(isequal(find_neighbour(x),y_correct))

a = 720 b = 4849 ans = 8761919

13   Pass
%% x = 820199; y_correct = 819920; assert(isequal(find_neighbour(x),y_correct))

a = 279 b = 629 ans = 819920

14   Pass
%% x = 991; y_correct = 919; assert(isequal(find_neighbour(x),y_correct))

a = 72 b = 3 ans = 919

15   Pass
%% x = 911; y_correct = 1019; assert(isequal(find_neighbour(x),y_correct))

a = 108 b = 5 ans = 1019

16   Pass
%% x = 7001; y_correct = 7010; assert(isequal(find_neighbour(x),y_correct))

a = 9 b = 19 ans = 7010

17   Pass
%% x = 1192999; y_correct = 1199299; assert(isequal(find_neighbour(x),y_correct))

a = 6300 b = 4201 ans = 1199299

18   Pass
%% x = 8713222; y_correct = 8712322; assert(isequal(find_neighbour(x),y_correct))

a = 900 b = 4849 ans = 8712322