Determine the number of permutations (p
1, p
2,...p
7) of 1,2, ...7; such that for all k 1≤k≤6, (p
1, p
2,... p
k)
is not a permutation of (1,2, ...k); i.e., p
1≠1; (p
1, p
2) is not a permutation of (1,2), etc.
What would be the answer if we specify 1≤k<6 instead?
(In reply to
k <= 1,2,3,4,5,6 by Steve Herman)
The numbers I get are:
max k answer
1 4320
2 4200
3 4128
4 4050
5 3908
6 3447
a=[1 2 3 4 5 6 7]
for kmax=1:6
p=perms(a); count=0;
for r=1:size(p)
p0=p(r,:); good=true;
for k=1:kmax
pk=p0(1:k);
pt=a(1:k);
if isequal(pt,sort(pk))
good=false;
break
end
end
if good
count= count+1;
end
end
disp([kmax count])
end
|
Posted by Charlie
on 2020-11-24 20:36:07 |