Cody

Solution 1200227

Submitted on 29 May 2017
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   Fail
n = 1; [A, B] = prouhet(n); assert(isequal(A, round(A)) && isequal(B, round(B))) assert(isempty(intersect(A, B))); assert(isequal(numel(A), numel(B), numel(unique(A)), numel(unique(B)))); assert(isequal(sum(A(:).^(1:n),1), sum(B(:).^(1:n),1))); disp(sprintf('Each set has %i elements.', numel(A)))

ans = -0.9000 0.1000 ans = -1.9000 1.1000

Assertion failed.

2   Fail
n = 2; [A, B] = prouhet(n); assert(isequal(A, round(A)) && isequal(B, round(B))) assert(isempty(intersect(A, B))); assert(isequal(numel(A), numel(B), numel(unique(A)), numel(unique(B)))); assert(isequal(sum(A(:).^(1:n),1), sum(B(:).^(1:n),1))); disp(sprintf('Each set has %i elements.', numel(A)))

ans = -3.9000 -0.9000 1.1000 2.1000 ans = -2.9000 -1.9000 0.1000 3.1000

Assertion failed.

3   Fail
n = 5; [A, B] = prouhet(n); assert(isequal(A, round(A)) && isequal(B, round(B))) assert(isempty(intersect(A, B))); assert(isequal(numel(A), numel(B), numel(unique(A)), numel(unique(B)))); assert(isequal(sum(A(:).^(1:n),1), sum(B(:).^(1:n),1))); disp(sprintf('Each set has %i elements.', numel(A)))

ans = Columns 1 through 17 -30.9000 -29.9000 -27.9000 -24.9000 -23.9000 -20.9000 -18.9000 -17.9000 -15.9000 -12.9000 -10.9000 -9.9000 -6.9000 -5.9000 -3.9000 -0.9000 0.1000 Columns 18 through 32 3.1000 5.1000 6.1000 9.1000 10.1000 12.1000 15.1000 17.1000 18.1000 20.1000 23.1000 24.1000 27.1000 29.1000 30.1000 ans = Columns 1 through 17 -31.9000 -28.9000 -26.9000 -25.9000 -22.9000 -21.9000 -19.9000 -16.9000 -14.9000 -13.9000 -11.9000 -8.9000 -7.9000 -4.9000 -2.9000 -1.9000 1.1000 Columns 18 through 32 2.1000 4.1000 7.1000 8.1000 11.1000 13.1000 14.1000 16.1000 19.1000 21.1000 22.1000 25.1000 26.1000 28.1000 31.1000

Assertion failed.

4   Fail
n = 7; [A, B] = prouhet(n); assert(isequal(A, round(A)) && isequal(B, round(B))) assert(isempty(intersect(A, B))); assert(isequal(numel(A), numel(B), numel(unique(A)), numel(unique(B)))); assert(isequal(sum(A(:).^(1:n),1), sum(B(:).^(1:n),1))); disp(sprintf('Each set has %i elements.', numel(A)))

ans = Columns 1 through 17 -126.9000 -125.9000 -123.9000 -120.9000 -119.9000 -116.9000 -114.9000 -113.9000 -111.9000 -108.9000 -106.9000 -105.9000 -102.9000 -101.9000 -99.9000 -96.9000 -95.9000 Columns 18 through 34 -92.9000 -90.9000 -89.9000 -86.9000 -85.9000 -83.9000 -80.9000 -78.9000 -77.9000 -75.9000 -72.9000 -71.9000 -68.9000 -66.9000 -65.9000 -63.9000 -60.9000 Columns 35 through 51 -58.9000 -57.9000 -54.9000 -53.9000 -51.9000 -48.9000 -46.9000 -45.9000 -43.9000 -40.9000 -39.9000 -36.9000 -34.9000 -33.9000 -30.9000 -29.9000 -27.9000 Columns 52 through 68 -24.9000 -23.9000 -20.9000 -18.9000 -17.9000 -15.9000 -12.9000 -10.9000 -9.9000 -6.9000 -5.9000 -3.9000 -0.9000 0.1000 3.1000 5.1000 6.1000 Columns 69 through 85 9.1000 10.1000 12.1000 15.1000 17.1000 18.1000 20.1000 23.1000 24.1000 27.1000 29.1000 30.1000 33.1000 34.1000 36.1000 39.1000 40.1000 Columns 86 through 102 43.1000 45.1000 46.1000 48.1000 51.1000 53.1000 54.1000 57.1000 58.1000 60.1000 63.1000 65.1000 66.1000 68.1000 71.1000 72.1000 75.1000 Columns 103 through 119 77.1000 78.1000 80.1000 83.1000 85.1000 86.1000 89.1000 90.1000 92.1000 95.1000 96.1000 99.1000 101.1000 102.1000 105.1000 106.1000 108.1000 Columns 120 through 128 111.1000 113.1000 114.1000 116.1000 119.1000 120.1000 123.1000 125.1000 126.1000 ans = Columns 1 through 17 -127.9000 -124.9000 -122.9000 -121.9000 -118.9000 -117.9000 -115.9000 -112.9000 -110.9000 -109.9000 -107.9000 -104.9000 -103.9000 -100.9000 -98.9000 -97.9000 -94.9000 Columns 18 through 34 -93.9000 -91.9000 -88.9000 -87.9000 -84.9000 -82.9000 -81.9000 -79.9000 -76.9000 -74.9000 -73.9000 -70.9000 -69.9000 -67.9000 -64.9000 -62.9000 -61.9000 Columns 35 through 51 -59.9000 -56.9000 -55.9000 -52.9000 -50.9000 -49.9000 -47.9000 -44.9000 -42.9000 -41.9000 -38.9000 -37.9000 -35.9000 -32.9000 -31.9000 -28.9000 -26.9000 Columns 52 through 68 -25.9000 -22.9000 -21.9000 -19.9000 -16.9000 -14.9000 -13.9000 -11.9000 -8.9000 -7.9000 -4.9000 -2.9000 -1.9000 1.1000 2.1000 4.1000 7.1000 Columns 69 through 85 8.1000 11.1000 13.1000 14.1000 16.1000 19.1000 21.1000 22.1000 25.1000 26.1000 28.1000 31.1000 32.1000 35.1000 37.1000 38.1000 41.1000 Columns 86 through 102 42.1000 44.1000 47.1000 49.1000 50.1000 52.1000 55.1000 56.1000 59.1000 61.1000 62.1000 64.1000 67.1000 69.1000 70.1000 73.1000 74.1000 Columns 103 through 119 76.1000 79.1000 81.1000 82.1000 84.1000 87.1000 88.1000 91.1000 93.1000 94.1000 97.1000 98.1000 100.1000 103.1000 104.1000 107.1000 109.1000 Columns 120 through 128 110.1000 112.1000 115.1000 117.1000 118.1000 121.1000 122.1000 124.1000 127.1000

Assertion failed.

5   Pass
%n = 9; %[A, B] = prouhet(n); %assert(isequal(A, round(A)) && isequal(B, round(B))) %assert(isempty(intersect(A, B))); %assert(isequal(numel(A), numel(B), numel(unique(A)), numel(unique(B)))); %assert(isequal(sum(uint64(A(:)).^uint64(1:n)), sum(uint64(A(:)).^uint64(1:n)))); %disp(sprintf('Each set has %i elements.', numel(A))) %if numel(A) <=20 % disp('A:') % disp(A) % disp('B:') % disp(B) %end

6   Pass
% test info % % larger n will be added later % % scoring function will be added later as well % scoring will be entirely based on size of output: smaller output == better score % something like this: % % score = 0; % for n = 1:25 % [A, B] = prouhet(n) % assert(...); % score = score + numel(A); % end

Suggested Problems

More from this Author47