Cody

# Problem 45453. Spiral Out - 02

Solution 3682133

Submitted on 16 Nov 2020
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
p= 1:27; y= [21 22 23 24 25 26 20 7 8 9 10 27 19 6 1 2 11 0 18 5 4 3 12 0 17 16 15 14 13 0 0 0 0 0 0 0]; assert(isequal(spi_out_3(p),y))

y = 21 22 23 24 25 26 20 7 8 9 10 27 19 6 1 2 11 0 18 5 4 3 12 0 17 16 15 14 13 0 0 0 0 0 0 0

2   Pass
p= 49:-1:1; y= [7 6 5 4 3 2 1 8 29 28 27 26 25 24 9 30 43 42 41 40 23 10 31 44 49 48 39 22 11 32 45 46 47 38 21 12 33 34 35 36 37 20 13 14 15 16 17 18 19]; assert(isequal(spi_out_3(p),y))

y = 7 6 5 4 3 2 1 8 29 28 27 26 25 24 9 30 43 42 41 40 23 10 31 44 49 48 39 22 11 32 45 46 47 38 21 12 33 34 35 36 37 20 13 14 15 16 17 18 19

3   Pass
p=[4074 4529 635 4567 3162 488 1393 2735 4788 4825 789 4853 4786 2427 4002 710 2109 4579 3962 4798 3279 179 4246 4670 3394 3789 3716 1962 3278 856 3531 160 1385 231 486 4118 3475 1586 4752 173 2194 1908 3828 3976 935 2449 2228 3232 3547 3774 1381 3399 3276 814 595 2492 4799 1702 2927 1120 3757 1276 2530 3496 4455 4797 2737 694 747 1288 4204 1272 4072 1218 4647 1750 983 1256 3081 2367 1759 4155 2927 2749 4586 1430 3787 3769 1903 2840 380 270 2654 3896 4671 650 2845 2347 60 1686 811 3972 1557 2643 829 3010 1315 3271 3447 3741 2253 420 1145 4567 762 4130 2692 4981 391 2214 534 4810 24 3875 4087 4344 423 1999 1300 4001 2158 4554 910 1320 728 681 4347 2899 2750 725 4266 3111 1755 2567 2010 380 1200 617 920 1200 2087 249 4514 4724 2455 2447 1689 4501 1847 557 3902 1949 1209 2020 483 660 4711 4781 2877 299 1174 1766 4106 78 216 845 3246 3659 3239 2255 2736 1482 3724 945 3434 918 1843 3129 3902 406 4647 3879 2434 2180 2234 1532 2543 2554 4089 3975]; y= [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1689 4501 1847 557 3902 1949 1209 2020 483 660 4711 4781 2877 299 0 2447 2253 420 1145 4567 762 4130 2692 4981 391 2214 534 4810 1174 0 2455 3741 4072 1218 4647 1750 983 1256 3081 2367 1759 4155 24 1766 0 4724 3447 1272 3828 3976 935 2449 2228 3232 3547 3774 2927 3875 4106 0 4514 3271 4204 1908 3279 179 4246 4670 3394 3789 1381 2749 4087 78 0 249 1315 1288 2194 4798 1393 2735 4788 4825 3716 3399 4586 4344 216 0 2087 3010 747 173 3962 488 4074 4529 789 1962 3276 1430 423 845 0 1200 829 694 4752 4579 3162 4567 635 4853 3278 814 3787 1999 3246 0 920 2643 2737 1586 2109 710 4002 2427 4786 856 595 3769 1300 3659 0 617 1557 4797 3475 4118 486 231 1385 160 3531 2492 1903 4001 3239 3975 1200 3972 4455 3496 2530 1276 3757 1120 2927 1702 4799 2840 2158 2255 4089 380 811 1686 60 2347 2845 650 4671 3896 2654 270 380 4554 2736 2554 2010 2567 1755 3111 4266 725 2750 2899 4347 681 728 1320 910 1482 2543 1532 2234 2180 2434 3879 4647 406 3902 3129 1843 918 3434 945 3724]; assert(isequal(spi_out_3(p),y))

y = Columns 1 through 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1689 4501 1847 557 3902 1949 1209 2020 483 660 4711 4781 2877 0 2447 2253 420 1145 4567 762 4130 2692 4981 391 2214 534 4810 0 2455 3741 4072 1218 4647 1750 983 1256 3081 2367 1759 4155 24 0 4724 3447 1272 3828 3976 935 2449 2228 3232 3547 3774 2927 3875 0 4514 3271 4204 1908 3279 179 4246 4670 3394 3789 1381 2749 4087 0 249 1315 1288 2194 4798 1393 2735 4788 4825 3716 3399 4586 4344 0 2087 3010 747 173 3962 488 4074 4529 789 1962 3276 1430 423 0 1200 829 694 4752 4579 3162 4567 635 4853 3278 814 3787 1999 0 920 2643 2737 1586 2109 710 4002 2427 4786 856 595 3769 1300 0 617 1557 4797 3475 4118 486 231 1385 160 3531 2492 1903 4001 3975 1200 3972 4455 3496 2530 1276 3757 1120 2927 1702 4799 2840 2158 4089 380 811 1686 60 2347 2845 650 4671 3896 2654 270 380 4554 2554 2010 2567 1755 3111 4266 725 2750 2899 4347 681 728 1320 910 2543 1532 2234 2180 2434 3879 4647 406 3902 3129 1843 918 3434 945 Column 15 0 299 1174 1766 4106 78 216 845 3246 3659 3239 2255 2736 1482 3724

4   Pass
p= pascal(6); p=p(:)'; y= [10 20 35 56 1 5 4 1 2 3 4 15 1 1 1 1 5 35 21 1 1 1 6 70 15 10 6 3 1 126 252 126 56 21 6 1]; assert(isequal(spi_out_3(p),y))

y = 10 20 35 56 1 5 4 1 2 3 4 15 1 1 1 1 5 35 21 1 1 1 6 70 15 10 6 3 1 126 252 126 56 21 6 1

5   Pass
p= eye(6); p=p(:)' y= [0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0]; assert(isequal(spi_out_3(p),y))

p = Columns 1 through 29 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 Columns 30 through 36 0 0 0 0 0 0 1 y = 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0

6   Pass
p= [-84 -132 -54 -104 -137 -31 -42 -101 -88 -94 -163 -146 -115,-159 -48]; y= [-42 -101 -88 -94 -31 -84 -132 -163 -137 -104 -54 -146 0 -48 -159 -115]; assert(isequal(spi_out_3(p),y))

y = -42 -101 -88 -94 -31 -84 -132 -163 -137 -104 -54 -146 0 -48 -159 -115

7   Fail
filetext = fileread('spi_out_3.m'); assert(isempty(strfind(filetext, 'spiral')),'spiral() forbidden')

spiral() forbidden

### Community Treasure Hunt

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

Start Hunting!