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!)
A322281 Number of permutations sigma such that |sigma(i+j)-sigma(i)| >= 4 for 1 <= i <= n - j, 1 <= j <= 3. 3

%I #17 Dec 02 2018 12:00:52

%S 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,74,2424,93424,4394386,201355480

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

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

%e a(16) = 2: [4,8,12,16,3,7,11,15,2,6,10,14,1,5,9,13] and its reverse.

%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 A322281(n)

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

%o end

%o p A322281(18)

%Y Cf. A179957, A279214.

%K nonn,more

%O 0,17

%A _Seiichi Manyama_, Dec 01 2018

%E a(21) from _Alois P. Heinz_, Dec 02 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 23 20:33 EDT 2024. Contains 371916 sequences. (Running on oeis4.)