Cody

# Problem 2737. Prouhet–Tarry–Escott (basic)

Solution 1200234

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   Pass
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)))

varargout = 1×2 cell array [1×2 double] [1×2 double] Each set has 2 elements.

2   Pass
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)))

varargout = 1×2 cell array [1×4 double] [1×4 double] Each set has 4 elements.

3   Pass
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)))

varargout = 1×2 cell array [1×32 double] [1×32 double] Each set has 32 elements.

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)))

varargout = 1×2 cell array [1×128 double] [1×128 double]

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

### Community Treasure Hunt

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

Start Hunting!