I am not able to figure out why the solutions of my code to test 8 and 9 are wrong.
My wrong results:
- test 8 -> '1250000041666667776'
- test 9 -> '13107200170666672128'
I get precisely the same results as Angelo...
Angelo and Heiko, your solutions are working to a degree. However to obtain exact results on big numbers you have to use different tools. You can search for uint64 and bigdecimal. Hope it helps.
Thanks for the tip with uint64.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
m = 1;
y_correct = '1';
assert(isequal(hexagonalSpiral(m),y_correct))
|
2 | Pass |
m = 2;
y_correct = '16';
assert(isequal(hexagonalSpiral(m),y_correct))
|
3 | Pass |
m = 5;
y_correct = '1293';
assert(isequal(hexagonalSpiral(m),y_correct))
|
4 | Pass |
m = 16;
y_correct = '420800';
assert(isequal(hexagonalSpiral(m),y_correct))
|
5 | Pass |
m = 100;
y_correct = '4000333360';
assert(isequal(hexagonalSpiral(m),y_correct))
|
6 | Pass |
m = 1295;
y_correct = '1456830580539887';
assert(isequal(hexagonalSpiral(m),y_correct))
|
7 | Pass |
m = 2500;
y_correct = '39062505208334000';
assert(isequal(hexagonalSpiral(m),y_correct))
|
8 | Fail |
m = 5000;
y_correct = '1250000041666668000';
assert(isequal(hexagonalSpiral(m),y_correct))
|
9 | Fail |
m = 8000;
y_correct = '13107200170666668800';
assert(isequal(hexagonalSpiral(m),y_correct))
|
Find relatively common elements in matrix rows
865 Solvers
3892 Solvers
739 Solvers
238 Solvers
62 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!