Cody

# Problem 2329. Finding the next number in a number list, are you able to crack it!

Solution 455166

Submitted on 15 Jun 2014 by Clemens Giegerich
• Size: 9
• This is the leading solution.
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 = [11; 4; 16; 3; 3; 15; 6; 17; 10; 18; 7; 13; 15; 5; 24; 5; 3; 3]; NextNumber= 3; assert(isequal(FindNextNumber(x),NextNumber))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In FindNextNumber at 2 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14]

2   Pass
%% x = [9; 1; 7; 1; 7; 9; 2; 8; 4; 8; 16; 21; 13; 15; 1; 13; 10]; NextNumber= 8; assert(isequal(FindNextNumber(x),NextNumber))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In FindNextNumber at 2 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14]

3   Pass
%% x = [6; 20; 9; 3; 25; 4; 1; 4; 8; 9; 1; 7]; NextNumber= 1; assert(isequal(FindNextNumber(x),NextNumber))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In FindNextNumber at 2 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14]

4   Pass
%% x = [17; 5; 12; 33; 5; 7; 4]; NextNumber= 4; assert(isequal(FindNextNumber(x),NextNumber))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In FindNextNumber at 2 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14]

5   Pass
%% x = [8; 6; 11; 4; 1; 6; 2; 1; 3; 11; 4; 16; 3; 3; 15; 6; 17; 10; 18; 7; 13; 15; 5; 24; 5; 3; 3; 1; 2; 5; 16; 1; 2; 17; 9; 8; 5; 12; 16; 11; 8; 5; 10; 11; 10; 10; 2; 4; 17; 5; 12; 33; 5; 7; 4; 11; 16; 5; 1; 6; 20; 9; 3; 25; 4; 1]; NextNumber= 5; assert(isequal(FindNextNumber(x),NextNumber))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In FindNextNumber at 2 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14]

6   Pass
%% x = [4; 4; 18; 12; 27; 20; 24; 25; 14; 29; 16; 25; 15; 6; 6; 3; 20; 9; 20; 5; 12; 24; 16; 27]; NextNumber= 20; assert(isequal(FindNextNumber(x),NextNumber))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In FindNextNumber at 2 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14]

7   Pass
%% x = [14; 22; 27; 15; 8; 30; 24; 33; 28; 27; 31; 31; 38; 29; 30; 35; 12; 7; 15; 22; 10; 26; 35; 15; 25; 18; 32; 30; 31; 35; 22; 15; 21; 13; 19; 24; 32; 18; 30; 31; 28; 32; 40; 17; 15; 28; 41; 42; 35; 30; 35; 39; 33; 17; 34; 26; 13; 14; 19; 40; 13; 27; 16; 23; 22; 29; 42; 33; 37; 28; 36; 30; 26; 6; 25; 39; 26; 23; 39; 27; 28; 14; 25; 29; 7; 16]; NextNumber= 35; assert(isequal(FindNextNumber(x),NextNumber))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In FindNextNumber at 2 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14]

8   Pass
%% x = [27; 31; 31; 38; 29; 30; 35; 12; 7; 15; 22; 10; 26; 35; 15; 25; 18; 32; 30; 31; 35; 22; 15; 21; 13; 19; 24; 32; 18; 30; 31; 28; 32; 40; 17; 15; 28; 41; 42; 35; 30; 35; 39; 33; 17; 34; 26; 13; 14; 19; 40; 13; 27; 16; 23; 22; 29; 42; 33; 37; 28; 36; 30; 26; 6; 25; 39; 26; 23; 39; 27; 28; 14; 25; 29; 7; 16; 28; 11; 14]; NextNumber= 28; assert(isequal(FindNextNumber(x),NextNumber))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In FindNextNumber at 2 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14]

9   Pass
%% x = [39; 46; 39; 21; 46; 46; 45; 31; 47; 45; 39; 44; 47]; NextNumber= 45; assert(isequal(FindNextNumber(x),NextNumber))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In FindNextNumber at 2 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14]

10   Pass
%% x = [7; 8; 18; 7; 9; 2; 11; 2; 2; 2; 13; 4; 4; 13; 11; 6; 3; 15; 16; 17; 4; 7; 17; 12; 3; 12; 9; 3; 17; 2; 4; 17; 5; 18; 1; 4; 15; 2; 11; 6; 19; 4; 2; 1; 18; 15; 12; 17; 11; 2; 1; 3; 17; 15; 4; 12; 10; 11; 16; 4; 2; 13; 13; 8; 16; 2; 9; 19; 7; 15; 12; 5; 17; 6; 9; 16; 9; 11; 4; 12; 7; 12; 9; 18; 2; 8; 14]; NextNumber= 4; assert(isequal(FindNextNumber(x),NextNumber))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In FindNextNumber at 2 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14]

### Community Treasure Hunt

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

Start Hunting!