cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

This page as a plain text file.
%I A322281 #17 Dec 02 2018 12:00:52
%S A322281 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,74,2424,93424,4394386,201355480
%N A322281 Number of permutations sigma such that |sigma(i+j)-sigma(i)| >= 4 for 1 <= i <= n - j, 1 <= j <= 3.
%C A322281 2 | a(n) for n > 1.
%e A322281 a(16) = 2: [4,8,12,16,3,7,11,15,2,6,10,14,1,5,9,13] and its reverse.
%o A322281 (Ruby)
%o A322281 def check(d, a, i)
%o A322281   return true if i == 0
%o A322281   j = 1
%o A322281   d_max = [i, d - 1].min
%o A322281   while (a[i] - a[i - j]).abs >= d && j < d_max
%o A322281     j += 1
%o A322281   end
%o A322281   (a[i] - a[i - j]).abs >= d
%o A322281 end
%o A322281 def solve(d, len, a = [])
%o A322281   b = []
%o A322281   if a.size == len
%o A322281     b << a
%o A322281   else
%o A322281     (1..len).each{|m|
%o A322281       s = a.size
%o A322281       if s == 0 || (s > 0 && !a.include?(m))
%o A322281         if check(d, a + [m], s)
%o A322281           b += solve(d, len, a + [m])
%o A322281         end
%o A322281       end
%o A322281     }
%o A322281   end
%o A322281   b
%o A322281 end
%o A322281 def A322281(n)
%o A322281   (0..n).map{|i| solve(4, i).size}
%o A322281 end
%o A322281 p A322281(18)
%Y A322281 Cf. A179957, A279214.
%K A322281 nonn,more
%O A322281 0,17
%A A322281 _Seiichi Manyama_, Dec 01 2018
%E A322281 a(21) from _Alois P. Heinz_, Dec 02 2018