Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,9 @@
function [New]=PerfectShuffle(Nitems, Nturns)
if mod(Nitems,2)==0 %only if even number
X=1:Nitems; %define deck
for c=1:Nturns %defines one shuffle
X=reshape(X,Nitems/2,2)'; %split the deck in two and stack halves
X=X(:)'; %mix the halves
end
New=X; %result of multiple shufflings
end

View file

@ -0,0 +1,13 @@
Result=[]; %vector to store results
Q=[8, 24, 52, 100, 1020, 1024, 10000]; %queries
for n=Q %for each query
Same=0; %initialize comparison
T=0; %initialize number of shuffles
while ~Same %while the result is not the original query
T=T+1; %one more shuffle
R=PerfectShuffle(n,T); %result of shuffling the query
Same=~(any(R-(1:n))); %same vector as the query
end %when getting the same vector
Result=[Result;T]; %collect results
end
disp([Q', Result])