Cody

Solution 1229508

Submitted on 11 Jul 2017 by Said BOUREZG
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 = 56; y = 1; n = 1; A_correct = 56; assert(isequal(wheat_chess(x,y,n),A_correct))

ans = 56

2   Pass
x = 1; y = 2; n = 8; A_correct = 18446744073709551615; assert(isequal(wheat_chess(x,y,n),A_correct))

ans = 1 2 ans = 1 2 4 ans = 1 2 4 8 ans = 1 2 4 8 16 ans = 1 2 4 8 16 32 ans = 1 2 4 8 16 32 64 ans = 1 2 4 8 16 32 64 128 ans = 1 2 4 8 16 32 64 128 256 ans = 1 2 4 8 16 32 64 128 256 512 ans = 1 2 4 8 16 32 64 128 256 512 1024 ans = 1 2 4 8 16 32 64 128 256 512 1024 2048 ans = 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 ans = 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 ans = 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Column 16 32768 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 17 32768 65536 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 18 32768 65536 131072 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 19 32768 65536 131072 262144 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 20 32768 65536 131072 262144 524288 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 21 32768 65536 131072 262144 524288 1048576 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 22 32768 65536 131072 262144 524288 1048576 2097152 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 23 32768 65536 131072 262144 524288 1048576 2097152 4194304 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 24 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 25 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 26 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 27 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 28 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 29 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 ans = Columns 1 through 15 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 Columns 16 through 30 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912 ans = 1.0e+09 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0001 Columns 19 through 31 0.0003 0.0005 0.0010 0.0021 0.0042 0.0084 0.0168 0.0336 0.0671 0.1342 0.2684 0.5369 1.0737 ans = 1.0e+09 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0001 Columns 19 through 32 0.0003 0.0005 0.0010 0.0021 0.0042 0.0084 0.0168 0.0336 0.0671 0.1342 0.2684 0.5369 1.0737 2.1475 ans = 1.0e+09 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0001 Columns 19 through 33 0.0003 0.0005 0.0010 0.0021 0.0042 0.0084 0.0168 0.0336 0.0671 0.1342 0.2684 0.5369 1.0737 2.1475 4.2950 ans = 1.0e+09 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0001 Columns 19 through 34 0.0003 0.0005 0.0010 0.0021 0.0042 0.0084 0.0168 0.0336 0.0671 0.1342 0.2684 0.5369 1.0737 2.1475 4.2950 8.5899 ans = 1.0e+10 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Columns 19 through 35 0.0000 0.0001 0.0001 0.0002 0.0004 0.0008 0.0017 0.0034 0.0067 0.0134 0.0268 0.0537 0.1074 0.2147 0.4295 0.8590 1.7180 ans = 1.0e+10 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Columns 19 through 36 0.0000 0.0001 0.0001 0.0002 0.0004 0.0008 0.0017 0.0034 0.0067 0.0134 0.0268 0.0537 0.1074 0.2147 0.4295 0.8590 1.7180 3.4360 ans = 1.0e+10 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Columns 19 through 36 0.0000 0.0001 0.0001 0.0002 0.0004 0.0008 0.0017 0.0034 0.0067 0.0134 0.0268 0.0537 0.1074 0.2147 0.4295 0.8590 1.7180 3.4360 Column 37 6.8719 ans = 1.0e+11 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Columns 19 through 36 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0002 0.0003 0.0007 0.0013 0.0027 0.0054 0.0107 0.0215 0.0429 0.0859 0.1718 0.3436 Columns 37 through 38 0.6872 1.3744 ans = 1.0e+11 * Columns 1 through 18 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Columns 19 through 36 0.0000 0.0000 0.0000 0.0000 0.0000 0.000...

3   Pass
x = -1; y = 2; n = 8; A_correct = -18446744073709551615; assert(isequal(wheat_chess(x,y,n),A_correct))

ans = -1 -2 ans = -1 -2 -4 ans = -1 -2 -4 -8 ans = -1 -2 -4 -8 -16 ans = -1 -2 -4 -8 -16 -32 ans = -1 -2 -4 -8 -16 -32 -64 ans = -1 -2 -4 -8 -16 -32 -64 -128 ans = -1 -2 -4 -8 -16 -32 -64 -128 -256 ans = -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 ans = -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 ans = -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 ans = -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 ans = -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 ans = -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Column 16 -32768 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 17 -32768 -65536 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 18 -32768 -65536 -131072 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 19 -32768 -65536 -131072 -262144 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 20 -32768 -65536 -131072 -262144 -524288 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 21 -32768 -65536 -131072 -262144 -524288 -1048576 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 22 -32768 -65536 -131072 -262144 -524288 -1048576 -2097152 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 23 -32768 -65536 -131072 -262144 -524288 -1048576 -2097152 -4194304 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 24 -32768 -65536 -131072 -262144 -524288 -1048576 -2097152 -4194304 -8388608 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 25 -32768 -65536 -131072 -262144 -524288 -1048576 -2097152 -4194304 -8388608 -16777216 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 26 -32768 -65536 -131072 -262144 -524288 -1048576 -2097152 -4194304 -8388608 -16777216 -33554432 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 27 -32768 -65536 -131072 -262144 -524288 -1048576 -2097152 -4194304 -8388608 -16777216 -33554432 -67108864 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 28 -32768 -65536 -131072 -262144 -524288 -1048576 -2097152 -4194304 -8388608 -16777216 -33554432 -67108864 -134217728 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 29 -32768 -65536 -131072 -262144 -524288 -1048576 -2097152 -4194304 -8388608 -16777216 -33554432 -67108864 -134217728 -268435456 ans = Columns 1 through 15 -1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 Columns 16 through 30 -32768 -65536 -131072 -262144 -524288 -1048576 -2097152 -4194304 -8388608 -16777216 -33554432 -67108864 -134217728 -268435456 -536870912 ans = 1.0e+09 * Columns 1 through 18 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0001 -0.0001 Columns 19 through 31 -0.0003 -0.0005 -0.0010 -0.0021 -0.0042 -0.0084 -0.0168 -0.0336 -0.0671 -0.1342 -0.2684 -0.5369 -1.0737 ans = 1.0e+09 * Columns 1 through 18 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0001 -0.0001 Columns 19 through 32 -0.0003 -0.0005 -0.0010 -0.0021 -0.0042 -0.0084 -0.0168 -0.0336 -0.0671 -0.1342 -0.2684 -0.5369 -1.0737 -2.1475 ans = 1.0e+09 * Columns 1 through 18 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0001 -0.0001 Columns 19 through 33 -0.0003 -0.0005 -0.0010 -0.0021 -0.0042 -0.0084 -0.0168 -0.0336 -0.0671 -0.1342 -0.2684 -0.5369 -1.0737 -2.1475 -4.2950 ans = 1.0e+09 * Columns 1 through 18 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0001 -0.0001 Columns 19 through 34 -0.0003 -0.0005 -0.0010 -0.0021 -0.0042 -0.0084 -0.0168 -0.0336 -0.0671 -0.1342 -0.2684 -0.5369 -1.0737 -2.1475 -4.2950 -8.5899 ans = 1.0e+10 * Columns 1 through 18 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 Columns 19 through 35 -0.0000 -0.0001 -0.0001 -0.0002 -0.0004 -0.0008 -0.0017 -0.0034 -0.0067 -0.0134 -0.0268 -0.0537 -0.1074 -0.2147 -0.4295 -0.8590 -1.7180 ans = 1.0e+10 * Columns 1 through 18 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 Columns 19 through 36 -0.0000 -0.0001 -0.0001 -0.0002 -0.0004 -0.0008 -0.0017 -0.0034 -0.0067 -0.0134 -0.0268 -0.0537 -0.1074 -0.2147 -0.4295 -0.8590 -1.7180 -3.4360 ans = 1.0e+10 * Columns 1 through 18 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 Columns 19 through 36 -0.0000 -0.0001 -0.0001 -0.0002 -0.0004 -0.0008 -0.0017 -0.0034 -0.0067 -0.0134 -0.0268 -0.0537 -0.1074 -0.2147 -0.4295 -0.8590 -1.7180 -3.4360 Column 37 -6.8719 ans = 1.0e+11 * Columns 1 through 18 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 Columns 19 through 36 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0001 -0.0002 -0.0003 -0.0007 -0.0013 -0.0027 -0.0054 -0.0107 -0.0215 -0.0429 -0.0859 -0.1718 -0.3436 Columns 37 through 38 -0.6872 -1.3744 ans = 1.0e+11 * Columns 1 through 18 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 Columns 19 through 36 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.000...

4   Pass
x = 5; y = 3; n = 2; A_correct = 200; assert(isequal(wheat_chess(x,y,n),A_correct))

ans = 5 15 ans = 5 15 45 ans = 5 15 45 135 ans = 200

5   Pass
x = 10; y = -5; n = 3; A_correct = 3255210; assert(isequal(wheat_chess(x,y,n),A_correct))

ans = 10 -50 ans = 10 -50 250 ans = 10 -50 250 -1250 ans = 10 -50 250 -1250 6250 ans = 10 -50 250 -1250 6250 -31250 ans = 10 -50 250 -1250 6250 -31250 156250 ans = 10 -50 250 -1250 6250 -31250 156250 -781250 ans = 10 -50 250 -1250 6250 -31250 156250 -781250 3906250 ans = 3255210

6   Pass
x = 1; y = 0; n = 1; A_correct = 1; assert(isequal(wheat_chess(x,y,n),A_correct))

ans = 1

7   Pass
x = 1; y = 0; n = -1; A_correct = 'NaN'; assert(isequal(wheat_chess(x,y,n),A_correct))

8   Pass
x = 12; y = 1; n = 3; A_correct = 108; assert(isequal(wheat_chess(x,y,n),A_correct))

ans = 12 12 ans = 12 12 12 ans = 12 12 12 12 ans = 12 12 12 12 12 ans = 12 12 12 12 12 12 ans = 12 12 12 12 12 12 12 ans = 12 12 12 12 12 12 12 12 ans = 12 12 12 12 12 12 12 12 12 ans = 108