Cody

Solution 1554789

Submitted on 8 Jun 2018 by alaa mrwat
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
filetext = fileread('triples.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

2   Pass
n = 1; mat_correct = []; assert(isequal(triples(n),mat_correct))

c = 1.4142

3   Pass
n = 20.5; mat_correct = []; assert(isequal(triples(n),mat_correct))

4   Pass
n = 15; mat_correct = [3, 4, 5; 5, 12, 13; 6, 8, 10; 9, 12, 15]; assert(isequal(triples(n),mat_correct))

c = 1.4142 c = 2.2361 c = 3.1623 c = 4.1231 c = 5.0990 c = 6.0828 c = 7.0711 c = 8.0623 c = 9.0554 c = 10.0499 c = 11.0454 c = 12.0416 c = 13.0384 c = 14.0357 c = 15.0333 c = 2.2361 c = 2.8284 c = 3.6056 c = 4.4721 c = 5.3852 c = 6.3246 c = 7.2801 c = 8.2462 c = 9.2195 c = 10.1980 c = 11.1803 c = 12.1655 c = 13.1529 c = 14.1421 c = 15.1327 c = 3.1623 c = 3.6056 c = 4.2426 c = 5 c = 5.8310 c = 6.7082 c = 7.6158 c = 8.5440 c = 9.4868 c = 10.4403 c = 11.4018 c = 12.3693 c = 13.3417 c = 14.3178 c = 15.2971 c = 4.1231 c = 4.4721 c = 5 c = 5.6569 c = 6.4031 c = 7.2111 c = 8.0623 c = 8.9443 c = 9.8489 c = 10.7703 c = 11.7047 c = 12.6491 c = 13.6015 c = 14.5602 c = 15.5242 c = 5.0990 c = 5.3852 c = 5.8310 c = 6.4031 c = 7.0711 c = 7.8102 c = 8.6023 c = 9.4340 c = 10.2956 c = 11.1803 c = 12.0830 c = 13 c = 13.9284 c = 14.8661 c = 15.8114 c = 6.0828 c = 6.3246 c = 6.7082 c = 7.2111 c = 7.8102 c = 8.4853 c = 9.2195 c = 10 c = 10.8167 c = 11.6619 c = 12.5300 c = 13.4164 c = 14.3178 c = 15.2315 c = 16.1555 c = 7.0711 c = 7.2801 c = 7.6158 c = 8.0623 c = 8.6023 c = 9.2195 c = 9.8995 c = 10.6301 c = 11.4018 c = 12.2066 c = 13.0384 c = 13.8924 c = 14.7648 c = 15.6525 c = 16.5529 c = 8.0623 c = 8.2462 c = 8.5440 c = 8.9443 c = 9.4340 c = 10 c = 10.6301 c = 11.3137 c = 12.0416 c = 12.8062 c = 13.6015 c = 14.4222 c = 15.2643 c = 16.1245 c = 17 c = 9.0554 c = 9.2195 c = 9.4868 c = 9.8489 c = 10.2956 c = 10.8167 c = 11.4018 c = 12.0416 c = 12.7279 c = 13.4536 c = 14.2127 c = 15 c = 15.8114 c = 16.6433 c = 17.4929 c = 10.0499 c = 10.1980 c = 10.4403 c = 10.7703 c = 11.1803 c = 11.6619 c = 12.2066 c = 12.8062 c = 13.4536 c = 14.1421 c = 14.8661 c = 15.6205 c = 16.4012 c = 17.2047 c = 18.0278 c = 11.0454 c = 11.1803 c = 11.4018 c = 11.7047 c = 12.0830 c = 12.5300 c = 13.0384 c = 13.6015 c = 14.2127 c = 14.8661 c = 15.5563 c = 16.2788 c = 17.0294 c = 17.8045 c = 18.6011 c = 12.0416 c = 12.1655 c = 12.3693 c = 12.6491 c = 13 c = 13.4164 c = 13.8924 c = 14.4222 c = 15 c = 15.6205 c = 16.2788 c = 16.9706 c = 17.6918 c = 18.4391 c = 19.2094 c = 13.0384 c = 13.1529 c = 13.3417 c = 13.6015 c = 13.9284 c = 14.3178 c = 14.7648 c = 15.2643 c = 15.8114 c = 16.4012 c = 17.0294 c = 17.6918 c = 18.3848 c = 19.1050 c = 19.8494 c = 14.0357 c = 14.1421 c = 14.3178 c = 14.5602 c = 14.8661 c = 15.2315 c = 15.6525 c = 16.1245 c = 16.6433 c = 17.2047 c = 17.8045 c = 18.4391 c = 19.1050 c = 19.7990 c = 20.5183 c = 15.0333 c = 15.1327 c = 15.2971 c = 15.5242 c = 15.8114 c = 16.1555 c = 16.5529 c = 17 c = 17.4929 c = 18.0278 c = 18.6011 c = 19.2094 c = 19.8494 c = 20.5183 c = 21.2132

5   Pass
n = 16; mat_correct = [3, 4, 5; 5, 12, 13; 6, 8, 10; 9, 12, 15]; assert(isequal(triples(n),mat_correct))

c = 1.4142 c = 2.2361 c = 3.1623 c = 4.1231 c = 5.0990 c = 6.0828 c = 7.0711 c = 8.0623 c = 9.0554 c = 10.0499 c = 11.0454 c = 12.0416 c = 13.0384 c = 14.0357 c = 15.0333 c = 16.0312 c = 2.2361 c = 2.8284 c = 3.6056 c = 4.4721 c = 5.3852 c = 6.3246 c = 7.2801 c = 8.2462 c = 9.2195 c = 10.1980 c = 11.1803 c = 12.1655 c = 13.1529 c = 14.1421 c = 15.1327 c = 16.1245 c = 3.1623 c = 3.6056 c = 4.2426 c = 5 c = 5.8310 c = 6.7082 c = 7.6158 c = 8.5440 c = 9.4868 c = 10.4403 c = 11.4018 c = 12.3693 c = 13.3417 c = 14.3178 c = 15.2971 c = 16.2788 c = 4.1231 c = 4.4721 c = 5 c = 5.6569 c = 6.4031 c = 7.2111 c = 8.0623 c = 8.9443 c = 9.8489 c = 10.7703 c = 11.7047 c = 12.6491 c = 13.6015 c = 14.5602 c = 15.5242 c = 16.4924 c = 5.0990 c = 5.3852 c = 5.8310 c = 6.4031 c = 7.0711 c = 7.8102 c = 8.6023 c = 9.4340 c = 10.2956 c = 11.1803 c = 12.0830 c = 13 c = 13.9284 c = 14.8661 c = 15.8114 c = 16.7631 c = 6.0828 c = 6.3246 c = 6.7082 c = 7.2111 c = 7.8102 c = 8.4853 c = 9.2195 c = 10 c = 10.8167 c = 11.6619 c = 12.5300 c = 13.4164 c = 14.3178 c = 15.2315 c = 16.1555 c = 17.0880 c = 7.0711 c = 7.2801 c = 7.6158 c = 8.0623 c = 8.6023 c = 9.2195 c = 9.8995 c = 10.6301 c = 11.4018 c = 12.2066 c = 13.0384 c = 13.8924 c = 14.7648 c = 15.6525 c = 16.5529 c = 17.4642 c = 8.0623 c = 8.2462 c = 8.5440 c = 8.9443 c = 9.4340 c = 10 c = 10.6301 c = 11.3137 c = 12.0416 c = 12.8062 c = 13.6015 c = 14.4222 c = 15.2643 c = 16.1245 c = 17 c = 17.8885 c = 9.0554 c = 9.2195 c = 9.4868 c = 9.8489 c = 10.2956 c = 10.8167 c = 11.4018 c = 12.0416 c = 12.7279 c = 13.4536 c = 14.2127 c = 15 c = 15.8114 c = 16.6433 c = 17.4929 c = 18.3576 c = 10.0499 c = 10.1980 c = 10.4403 c = 10.7703 c = 11.1803 c = 11.6619 c = 12.2066 c = 12.8062 c = 13.4536 c = 14.1421 c = 14.8661 c = 15.6205 c = 16.4012 c = 17.2047 c = 18.0278 c = 18.8680 c = 11.0454 c = 11.1803 c = 11.4018 c = 11.7047 c = 12.0830 c = 12.5300 c = 13.0384 c = 13.6015 c = 14.2127 c = 14.8661 c = 15.5563 c = 16.2788 c = 17.0294 c = 17.8045 c = 18.6011 c = 19.4165 c = 12.0416 c = 12.1655 c = 12.3693 c = 12.6491 c = 13 c = 13.4164 c = 13.8924 c = 14.4222 c = 15 c = 15.6205 c = 16.2788 c = 16.9706 c = 17.6918 c = 18.4391 c = 19.2094 c = 20 c = 13.0384 c = 13.1529 c = 13.3417 c = 13.6015 c = 13.9284 c = 14.3178 c = 14.7648 c = 15.2643 c = 15.8114 c = 16.4012 c = 17.0294 c = 17.6918 c = 18.3848 c = 19.1050 c = 19.8494 c = 20.6155 c = 14.0357 c = 14.1421 c = 14.3178 c = 14.5602 c = 14.8661 c = 15.2315 c = 15.6525 c = 16.1245 c = 16.6433 c = 17.2047 c = 17.8045 c = 18.4391 c = 19.1050 c = 19.7990 c = 20.5183 c = 21.2603 c = 15.0333 c = 15.1327 c = 15.2971 c = 15.5242 c = 15.8114 c = 16.1555 c = 16.5529 c = 17 c = 17.4929 c = 18.0278 c = 18.6011 c = 19.2094 c = 19.8494 c = 20.5183 c = 21.2132 c = 21.9317 c = 16.0312 c = 16.1245 c = 16.2788 c = 16.4924 c = 16.7631 c = 17.0880 c = 17.4642 c = 17.8885 c = 18.3576 c = 18.8680 c = 19.4165 c = 20 c = 20.6155 c = 21.2603 c = 21.9317 c = 22.6274

6   Pass
n = 100 mat_correct = ... [3 4 5; 5 12 13; 6 8 10; 7 24 25; 8 15 17; 9 12 15; 9 40 41; 10 24 26; 11 60 61; 12 16 20; 12 35 37; 13 84 85; 14 48 50; 15 20 25; 15 36 39; 16 30 34; 16 63 65; 18 24 30; 18 80 82; 20 21 29; 20 48 52; 21 28 35; 21 72 75; 24 32 40; 24 45 51; 24 70 74; 25 60 65; 27 36 45; 28 45 53; 28 96 100; 30 40 50; 30 72 78; 32 60 68; 33 44 55; 33 56 65; 35 84 91; 36 48 60; 36 77 85; 39 52 65; 39 80 89; 40 42 58; 40 75 85; 42 56 70; 45 60 75; 48 55 73; 48 64 80; 51 68 85; 54 72 90; 57 76 95; 60 63 87; 60 80 100; 65 72 97];

n = 100

7   Pass
n = 1000; s_correct = [881, 3]; assert(isequal(size(triples(n)), s_correct))

c = 1.4142 c = 2.2361 c = 3.1623 c = 4.1231 c = 5.0990 c = 6.0828 c = 7.0711 c = 8.0623 c = 9.0554 c = 10.0499 c = 11.0454 c = 12.0416 c = 13.0384 c = 14.0357 c = 15.0333 c = 16.0312 c = 17.0294 c = 18.0278 c = 19.0263 c = 20.0250 c = 21.0238 c = 22.0227 c = 23.0217 c = 24.0208 c = 25.0200 c = 26.0192 c = 27.0185 c = 28.0179 c = 29.0172 c = 30.0167 c = 31.0161 c = 32.0156 c = 33.0151 c = 34.0147 c = 35.0143 c = 36.0139 c = 37.0135 c = 38.0132 c = 39.0128 c = 40.0125 c = 41.0122 c = 42.0119 c = 43.0116 c = 44.0114 c = 45.0111 c = 46.0109 c = 47.0106 c = 48.0104 c = 49.0102 c = 50.0100 c = 51.0098 c = 52.0096 c = 53.0094 c = 54.0093 c = 55.0091 c = 56.0089 c = 57.0088 c = 58.0086 c = 59.0085 c = 60.0083 c = 61.0082 c = 62.0081 c = 63.0079 c = 64.0078 c = 65.0077 c = 66.0076 c = 67.0075 c = 68.0074 c = 69.0072 c = 70.0071 c = 71.0070 c = 72.0069 c = 73.0068 c = 74.0068 c = 75.0067 c = 76.0066 c = 77.0065 c = 78.0064 c = 79.0063 c = 80.0062 c = 81.0062 c = 82.0061 c = 83.0060 c = 84.0060 c = 85.0059 c = 86.0058 c = 87.0057 c = 88.0057 c = 89.0056 c = 90.0056 c = 91.0055 c = 92.0054 c = 93.0054 c = 94.0053 c = 95.0053 c = 96.0052 c = 97.0052 c = 98.0051 c = 99.0051 c = 100.0050 c = 101.0050 c = 102.0049 c = 103.0049 c = 104.0048 c = 105.0048 c = 106.0047 c = 107.0047 c = 108.0046 c = 109.0046 c = 110.0045 c = 111.0045 c = 112.0045 c = 113.0044 c = 114.0044 c = 115.0043 c = 116.0043 c = 117.0043 c = 118.0042 c = 119.0042 c = 120.0042 c = 121.0041 c = 122.0041 c = 123.0041 c = 124.0040 c = 125.0040 c = 126.0040 c = 127.0039 c = 128.0039 c = 129.0039 c = 130.0038 c = 131.0038 c = 132.0038 c = 133.0038 c = 134.0037 c = 135.0037 c = 136.0037 c = 137.0036 c = 138.0036 c = 139.0036 c = 140.0036 c = 141.0035 c = 142.0035 c = 143.0035 c = 144.0035 c = 145.0034 c = 146.0034 c = 147.0034 c = 148.0034 c = 149.0034 c = 150.0033 c = 151.0033 c = 152.0033 c = 153.0033 c = 154.0032 c = 155.0032 c = 156.0032 c = 157.0032 c = 158.0032 c = 159.0031 c = 160.0031 c = 161.0031 c = 162.0031 c = 163.0031 c = 164.0030 c = 165.0030 c = 166.0030 c = 167.0030 c = 168.0030 c = 169.0030 c = 170.0029 c = 171.0029 c = 172.0029 c = 173.0029 c = 174.0029 c = 175.0029 c = 176.0028 c = 177.0028 c = 178.0028 c = 179.0028 c = 180.0028 c = 181.0028 c = 182.0027 c = 183.0027 c = 184.0027 c = 185.0027 c = 186.0027 c = 187.0027 c = 188.0027 c = 189.0026 c = 190.0026 c = 191.0026 c = 192.0026 c = 193.0026 c = 194.0026 c = 195.0026 c = 196.0026 c = 197.0025 c = 198.0025 c = 199.0025 c = 200.0025 c = 201.0025 c = 202.0025 c = 203.0025 c = 204.0025 c = 205.0024 c = 206.0024 c = 207.0024 c = 208.0024 c = 209.0024 c = 210.0024 c = 211.0024 c = 212.0024 c = 213.0023 c = 214.0023 c = 215.0023 c = 216.0023 c = 217.0023 c = 218.0023 c = 219.0023 c = 220.0023 c = 221.0023 c = 222.0023 c = 223.0022 c = 224.0022 c = 225.0022 c = 226.0022 c = 227.0022 c = 228.0022 c = 229.0022 c = 230.0022 c = 231.0022 c = 232.0022 c = 233.0021 c = 234.0021 c = 235.0021 c = 236.0021 c = 237.0021 c = 238.0021 c = 239.0021 c = 240.0021 c = 241.0021 c = 242.0021 c = 243.0021 c = 244.0020 c = 245.0020 c = 246.0020 c = 247.0020 c = 248.0020 c = 249.0020 c = 250.0020 c = 251.0020 c = 252.0020 c = 253.0020 c = 254.0020 c = 255.0020 c = 256.0020 c = 257.0019 c = 258.0019 c = 259.0019 c = 260.0019 c = 261.0019 c = 262.0019 c = 263.0019 c = 264.0019 c = 265.0019 c = 266.0019 c = 267.0019 c = 268.0019 c = 269.0019 c = 270.0019 c = 271.0018 c = 272.0018 c = 273.0018 c = 274.0018 c = 275.0018 c = 276.0018 c = 277.0018 c = 278.0018 c = 279.0018 c = 280.0018 c = 281.0018 c = 282.0018 c = 283.0018 c = 284.0018 c = 285.0018 c = 286.0017 c = 287.0017 c = 288.0017 c = 289.0017 c = 290.0017 c = 291.0017 c = 292.0017 c = 293.0017 c = 294.0017 c = 295.0017 c = 296.0017 c = 297.0017 c = 298.0017 c = 299.0017 c = 300.0017 c = 301.0017 c = 302.0017 c = 303.0017 c = 304.0016 c = 305.0016 c = 306.0016 c = 307.0016 c = 308.0016 c = 309.0016 c = 310.0016 c = 311.0016 c = 312.0016 c = 313.0016 c = 314.0016 c = 315.0016 c = 316.0016 c = 317.0016 c = 318.0016 c = 319.0016 c = 320.0016 c = 321.0016 c = 322.0016 c = 323.0015 c = 324.0015 c = 325.0015 c = 326.0015 c = 327.0015 c = 328.0015 c = 329.0015 c = 330.0015 c = 331.0015 c = 332.0015 c = 333.0015 c = 334.0015 c = 335.0015 c = 336.0015 c = 337.0015 c = 338.0015 c = 339.0015 c = 340.0015 c = 341.0015 c = 342.0015 c = 343.0015 c = 344.0015 c = 345.0014 c = 346.0014 c = 347.0014 c = 348.0014 c = 349.0014 c = 350.0014 c = 351.0014 c = 352.0014 c = 353.0014 c = 354.0014 c = 355.0014 c = 356.0014 c = 357.0014 c = 358.0014 c = 359.0014 c = 360.0014 c = 361.0014 c = 362.0014 c = 363.0014 c = 364.0014 c = 365.0014 c = 366.0014 c = 367.0014 c = 368.0014 c = 369.0014 c = 370.0014 c = 371.0013 c = 372.0013 c = 373.0013 c = 374.0013 c = 375.0013 c = 376.0013 c = 377.0013 c = 378.0013 c = 379.0013 c = 380.0013 c = 381.0013 c = 382.0013 c = 383.0013 c = 384.0013 c = 385.0013 c = 386.0013 c = 387.0013 c = 388.0013 c = 389.0013 c = 390.0013 c = 391.0013 c = 392.0013 c = 393.0013 c = 394.0013 c = 395.0013 c = 396.0013 c = 397.0013 c = 398.0013 c = 399.0013 c = 400.0012 c = 401.0012 c = 402.0012 c = 403.0012 c = 404.0012 c = 405.0012 c = 406.0012 c = 407.0012 c = 408.0012 c = 409.0012 c = 410.0012 c = 411.0012 c = 412.0012 c = 413.0012 c = 414.0012 c = 415.0012 c = 416.0012 c = 417.0012 c = 418.0012 c = 419.0012 c = 420.0012 c = 421.0012 c = 422.0012 c = 423.0012 c = 424.0012 c = 425.0012 c = 426.0012 c = 427.0012 c = 428.0012 c = 429.0012 c = 430.0012 c = 431.0012 c = 432.0012 c = 433.0012 c = 434.0012 c = 435.0011 c = 436.0011 c = 437.0011 c = 438.0011 c = 439.0011 c = 440.0011 c = 441.0011 c = 442.0011 c = 443.0011 c = 444.0011 c = 445.0011 c = 446.0011 c = 447.0011 c = 448.0011 c = 449.0011 c = 450.0011 c = 451.0011 c = 452.0011 c = 453.0011 c = 454.0011 c = 455.0011 c = 456.0011 c = 457.0011 c = 458.0011 c = 459.0011 c = 460.0011 c = 461.0011 c = 462.0011 c = 463.0011 c = 464.0011 c = 465.0011 c = 466.0011 c = 467.0011 c = 468.0011 c = 469.0011 c = 470.0011 c = 471.0011 c = 472.0011 c = 473.0011 c = 474.0011 c = 475.0011 c = 476.0011 c = 477.0010 c = 478.0010 c = 479.0010 c = 480.0010 c = 481.0010 c = 482.0010 c = 483.0010 c = 484.0010 c = 485.0010 c = 486.0010 c = 487.0010 c = 488.0010 c = 489.0010 c = 490.0010 c = 491.0010 c = 492.0010 c = 493.0010 c = 494.0010 c = 495.0010 c = 496.0010 c = 497.0010 c = 498.0010 c = 499.0010 c = 500.0010 c = 501.0010 c = 502.0010 c = 503.0010 c = 504.0010 c = 505.0010 c = 506.0010 c = 507.0010 c = 508.0010 c = 509.0010 c = 510.0010 c = 511.0010 c = 512.0010 c = 513.0010 c = 514.0010 c = 515.0010 c = 516.0010 c = 517.0010 c = 518.0010 c = 519.0010 c = 520.0010 c = 521.0010 c = 522.0010 c = 523.0010 c = 524.0010 c = 525.0010 c = 526.0010 c = 527.0009 c = 528.0009 c = 529.0009 c = 530.0009 c = 531.0009 c = 532.0009 c = 533.0009 c = 534.0009 c = 535.0009 c = 536.0009 c = 537.0009 c = 538.0009 c = 539.0009 c = 540.0009 c = 541.0009 c = 542.0009 c = 543.0009 c = 544.0009 c = 545.0009 c = 546.0009 c = 547.0009 c = 548.0009 c = 549.0009 c = 550.0009 c = 551.0009 c = 552.0009 c = 553.0009 c = 554.0009 c = 555.0009 c = 556...