Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 324435

Submitted on 27 Sep 2013 by Alfonso Nieto-Castanon

Correct

102Size
Leading solution size is 94.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
tic
n=17;
exp=101;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.027744 seconds.
2
Pass
 
%%
n=19;
exp=123;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.030675 seconds.
3
Pass
 
%%
n=23;
exp=183;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.032155 seconds.
4
Pass
 
%%
n=29;
exp=289;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.033656 seconds.
5
Pass
 
%%
n=31;
exp=327;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.035143 seconds.
6
Pass
 
%%
n=37;
exp=465;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.036687 seconds.
7
Pass
 
%%
n=41;
exp=573;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.038270 seconds.
8
Pass
 
%%
n=43;
exp=627;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.039864 seconds.
9
Pass
 
%%
n=47;
exp=751;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.041512 seconds.
10
Pass
 
%%
n=53;
exp=953;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.043300 seconds.
11
Pass
 
%%
n=59;
exp=1179;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.045073 seconds.
12
Pass
 
%%
n=61;
exp=1257;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.046836 seconds.
13
Pass
 
%%
n=67;
exp=1515;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.048695 seconds.
14
Pass
 
%%
n=71;
exp=1703;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.050576 seconds.
15
Pass
 
%%
n=73;
exp=1797;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.052559 seconds.
16
Pass
 
%%
n=79;
exp=2103;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.054583 seconds.
17
Pass
 
%%
n=83;
exp=2323;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.056718 seconds.
18
Pass
 
%%
n=89;
exp=2669;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.058953 seconds.
19
Pass
 
%%
n=97;
exp=3165;
S=Graceful_Wichmann(n);
assert(S(end)==exp)
delta=abs(repmat(S,n,1)-repmat(S',1,n));
assert(length(unique(delta(:)))==S(end)+1)  % zero increases delta unique
toc
Elapsed time is 0.061348 seconds.