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 458567

Submitted on 19 Jun 2014 by Ziko

Correct

76Size
Leading solution size is 16.
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 = 2;
y_correct = 1;
assert(isequal(mytaxicab(x),y_correct))
ans =
     1
2
Pass
 
%%
x = 1729;
y_correct = 2;
assert(isequal(mytaxicab(x),y_correct))
y =
     1
y =
     1     0
y =
     1     0     0
y =
     1     0     0     0
y =
     1     0     0     0     0
y =
     1     0     0     0     0     0
y =
     1     0     0     0     0     0     0
y =
     1     0     0     0     0     0     0     0
y =
     1     0     0     0     0     0     0     0     1
y =
     1     0     0     0     0     0     0     0     1     1
ans =
     2
3
Pass
 
%%
x = 5251;
y_correct = 0;
assert(isequal(mytaxicab(x),y_correct))
y =
     0
y =
     0     0
y =
     0     0     0
y =
     0     0     0     0
y =
     0     0     0     0     0
y =
     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0     0     0     0
ans =
     0
4
Pass
 
%%
x = 10000001;
y_correct = 0;
assert(isequal(mytaxicab(x),y_correct))
y =
     0
y =
     0     0
y =
     0     0     0
y =
     0     0     0     0
y =
     0     0     0     0     0
y =
     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Column 17
     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 18
     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 19
     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 20
     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 21
     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 22
     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 23
     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 24
     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 25
     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 26
     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 27
     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 28
     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 29
     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 30
     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 31
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Column 33
     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 34
     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 35
     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 36
     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 37
     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 38
     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 39
     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 40
     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 41
     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 42
     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 43
     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 44
     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 45
     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 46
     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 47
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 48
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 48
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Column 49
     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 48
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 49 through 50
     0     0
y =...
5
Pass
 
%%
x = 87539319;
y_correct = 3;
assert(isequal(mytaxicab(x),y_correct))
y =
     0
y =
     0     0
y =
     0     0     0
y =
     0     0     0     0
y =
     0     0     0     0     0
y =
     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Column 17
     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 18
     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 19
     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 20
     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 21
     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 22
     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 23
     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 24
     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 25
     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 26
     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 27
     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 28
     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 29
     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 30
     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 31
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Column 33
     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 34
     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 35
     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 36
     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 37
     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 38
     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 39
     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 40
     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 41
     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 42
     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 43
     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 44
     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 45
     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 46
     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 47
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 48
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 48
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Column 49
     0
y =
  Columns 1 through 16
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 17 through 32
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 33 through 48
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  Columns 49 through 50
     0     0
y =...