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 186690

Submitted on 5 Jan 2013

Incorrect

42Size
Leading solution size is 10.
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
 
%%
n = 1;
y_correct = 1;
assert(isequal(wheat_chess(n),y_correct))
y =
     0
y =
     1
2
Pass
 
%%
n = 0;
y_correct = 0;
assert(isequal(wheat_chess(n),y_correct))
y =
     0
3
Fail
 
%%
n = -1;
y_correct = 'NaN';
assert(isequal(wheat_chess(n),y_correct))
Error: Assertion failed.
4
Pass
 
%%
n = 4;
y_correct = 65535;
assert(isequal(wheat_chess(n),y_correct))
y =
     0
y =
     1
y =
     3
y =
     7
y =
    15
y =
    31
y =
    63
y =
   127
y =
   255
y =
   511
y =
        1023
y =
        2047
y =
        4095
y =
        8191
y =
       16383
y =
       32767
y =
       65535
5
Pass
 
%%
n = 8;
y_correct = 18446744073709551615;
assert(isequal(wheat_chess(n),y_correct))
y =
     0
y =
     1
y =
     3
y =
     7
y =
    15
y =
    31
y =
    63
y =
   127
y =
   255
y =
   511
y =
        1023
y =
        2047
y =
        4095
y =
        8191
y =
       16383
y =
       32767
y =
       65535
y =
      131071
y =
      262143
y =
      524287
y =
     1048575
y =
     2097151
y =
     4194303
y =
     8388607
y =
    16777215
y =
    33554431
y =
    67108863
y =
   134217727
y =
   268435455
y =
   536870911
y =
   1.0737e+09
y =
   2.1475e+09
y =
   4.2950e+09
y =
   8.5899e+09
y =
   1.7180e+10
y =
   3.4360e+10
y =
   6.8719e+10
y =
   1.3744e+11
y =
   2.7488e+11
y =
   5.4976e+11
y =
   1.0995e+12
y =
   2.1990e+12
y =
   4.3980e+12
y =
   8.7961e+12
y =
   1.7592e+13
y =
   3.5184e+13
y =
   7.0369e+13
y =
   1.4074e+14
y =
   2.8147e+14
y =
   5.6295e+14
y =
   1.1259e+15
y =
   2.2518e+15
y =
   4.5036e+15
y =
   9.0072e+15
y =
   1.8014e+16
y =
   3.6029e+16
y =
   7.2058e+16
y =
   1.4412e+17
y =
   2.8823e+17
y =
   5.7646e+17
y =
   1.1529e+18
y =
   2.3058e+18
y =
   4.6117e+18
y =
   9.2234e+18
y =
   1.8447e+19
6
Pass
 
%%
n = 10;
y_correct = 1267650600228229401496703205375;
assert(isequal(wheat_chess(n),y_correct))
y =
     0
y =
     1
y =
     3
y =
     7
y =
    15
y =
    31
y =
    63
y =
   127
y =
   255
y =
   511
y =
        1023
y =
        2047
y =
        4095
y =
        8191
y =
       16383
y =
       32767
y =
       65535
y =
      131071
y =
      262143
y =
      524287
y =
     1048575
y =
     2097151
y =
     4194303
y =
     8388607
y =
    16777215
y =
    33554431
y =
    67108863
y =
   134217727
y =
   268435455
y =
   536870911
y =
   1.0737e+09
y =
   2.1475e+09
y =
   4.2950e+09
y =
   8.5899e+09
y =
   1.7180e+10
y =
   3.4360e+10
y =
   6.8719e+10
y =
   1.3744e+11
y =
   2.7488e+11
y =
   5.4976e+11
y =
   1.0995e+12
y =
   2.1990e+12
y =
   4.3980e+12
y =
   8.7961e+12
y =
   1.7592e+13
y =
   3.5184e+13
y =
   7.0369e+13
y =
   1.4074e+14
y =
   2.8147e+14
y =
   5.6295e+14
y =
   1.1259e+15
y =
   2.2518e+15
y =
   4.5036e+15
y =
   9.0072e+15
y =
   1.8014e+16
y =
   3.6029e+16
y =
   7.2058e+16
y =
   1.4412e+17
y =
   2.8823e+17
y =
   5.7646e+17
y =
   1.1529e+18
y =
   2.3058e+18
y =
   4.6117e+18
y =
   9.2234e+18
y =
   1.8447e+19
y =
   3.6893e+19
y =
   7.3787e+19
y =
   1.4757e+20
y =
   2.9515e+20
y =
   5.9030e+20
y =
   1.1806e+21
y =
   2.3612e+21
y =
   4.7224e+21
y =
   9.4447e+21
y =
   1.8889e+22
y =
   3.7779e+22
y =
   7.5558e+22
y =
   1.5112e+23
y =
   3.0223e+23
y =
   6.0446e+23
y =
   1.2089e+24
y =
   2.4179e+24
y =
   4.8357e+24
y =
   9.6714e+24
y =
   1.9343e+25
y =
   3.8686e+25
y =
   7.7371e+25
y =
   1.5474e+26
y =
   3.0949e+26
y =
   6.1897e+26
y =
   1.2379e+27
y =
   2.4759e+27
y =
   4.9518e+27
y =
   9.9035e+27
y =
   1.9807e+28
y =
   3.9614e+28
y =
   7.9228e+28
y =
   1.5846e+29
y =
   3.1691e+29
y =
   6.3383e+29
y =
   1.2677e+30