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,16 @@
(
d = { |array, n|
Routine {
n = n ?? { array.size.factorial };
n.do { |i|
var permuted = array.permute(i);
if(array.every { |each, i| permuted[i] != each }) {
permuted.yield
};
}
};
};
f = { |n| d.((0..n-1)) };
x = f.(4);
x.all.do(_.postln); "";
)

View file

@ -0,0 +1,9 @@
[ 3, 2, 1, 0 ]
[ 2, 3, 0, 1 ]
[ 1, 0, 3, 2 ]
[ 1, 2, 3, 0 ]
[ 2, 0, 3, 1 ]
[ 3, 2, 0, 1 ]
[ 1, 3, 0, 2 ]
[ 2, 3, 1, 0 ]
[ 3, 0, 1, 2 ]

View file

@ -0,0 +1,15 @@
(
z = { |n|
case
{ n <= 0 } { 1 }
{ n == 1 } { 0 }
{ (n - 1) * (z.(n - 1) + z.(n - 2)) }
};
p = { |i| i.asPaddedString(10, " ") };
"n derangements subfactorial".postln;
(0..9).do { |i|
var derangements = f.(i).all;
var subfactorial = z.(i);
"% % %\n".postf(i, p.(derangements.size), p.(subfactorial));
};
)

View file

@ -0,0 +1,11 @@
n derangements subfactorial
0 1 1
1 0 0
2 1 1
3 2 2
4 9 9
5 44 44
6 265 265
7 1854 1854
8 14833 14833
9 133496 133496