login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A279214 Number of permutations sigma such that |sigma(i+1)-sigma(i)| >= 3 for 1 <= i <= n - 1 and |sigma(i+2)-sigma(i)| >= 3 for 1 <= i <= n - 2. 4

%I #79 Dec 02 2018 02:57:08

%S 1,1,0,0,0,0,0,0,0,2,40,792,15374,281434,5089060,93082532,1743601076,

%T 33694028152

%N Number of permutations sigma such that |sigma(i+1)-sigma(i)| >= 3 for 1 <= i <= n - 1 and |sigma(i+2)-sigma(i)| >= 3 for 1 <= i <= n - 2.

%C 2 | a(n) for n > 1.

%e a(9) = 2: 369258147, 741852963.

%o (Ruby)

%o def check(d, a, i)

%o return true if i == 0

%o j = 1

%o d_max = [i, d - 1].min

%o while (a[i] - a[i - j]).abs >= d && j < d_max

%o j += 1

%o end

%o (a[i] - a[i - j]).abs >= d

%o end

%o def solve(d, len, a = [])

%o b = []

%o if a.size == len

%o b << a

%o else

%o (1..len).each{|m|

%o s = a.size

%o if s == 0 || (s > 0 && !a.include?(m))

%o if check(d, a + [m], s)

%o b += solve(d, len, a + [m])

%o end

%o end

%o }

%o end

%o b

%o end

%o def A279214(n)

%o (0..n).map{|i| solve(3, i).size}

%o end

%o p A279214(12)

%Y Cf. A002464 (|sigma(i+1)-sigma(i)| >= 2), A127697 (|sigma(i+1)-sigma(i)| >= 3).

%K nonn,more

%O 0,10

%A _Seiichi Manyama_, Dec 17 2016

%E a(0)-a(2), a(15)-a(17) from _Alois P. Heinz_, Dec 01 2018

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 15:18 EDT 2024. Contains 371960 sequences. (Running on oeis4.)