Cody

# Problem 44319. Write c^3 as sum of two squares a^2+b^2

Solution 3286633

Submitted on 20 Oct 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
c = 1; y_correct = []; assert(isequal(sumoftwosquares(c),y_correct))

2   Pass
c = 5; y_correct = [2 11; 5 10]; assert(isequal(sumoftwosquares(c),y_correct))

y = 2 11 y = 2 11 5 10 y = 2 11 5 10 10 5 y = 2 11 5 10 10 5 11 2

3   Pass
c = 6; y_correct = []; assert(isequal(sumoftwosquares(c),y_correct))

4   Pass
c = 10; y_correct = [10 30; 18 26]; assert(isequal(sumoftwosquares(c),y_correct))

y = 10 30 y = 10 30 18 26 y = 10 30 18 26 26 18 y = 10 30 18 26 26 18 30 10

5   Pass
c = 20; y_correct = [16 88; 40 80]; assert(isequal(sumoftwosquares(c),y_correct))

y = 16 88 y = 16 88 40 80 y = 16 88 40 80 80 40 y = 16 88 40 80 80 40 88 16

6   Pass
c = 24; y_correct = []; assert(isequal(sumoftwosquares(c),y_correct))

7   Pass
c = 40; y_correct = [80 240; 144 208]; assert(isequal(sumoftwosquares(c),y_correct))

y = 80 240 y = 80 240 144 208 y = 80 240 144 208 208 144 y = 80 240 144 208 208 144 240 80

8   Pass
c = 65; y_correct = [7 524; 65 520; 140 505; 191 488; 208 481; 260 455; 320 415; 364 377]; assert(isequal(sumoftwosquares(c),y_correct))

y = 7 524 y = 7 524 65 520 y = 7 524 65 520 140 505 y = 7 524 65 520 140 505 191 488 y = 7 524 65 520 140 505 191 488 208 481 y = 7 524 65 520 140 505 191 488 208 481 260 455 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 377 364 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 377 364 415 320 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 377 364 415 320 455 260 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 377 364 415 320 455 260 481 208 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 377 364 415 320 455 260 481 208 488 191 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 377 364 415 320 455 260 481 208 488 191 505 140 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 377 364 415 320 455 260 481 208 488 191 505 140 520 65 y = 7 524 65 520 140 505 191 488 208 481 260 455 320 415 364 377 377 364 415 320 455 260 481 208 488 191 505 140 520 65 524 7

9   Pass
c = 100; y_correct = [280 960; 352 936; 600 800]; assert(isequal(sumoftwosquares(c),y_correct))

y = 280 960 y = 280 960 352 936 y = 280 960 352 936 600 800 y = 280 960 352 936 600 800 800 600 y = 280 960 352 936 600 800 800 600 936 352 y = 280 960 352 936 600 800 800 600 936 352 960 280

10   Pass
c = 123; y_correct = []; assert(isequal(sumoftwosquares(c),y_correct))

11   Pass
c = 340; y_correct = [408 6256;1360 6120; 1680 6040; 2280 5840; 2584 5712; 3304 5328; 3824 4968; 4080 4760]; assert(isequal(sumoftwosquares(c),y_correct))

y = 408 6256 y = 408 6256 1360 6120 y = 408 6256 1360 6120 1680 6040 y = 408 6256 1360 6120 1680 6040 2280 5840 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 4760 4080 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 4760 4080 4968 3824 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 4760 4080 4968 3824 5328 3304 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 4760 4080 4968 3824 5328 3304 5712 2584 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 4760 4080 4968 3824 5328 3304 5712 2584 5840 2280 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 4760 4080 4968 3824 5328 3304 5712 2584 5840 2280 6040 1680 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 4760 4080 4968 3824 5328 3304 5712 2584 5840 2280 6040 1680 6120 1360 y = 408 6256 1360 6120 1680 6040 2280 5840 2584 5712 3304 5328 3824 4968 4080 4760 4760 4080 4968 3824 5328 3304 5712 2584 5840 2280 6040 1680 6120 1360 6256 408

12   Fail
c = 500; y_correct = [1160 11120; 2000 11000; 5000 10000; 5744 9592; 7600 8200]; assert(isequal(sumoftwosquares(c),y_correct))

y = 5000 10000 y = 5000 10000 5744 9592 y = 5000 10000 5744 9592 7600 8200 y = 5000 10000 5744 9592 7600 8200 8200 7600 y = 5000 10000 5744 9592 7600 8200 8200 7600 9592 5744 y = 5000 10000 5744 9592 7600 8200 8200 7600 9592 5744 10000 5000

Assertion failed.

### Community Treasure Hunt

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

Start Hunting!