Given a list of items [1..N], how many permutations are there, as a function of N, where no element has moved more than one space away from its original position?
E.g. with three items:
[213] is valid, [312] (the 3 has moved too far) is not.
Joaz Banbeck wrote:I've been thinking about this one also. Not having the advantages of an Agean breeze, I'm not coming up with a good answer.
The best I've got is that as K approaches N, F(N) approaches N!
In other words...
Assuming N > K, N > 0, K > 0
F(N,0) = 1 1 1 1 1 1 ...
F(N,1) = 1 2 3 5 8 13 21 ...
F(N,2) = 1 2 6 14 ...
F(N,3) = 1 2 6 24 ...
...
F(N,N-1) = 1 2 6 24 120 760 ... = N!
I think I have the beginnings of a formula. For the first term that deviates from the factorial, the formula looks like this:
3 = 6 - ( 2 + 2 - 1 )
14 = 24 - ( 6 + 6 - 2 )
F(N,K) = N! - ( 2(N-1)! - K )
HermanHiddema wrote:... we've counted double those cases where both happen at the same time, which are (N-2)! cases...
wikipedia wrote:The Fibonacci numbers can be found in different ways in the sequence of binary strings.
* The number of binary strings of length n without consecutive 1s is the Fibonacci number Fn+2. For example, out of the 16 binary strings of length 4, there are F6 = 8 without consecutive 1s – they are 0000, 1000, 0100, 0010, 1010, 0001, 1001 and 0101. By symmetry, the number of strings of length n without consecutive 0s is also Fn+2.
* The number of binary strings of length n without an odd number of consecutive 1s is the Fibonacci number Fn+1. For example, out of the 16 binary strings of length 4, there are F5 = 5 without an odd number of consecutive 1s – they are 0000, 0011, 0110, 1100, 1111.
* The number of binary strings of length n without an even number of consecutive 0s or 1s is 2Fn. For example, out of the 16 binary strings of length 4, there are 2F4 = 6 without an even number of consecutive 0s or 1s – they are 0001, 1000, 1110, 0111, 0101, 1010.
Joaz Banbeck wrote:BTW...wikipedia wrote: * The number of binary strings of length n without consecutive 1s is the Fibonacci number Fn+2. For example, out of the 16 binary strings of length 4, there are F6 = 8 without consecutive 1s – they are 0000, 1000, 0100, 0010, 1010, 0001, 1001 and 0101. By symmetry, the number of strings of length n without consecutive 0s is also Fn+2.
Joaz Banbeck wrote:I've been thinking about this one also. Not having the advantages of an Agean breeze, I'm not coming up with a good answer.
The best I've got is that as K approaches N-1, F(N) approaches N!
In other words...
Assuming N > K, N > 0, K > 0
F(N,0) = 1 1 1 1 1 1 ...
F(N,1) = 1 2 3 5 8 13 21 ...
F(N,2) = 1 2 6 14 ...
F(N,3) = 1 2 6 24 ...
...
F(N,N-1) = 1 2 6 24 120 760 ... = N!
I think I have the beginnings of a formula. For the first term that deviates from the factorial, the formula looks like this:
3 = 6 - ( 2 + 2 - 1 )
14 = 24 - ( 6 + 6 - 2 )
F(N,K) = N! - ( 2(N-1)! - K )
perceval wrote:interesting...
conjecture: does that mean that no cycle of length greater than k+1 can exists (true for k=1)?
not sure but seems plausible
if true would that help ?
mmm i am gonna obsess about that one