Cody

Problem 2737. Prouhet–Tarry–Escott (basic)

Solution 1200226

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 ans = 0.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 = -1.9000 0.1000 ans = -0.9000 1.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 = -14.9000 -12.9000 -11.9000 -9.9000 -7.9000 -5.9000 -2.9000 -0.9000 0.1000 2.1000 5.1000 7.1000 9.1000 11.1000 12.1000 14.1000 ans = -15.9000 -13.9000 -10.9000 -8.9000 -6.9000 -4.9000 -3.9000 -1.9000 1.1000 3.1000 4.1000 6.1000 8.1000 10.1000 13.1000 15.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 -62.9000 -60.9000 -59.9000 -57.9000 -55.9000 -53.9000 -50.9000 -48.9000 -47.9000 -45.9000 -42.9000 -40.9000 -38.9000 -36.9000 -35.9000 -33.9000 -31.9000 Columns 18 through 34 -29.9000 -26.9000 -24.9000 -22.9000 -20.9000 -19.9000 -17.9000 -14.9000 -12.9000 -11.9000 -9.9000 -7.9000 -5.9000 -2.9000 -0.9000 0.1000 2.1000 Columns 35 through 51 5.1000 7.1000 9.1000 11.1000 12.1000 14.1000 17.1000 19.1000 20.1000 22.1000 24.1000 26.1000 29.1000 31.1000 33.1000 35.1000 36.1000 Columns 52 through 64 38.1000 40.1000 42.1000 45.1000 47.1000 48.1000 50.1000 53.1000 55.1000 57.1000 59.1000 60.1000 62.1000 ans = Columns 1 through 17 -63.9000 -61.9000 -58.9000 -56.9000 -54.9000 -52.9000 -51.9000 -49.9000 -46.9000 -44.9000 -43.9000 -41.9000 -39.9000 -37.9000 -34.9000 -32.9000 -30.9000 Columns 18 through 34 -28.9000 -27.9000 -25.9000 -23.9000 -21.9000 -18.9000 -16.9000 -15.9000 -13.9000 -10.9000 -8.9000 -6.9000 -4.9000 -3.9000 -1.9000 1.1000 3.1000 Columns 35 through 51 4.1000 6.1000 8.1000 10.1000 13.1000 15.1000 16.1000 18.1000 21.1000 23.1000 25.1000 27.1000 28.1000 30.1000 32.1000 34.1000 37.1000 Columns 52 through 64 39.1000 41.1000 43.1000 44.1000 46.1000 49.1000 51.1000 52.1000 54.1000 56.1000 58.1000 61.1000 63.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