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 324434

Submitted on 27 Sep 2013 by Alfonso Nieto-Castanon

Correct

108Size
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.027618 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.048107 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.049421 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.050766 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.052098 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.053509 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.054940 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.056340 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.057801 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.059406 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.060971 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.062557 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.064199 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.065881 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.067618 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.069433 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.071301 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.073260 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.075309 seconds.