Cody

Problem 44341. Hexagonal numbers on a spiral matrix

Solution 3044962

Submitted on 3 Oct 2020 by Augusto Mazzei
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
m = 1; y_correct = '1'; assert(isequal(hexagonalSpiral(m),y_correct))

a = 1 S = 1 ans = '1'

2   Pass
m = 2; y_correct = '16'; assert(isequal(hexagonalSpiral(m),y_correct))

a = 1 S = 1 6 ans = '16'

3   Pass
m = 5; y_correct = '1293'; assert(isequal(hexagonalSpiral(m),y_correct))

a = 1 S = 11 18 13 ans = '1293'

4   Pass
m = 16; y_correct = '420800'; assert(isequal(hexagonalSpiral(m),y_correct))

a = 1 S = 1 26 53 70 76 40 ans = '420800'

5   Pass
m = 100; y_correct = '4000333360'; assert(isequal(hexagonalSpiral(m),y_correct))

a = 1 S = 16 205 309 368 407 413 452 490 260 ans = '4000333360'

6   Pass
m = 1295; y_correct = '1456830580539887'; assert(isequal(hexagonalSpiral(m),y_correct))

a = 1 S = 1081 3261 4415 4986 5328 5555 5589 5802 5494 5753 5800 6352 3367 ans = '1456830580539887'

7   Pass
m = 2500; y_correct = '39062505208334000'; assert(isequal(hexagonalSpiral(m),y_correct))

a = 1 S = 3136 6721 8715 9857 10247 10647 11134 10943 11058 10697 11310 11250 12250 6500 ans = '39062505208334000'

8   Pass
m = 5000; y_correct = '1250000041666668000'; assert(isequal(hexagonalSpiral(m),y_correct))

a = 1 S = Columns 1 through 14 271 8146 14415 18029 19865 21071 21395 21904 22186 21947 22172 21751 22450 22500 Columns 15 through 16 24500 13000 ans = '1250000041666668000'

9   Pass
m = 8000; y_correct = '13107200170666668800'; assert(isequal(hexagonalSpiral(m),y_correct))

a = 1 S = Columns 1 through 14 10621 21714 27947 31600 33472 34406 34965 35490 35738 35335 35579 35383 35926 36000 Columns 15 through 16 39200 20800 ans = '13107200170666668800'