Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Perfect-shuffle/Scilab/perfect-shuffle.scilab
Normal file
28
Task/Perfect-shuffle/Scilab/perfect-shuffle.scilab
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
function New=PerfectShuffle(Nitems,Nturns)
|
||||
if modulo(Nitems,2)==0 then
|
||||
X=1:Nitems;
|
||||
for c=1:Nturns
|
||||
X=matrix(X,Nitems/2,2)';
|
||||
X=X(:);
|
||||
end
|
||||
New=X';
|
||||
end
|
||||
endfunction
|
||||
|
||||
Result=[];
|
||||
Q=[8, 24, 52, 100, 1020, 1024, 10000];
|
||||
for n=Q
|
||||
Same=0;
|
||||
T=0;
|
||||
Compare=[];
|
||||
while ~Same
|
||||
T=T+1;
|
||||
R=PerfectShuffle(n,T);
|
||||
Compare = find(R-(1:n));
|
||||
if Compare == [] then
|
||||
Same = 1;
|
||||
end
|
||||
end
|
||||
Result=[Result;T];
|
||||
end
|
||||
disp([Q', Result])
|
||||
Loading…
Add table
Add a link
Reference in a new issue