Cody

Solution 1200238

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

ans = -3 3 ans = -1 1 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)))

ans = -7 -1 3 5 ans = -5 -3 1 7 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)))

ans = Columns 1 through 30 -63 -57 -53 -51 -45 -43 -39 -33 -29 -27 -23 -17 -15 -9 -5 -3 3 5 9 15 17 23 27 29 33 39 43 45 51 53 Columns 31 through 32 57 63 ans = Columns 1 through 30 -61 -59 -55 -49 -47 -41 -37 -35 -31 -25 -21 -19 -13 -11 -7 -1 1 7 11 13 19 21 25 31 35 37 41 47 49 55 Columns 31 through 32 59 61 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)))

ans = Columns 1 through 30 -255 -249 -245 -243 -237 -235 -231 -225 -221 -219 -215 -209 -207 -201 -197 -195 -189 -187 -183 -177 -175 -169 -165 -163 -159 -153 -149 -147 -141 -139 Columns 31 through 60 -135 -129 -125 -123 -119 -113 -111 -105 -101 -99 -95 -89 -85 -83 -77 -75 -71 -65 -63 -57 -53 -51 -45 -43 -39 -33 -29 -27 -23 -17 Columns 61 through 90 -15 -9 -5 -3 3 5 9 15 17 23 27 29 33 39 43 45 51 53 57 63 65 71 75 77 83 85 89 95 99 101 Columns 91 through 120 105 111 113 119 123 125 129 135 139 141 147 149 153 159 163 165 169 175 177 183 187 189 195 197 201 207 209 215 219 221 Columns 121 through 128 225 231 235 237 243 245 249 255 ans = Columns 1 through 30 -253 -251 -247 -241 -239 -233 -229 -227 -223 -217 -213 -211 -205 -203 -199 -193 -191 -185 -181 -179 -173 -171 -167 -161 -157 -155 -151 -145 -143 -137 Columns 31 through 60 -133 -131 -127 -121 -117 -115 -109 -107 -103 -97 -93 -91 -87 -81 -79 -73 -69 -67 -61 -59 -55 -49 -47 -41 -37 -35 -31 -25 -21 -19 Columns 61 through 90 -13 -11 -7 -1 1 7 11 13 19 21 25 31 35 37 41 47 49 55 59 61 67 69 73 79 81 87 91 93 97 103 Columns 91 through 120 107 109 115 117 121 127 131 133 137 143 145 151 155 157 161 167 171 173 179 181 185 191 193 199 203 205 211 213 217 223 Columns 121 through 128 227 229 233 239 241 247 251 253

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