Cody

Solution 1203666

Submitted on 3 Jun 2017 by LY Cao
  • Size: 15
  • This is the leading solution.
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)))

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

Each set has 2 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)))

Each set has 2 elements.

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

Each set has 2 elements.

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