Cody

Solution 2328543

Submitted on 22 May 2020 by Russell Jones
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 = 1; y_correct = false; assert(isequal(isnilpotent(x),y_correct))

x = 1 y = logical 0 x = 1 y = logical 0 x = 1 y = logical 0 x = 1 y = logical 0 x = 1 y = logical 0 x = 1 y = logical 0 x = 1 y = logical 0 x = 1 y = logical 0 x = 1 y = logical 0 x = 1 y = logical 0

2   Pass
x = gallery('chebspec',5,0); y_correct = true; assert(isequal(isnilpotent(x),y_correct))

x = 5.5000 -6.8284 2.0000 -1.1716 0.5000 1.7071 -0.7071 -1.4142 0.7071 -0.2929 -0.5000 1.4142 -0.0000 -1.4142 0.5000 0.2929 -0.7071 1.4142 0.7071 -1.7071 -0.5000 1.1716 -2.0000 6.8284 -5.5000 y = logical 1 x = 17.0000 -28.4853 18.0000 -11.5147 5.0000 9.2426 -14.0000 6.0000 -2.0000 0.7574 -1.0000 4.0000 -6.0000 4.0000 -1.0000 0.7574 -2.0000 6.0000 -14.0000 9.2426 5.0000 -11.5147 18.0000 -28.4853 17.0000 y = logical 1 x = 30.0000 -56.4853 48.0000 -39.5147 18.0000 22.9706 -42.4264 33.9411 -25.4558 10.9706 6.0000 -8.4853 -0.0000 8.4853 -6.0000 -10.9706 25.4558 -33.9411 42.4264 -22.9706 -18.0000 39.5147 -48.0000 56.4853 -30.0000 y = logical 1 x = 24.0000 -48.0000 48.0000 -48.0000 24.0000 24.0000 -48.0000 48.0000 -48.0000 24.0000 24.0000 -48.0000 48.0000 -48.0000 24.0000 24.0000 -48.0000 48.0000 -48.0000 24.0000 24.0000 -48.0000 48.0000 -48.0000 24.0000 y = logical 1 x = 1.0e-11 * -0.0925 0.1343 -0.0782 0.0540 -0.0227 -0.0449 0.0512 -0.0178 0 0.0028 0.0050 -0.0213 0.0227 -0.0199 0.0057 -0.0021 0.0011 -0.0142 0.0512 -0.0426 -0.0346 0.0536 -0.0654 0.1307 -0.0938 y = logical 1 x = 1.0e-11 * -0.2231 0.3638 -0.2728 0.2160 -0.0966 -0.1577 0.2444 -0.1762 0.1251 -0.0568 -0.0298 0.0227 -0.0057 -0.0227 0.0227 0.0341 -0.1023 0.1364 -0.2160 0.1421 0.0199 -0.1080 0.2160 -0.3752 0.2274 y = logical 1 x = 1.0e-11 * -0.3695 0.6480 -0.4547 0.4093 -0.1933 -0.2899 0.5230 -0.2956 0.2728 -0.1478 -0.1535 0.2842 -0.1364 0.2046 -0.1137 -0.2103 0.4320 -0.3411 0.4547 -0.2615 -0.4206 0.8185 -0.7503 0.8640 -0.4547 y = logical 1 x = 1.0e-11 * -0.4547 0.7958 -0.6139 0.5457 -0.1933 -0.4093 0.7276 -0.5457 0.4775 -0.1819 -0.1478 0.2046 -0.0682 0 0.0796 0.0114 -0.1137 0.2956 -0.3638 0.2501 0.0114 -0.1137 0.2501 -0.3183 0.2274 y = logical 1 x = 1.0e-10 * -0.0579 0.1062 -0.0877 0.1030 -0.0636 -0.0505 0.0958 -0.0808 0.0861 -0.0505 -0.0469 0.0861 -0.0744 0.0958 -0.0606 -0.0511 0.0971 -0.0831 0.0939 -0.0568 -0.0464 0.0848 -0.0721 0.0880 -0.0543 y = logical 1 x = 1.0e-10 * -0.0314 0.0491 0.0068 -0.0945 0.0701 -0.0235 0.0429 -0.0136 -0.0429 0.0371 -0.0155 0.0156 0.0409 -0.1247 0.0837 -0.0178 0.0298 0.0068 -0.0753 0.0565 -0.0212 0.0287 0.0205 -0.0923 0.0644 y = logical 1

3   Pass
x = gallery('chebspec',3,0); y_correct = true; assert(isequal(isnilpotent(x),y_correct))

x = 1.5000 -2.0000 0.5000 0.5000 -0.0000 -0.5000 -0.5000 2.0000 -1.5000 y = logical 1 x = 1.0000 -2.0000 1.0000 1.0000 -2.0000 1.0000 1.0000 -2.0000 1.0000 y = logical 1 x = 1.0e-14 * -0.1443 0.0888 -0.0222 0 -0.0888 0.0444 0.0444 -0.0888 0 y = logical 1 x = 1.0e-14 * -0.1776 0.2665 -0.0888 -0.0888 0.0666 0 0 -0.1110 0.0666 y = logical 1 x = 1.0e-14 * -0.0888 0.1776 -0.0888 -0.0999 0.1776 -0.0777 -0.0888 0.1332 -0.0444 y = logical 1 x = 1.0e-15 * 0.0000 -0.0000 -0.0000 -0.2220 0.4441 -0.2220 -0.4441 0.8882 -0.4441 y = logical 1 x = 1.0e-29 * 0.2169 -0.3155 0.1578 0.1282 -0.1381 0.0493 0.0296 0.0394 -0.0493 y = logical 1 x = 1.0e-29 * 0.0789 -0.1972 0.0986 0.0986 -0.1923 0.0789 0.0986 -0.1479 0.0444 y = logical 1 x = 1.0e-29 * -0.0296 0.0394 -0.0099 0.0123 -0.0394 0.0271 0.0518 -0.1085 0.0567 y = logical 1 x = 1.0e-30 * -0.1972 0.3944 -0.1972 -0.1479 0.2958 -0.1479 -0.0493 0.0986 -0.0493 y = logical 1

4   Pass
x = [1 0 0;0 2 0; 0 0 -3]; y_correct = false; assert(isequal(isnilpotent(x),y_correct))

x = 1 0 0 0 2 0 0 0 -3 y = logical 1 x = 1 0 0 0 4 0 0 0 9 y = logical 0 x = 1 0 0 0 8 0 0 0 -27 y = logical 1 x = 1 0 0 0 16 0 0 0 81 y = logical 0 x = 1 0 0 0 32 0 0 0 -243 y = logical 1 x = 1 0 0 0 64 0 0 0 729 y = logical 0 x = 1 0 0 0 128 0 0 0 -2187 y = logical 1 x = 1 0 0 0 256 0 0 0 6561 y = logical 0 x = 1 0 0 0 512 0 0 0 -19683 y = logical 1 x = 1 0 0 0 1024 0 0 0 59049 y = logical 0

5   Pass
x = [6 -9; 4 -6]; y_correct = true; assert(isequal(isnilpotent(x),y_correct))

x = 6 -9 4 -6 y = logical 1 x = 0 0 0 0 y = logical 1 x = 0 0 0 0 y = logical 1 x = 0 0 0 0 y = logical 1 x = 0 0 0 0 y = logical 1 x = 0 0 0 0 y = logical 1 x = 0 0 0 0 y = logical 1 x = 0 0 0 0 y = logical 1 x = 0 0 0 0 y = logical 1 x = 0 0 0 0 y = logical 1

6   Pass
x = rand(50); y_correct = false; assert(isequal(isnilpotent(x),y_correct))

x = Columns 1 through 18 0.3725 0.9721 0.0557 0.2836 0.5046 0.4256 0.6402 0.1724 0.5640 0.1649 0.3570 0.3832 0.5643 0.6455 0.7581 0.9585 0.6795 0.0164 0.4782 0.2658 0.1887 0.9578 0.1124 0.7897 0.5385 0.0308 0.1204 0.4563 0.8763 0.8795 0.2290 0.8542 0.5376 0.8072 0.8230 0.1024 0.8414 0.1105 0.3133 0.2480 0.9034 0.2688 0.1612 0.5138 0.3902 0.8502 0.6239 0.8567 0.4251 0.2503 0.8817 0.6826 0.4216 0.0622 0.1670 0.0933 0.8979 0.9583 0.2188 0.1801 0.2006 0.8733 0.9368 0.7470 0.5599 0.8010 0.0859 0.7527 0.5770 0.0573 0.1676 0.4149 0.8789 0.6704 0.7709 0.2557 0.4357 0.4911 0.2706 0.7212 0.6774 0.7741 0.0917 0.0424 0.2377 0.2775 0.7880 0.2620 0.0974 0.4572 0.1107 0.4165 0.4020 0.5846 0.8431 0.0182 0.8399 0.0289 0.8040 0.6744 0.8663 0.0067 0.7211 0.6930 0.4849 0.7727 0.7094 0.8214 0.9436 0.1387 0.1840 0.0724 0.3396 0.8390 0.6597 0.0418 0.3524 0.6760 0.2081 0.8292 0.6750 0.8684 0.8501 0.2900 0.4264 0.2905 0.6503 0.9389 0.7574 0.4657 0.1143 0.1825 0.3375 0.2690 0.5991 0.7944 0.2809 0.6185 0.4195 0.9738 0.3976 0.6946 0.9483 0.3767 0.0835 0.3823 0.8088 0.0330 0.8959 0.5652 0.4780 0.9141 0.2460 0.5496 0.3537 0.0608 0.4448 0.5337 0.0710 0.6127 0.4160 0.8677 0.8408 0.3102 0.9013 0.2713 0.8228 0.9956 0.6226 0.5059 0.4828 0.3890 0.7701 0.3590 0.8016 0.2180 0.6428 0.7717 0.5910 0.8668 0.2231 0.2460 0.0757 0.2979 0.0540 0.9148 0.1021 0.2873 0.4896 0.5233 0.9774 0.5065 0.9139 0.7876 0.2836 0.6720 0.9966 0.4678 0.6331 0.1765 0.9395 0.0351 0.3117 0.1944 0.6110 0.7617 0.4240 0.5865 0.8310 0.2996 0.4948 0.9796 0.8681 0.2456 0.1106 0.2719 0.0581 0.7593 0.4939 0.3553 0.3975 0.2057 0.1703 0.8534 0.2754 0.6237 0.4430 0.4069 0.4534 0.9050 0.0939 0.7067 0.7068 0.5273 0.6279 0.2704 0.1551 0.9535 0.7062 0.4677 0.7502 0.0107 0.2694 0.6259 0.8967 0.5799 0.9975 0.8235 0.2358 0.3140 0.6441 0.4572 0.9358 0.4158 0.7364 0.4310 0.8516 0.0767 0.3155 0.0664 0.2881 0.4353 0.9780 0.7050 0.7831 0.3273 0.5138 0.9553 0.4361 0.0754 0.5527 0.2824 0.2489 0.5298 0.3965 0.7778 0.5724 0.8546 0.6718 0.5114 0.0465 0.8706 0.9386 0.3293 0.9621 0.9062 0.7791 0.9547 0.2986 0.6203 0.5041 0.6373 0.2345 0.6901 0.7262 0.3250 0.1581 0.0330 0.1767 0.2508 0.1780 0.5224 0.9719 0.8092 0.4408 0.8798 0.7674 0.9547 0.0180 0.5619 0.9506 0.7875 0.2307 0.3288 0.4576 0.9525 0.8148 0.0365 0.9341 0.6777 0.4062 0.3571 0.0131 0.2258 0.0568 0.1563 0.3446 0.7697 0.5700 0.5746 0.0934 0.3132 0.1406 0.0975 0.1324 0.7362 0.0178 0.1049 0.1451 0.2515 0.5329 0.8217 0.8160 0.6138 0.1546 0.4709 0.2361 0.7992 0.2277 0.8632 0.8973 0.3845 0.1356 0.4950 0.6734 0.9815 0.4981 0.8261 0.1409 0.9141 0.4439 0.3016 0.0564 0.9943 0.0331 0.5229 0.5744 0.0433 0.0950 0.1250 0.8675 0.2395 0.5141 0.8180 0.3869 0.1743 0.1294 0.8345 0.4898 0.1285 0.2943 0.7619 0.0515 0.8573 0.2102 0.5371 0.1970 0.3031 0.3349 0.9825 0.2795 0.1139 0.1280 0.4445 0.1487 0.2332 0.8548 0.3968 0.4395 0.5276 0.1966 0.2514 0.1394 0.2125 0.9268 0.8756 0.1653 0.6206 0.5670 0.4661 0.9262 0.9053 0.2487 0.3406 0.2458 0.1548 0.6997 0.8929 0.4370 0.8950 0.0484 0.8518 0.3983 0.9623 0.7323 0.9845 0.7684 0.7668 0.6114 0.6901 0.2791 0.3063 0.5665 0.9941 0.3973 0.1072 0.3562 0.1409 0.0725 0.2224 0.7559 0.4647 0.3029 0.3061 0.4042 0.1282 0.8395 0.2402 0.7117 0.3947 0.3203 0.6533 0.4449 0.3136 0.1218 0.2999 0.7496 0.5095 0.1980 0.9258 0.0443 0.3979 0.7539 0.9969 0.9524 0.2239 0.4282 0.8694 0.1373 0.9798 0.1235 0.0941 0.7976 0.1820 0.3106 0.8156 0.3856 0.7111 0.2872 0.3323 0.9063 0.0323 0.9332 0.9607 0.5455 0.0019 0.4821 0.3080 0.0681 0.4035 0.0024 0.4466 0.7106 0.5086 0.1067 0.8170 0.7659 0.2126 0.6784 0.5420 0.3879 0.1798 0.3530 0.5548 0.4310 0.7923 0.6219 0.8468 0.6601 0.8722 0.9981 0.7082 0.2793 0.2630 0.6243 0.7195 0.5729 0.8753 0.6433 0.6929 0.4645 0.8712 0.0199 0.4748 0.8333 0.2513 0.6844 0.4251 0.8429 0.5890 0.8926 0.4223 0.4141 0.7983 0.3034 0.2241 0.6533 0.4464 0.1201 0.1416 0.2283 0.6310 0.5364 0.5272 0.1980 0.8276 0.6874 0.6235 0.4472 0.2082 0.2555 0.3342 0.4831 0.8737 0.2100 0.7129 0.4418 0.4534 0.8067 0.5139 0.6104 0.0580 0.4171 0.1195 0.3617 0.2608 0.3617 0.2563 0.6904 0.0848 0.5014 0.5648 0.3827 0.9339 0.5715 0.5065 0.2606 0.6179 0.8184 0.2319 0.8637 0.4223 0.0265 0.9490 0.4965 0.4146 0.2574 0.2263 0.8559 0.2422 0.4478 0.3343 0.1082 0.2281 0.2631 0.2800 0.3696 0.3843 0.8031 0.7302 0.6565 0.2683 0.4239 0.9233 0.4009 0.9818 0.4057 0.7057 0.0104 0.0211 0.6060 0.1356 0.5658 0.5100 0.3981 0.3638 0.0593 0.1682 0.1566 0.5523 0.9027 0.1471 0.0254 0.3355 0.2305 0.1206 0.8226 0.6064 0.8545 0.1243 0.8866 0.7201 0.1975 0.2530 0.2310 0.3942 0.8137 0.8829 0.8694 0.2890 0.4897 0.5536 0.4590 0.0099 0.3130 0.5742 0.6534 0.7600 0.8173 0.8607 0.6029 0.6354 0.6605 0.2579 0.9522 0.7509 0.6075 0.2157 0.9517 0.7844 0.9958 0.4661 0.4943 0.1156 0.1395 0.0333 0.3443 0.5959 0.2011 0.8910 0.7389 0.6088 0.9253 0.2533 0.5710 0.6617 0.0837 0.3915 0.1985 0.2948 0.5263 0.0649 0.4238 0.2578 0.0657 0.3042 0.2745 0.7761 0.5761 0.2791 0.4588 0.2333 0.8093 0.9890 0.1198 0.9835 0.4427 0.0260 0.9282 0.7521 0.5040 0.5893 0.2164 0.6304 0.5891 0.6007 0.4403 0.3142 0.9393 0.2390 0.7926 0.9974 0.3533 0.7297 0.4144 0.5849 0.4082 0.9187 0.3190 0.4526 0.7353 0.1363 0.5824 0.8568 0.2358 0.1775 0.6609 0.3609 0.3759 0.2679 0.2627 0.5332 0.6292 0.2836 0.1882 0.2606 0.5357 0.5424 0.5749 0.7210 0.9863 0.3257 0.7217 0.3098 0.7466 0.5381 0.6685 0.9307 0.2232 0.4613 0.1976 0.1439 0.7781 0.2462 0.4843 0.9187 0.9421 0.4843 0.0799 0.8557 0.7356 0.8851 0.6712 0.4837 0.0626 0.7317 0.7103 0.0563 0.2973 0.0453 0.4021 0.2783 0.5155 0.8922 0.5025 0.6374 0.6426 0.5828 0.9344 0.7874 0.1529 0.2178 0.9765 0.7272 0.2748 0.5284 0.6272 0.3652 0.4115 0.5025 0.8245 0.5081 0.4807 0.5841 0.4290 0.3295 0.9697 0.1882 0.7671 0.7281 0.5310 0.4287 0.4502 0.8009 0.0135 0.8932 0.2189 0.0144 0.2941 0.7226 0.6469 0.1429 0.6492 0.8030 0.8587 0.1459 0.0963 0.8369 0.7413 0.3592 0.3001 0.8036 0.9319 0.4570 0.1051 0.1891 0.4599 0.0867 0.9733 0.7480 0.2533 0.8456 0.9201 0.9353 0.7572 0.7246 0.1051 0.3369 0.9360 0.0611 0.9258 0.9543 0.8045 0.4801 0.9198 0.0497 0.8428 0.4558 0.3966 0.1297 0.2487 0.7733 0.8157 0.9090 0.4437 0.9314 0.2064 0.5635 0.6752 0.8595 0.2956 0.0327 0.1197 0.3271 0.0386 0.9887 0.7007 0.8208 0.4698 0.5607 0.3815 0.1005 0.7846 0.1571 0.0052 0.2653 0.0254 0.8983 0.1797 0.1298 0.8081 0.1778 0.8333 0.3725 0.5161 0.4835 0.0976 0.8208 0.6303 0.1697 0.7829 0.9004 0.8342 0.8007 0.8650 0.0879 0.8317 0.3766 0.4406 0.9740 Columns 19 through 36 0.5171 0.4049 0.8572 0.7931 0.2907 0.4388 0.2776 0.6014 0.3038 0.5771 0.8731 0.5864 0.4288 0.3930 0.1274 0.1856 0.5652 0.9173 0.1177 0.6045 0.7069 0.9345 0.1733 0.5169 0.5192 0.5922 0.3029 0.3289 0.8362 0.6174 0.5127 0.9680 0.9544 0.5358 0.4334 0.1500 0.2025 0.6460 0.4842 0.5337 0.1297 0.9968 0.3820 0.6363 0.5121 0.4116 0.5754 0.9017 0.3024 0.6394 0.8771 0.0083 0.1397 0.9141 0.5893 0.1920 0.2497 0.1590 0.4173 0.9375 0.9386 0.7831 0.7733 0.1603 0.3843 0.1763 0.2104 0.0488 0.9049 0.0186 0.8399 0.0644 0.6637 0.8998 0.3230 0.3080 0.4102 0.0336 0.7079 0.8295 0.2244 0.2913 0.0548 0.5253 0.3921 0.5614 0.0472 0.0904 0.1076 ...

Suggested Problems

More from this Author9