Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 290805

Submitted on 27 Jul 2013 by Claudio Gelmi

Correct

17Size
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
Code Input and Output
1
Pass
 
%%
x = [1 2 3 4 5];
y_correct = [1 2 3 4 5];
assert(isequal(gendigit_champernowne(x),y_correct))
[Warning: Function /users/msssystem5/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In gendigit_champernowne at 3
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14]
2
Pass
 
%%
x = [10 11 12 13 14 15];
y_correct = [1 0 1 1 1 2];
assert(isequal(gendigit_champernowne(x),y_correct))
[Warning: Function /users/msssystem5/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In gendigit_champernowne at 3
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14]
3
Pass
 
%%
x = [188 189];
y_correct = [9 9];
assert(isequal(gendigit_champernowne(x),y_correct))
[Warning: Function /users/msssystem5/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In gendigit_champernowne at 3
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14]
4
Pass
 
%%
x = 2887:3000;
y_correct = '999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102';
assert(isequal(sprintf('%d',gendigit_champernowne(2887:3000)),y_correct))
[Warning: Function /users/msssystem5/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In gendigit_champernowne at 3
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14]
5
Pass
 
%%
x=[1000000 1000001 1000002];
y_correct = [1 8 5];
assert(isequal(gendigit_champernowne(x),y_correct))
[Warning: Function /users/msssystem5/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In gendigit_champernowne at 3
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14]
6
Pass
 
%%
x=[12000:12005];
y_correct = [7     7     3     2     7     8];
assert(isequal(gendigit_champernowne(x),y_correct))
[Warning: Function /users/msssystem5/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In gendigit_champernowne at 3
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14]
7
Pass
 
%%
x=[10000000 10000001 10000002];
y_correct = [7 3 0];
assert(isequal(gendigit_champernowne(x),y_correct))
[Warning: Function /users/msssystem5/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In gendigit_champernowne at 3
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14]
8
Pass
 
%%
x=[120000:120005];
y_correct = [2     6     2     2     2     2];
assert(isequal(gendigit_champernowne(x),y_correct))
[Warning: Function /users/msssystem5/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In gendigit_champernowne at 3
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14]
9
Pass
 
%%
x=[1200000:1200005];
y_correct = [ 8     5     1     8     2     1];
assert(isequal(gendigit_champernowne(x),y_correct))
[Warning: Function /users/msssystem5/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In gendigit_champernowne at 3
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14]
10
Pass
 
%%
x=[1200004:1200009];
y_correct = [ 2     1     8     5     1     9];
assert(isequal(gendigit_champernowne(x),y_correct))
[Warning: Function /users/msssystem5/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In gendigit_champernowne at 3
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14]
11
Pass
 
%%
x=[1200008:1200013];
y_correct = [1     9      2     1     8     5];
assert(isequal(gendigit_champernowne(x),y_correct))
[Warning: Function /users/msssystem5/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In gendigit_champernowne at 3
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14]
12
Pass
 
%%
x=[13000008:13000013];
y_correct = [2     0     1     5     8     7];
assert(isequal(gendigit_champernowne(x),y_correct))
[Warning: Function /users/msssystem5/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In gendigit_champernowne at 3
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14]
13
Pass
 
%%
x=[14000008:14000013];
y_correct = [ 1     5     8     7     3     1];
assert(isequal(gendigit_champernowne(x),y_correct))
[Warning: Function /users/msssystem5/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In gendigit_champernowne at 3
  In verifyCode>evaluateCode at 227
  In verifyCode at 40
  In fevalJSON at 14]