Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #35 Jul 05 2017 15:52:44
%S 2,26,242,2194,21304,226388,2643008
%N Number of maximal roller coasters in all n! permutations of n elements.
%C A roller coaster is a pattern in a permutation (not necessarily consecutive) consisting of alternating up and down steps, with always at least two in one direction.
%C A maximal roller coaster is one that cannot be extended further.
%C Note that the singleton pattern (only one element) is not considered a roller coaster.
%C Examples:
%C - 123 and 321 are the only two (maximal) roller coasters in all permutations with 3 elements; see also the examples section. These patterns are the smallest two roller coasters that exist.
%C - The permutation 1536742 contains the maximal roller coasters 136742, 156742 and 532, no further maximal roller coaster.
%C - The permutation 163978524 contains among others the maximal roller coasters 124 and 137854. In total, this permutation has 14 maximal roller coasters.
%C - The permutation 1254367 is already a roller coaster, so the only maximal roller coaster is the permutation itself.
%H Daniel Krenn, <a href="https://github.com/dkrenn/sequences-roller-coasters">sequences-roller-coasters</a>, program in SageMath, on GitHub.
%e For n = 3 the a(3) = 2 maximal roller coasters are 123 (of the permutation 123) and 321 (of the permutation 321); the permutations 132, 213, 231 and 312 do not contain any roller coaster pattern.
%t rc[p_] := Block[{L = {}, s}, s = Select[Reverse@ Subsets[p, {2, Length@p}], Min[Length /@ Split[ Sign@ Differences@#]] >= 2 &]; Do[ If[ AllTrue[L, ! SubsetQ[#, e] &], AppendTo[L, e]], {e, s}]; Length@ L]; a[n_] := ParallelSum[rc@ p, {p, Permutations@ Range@ n}]; a /@ Range[3, 8] (* _Giovanni Resta_, Jul 05 2017 *)
%K nonn,more
%O 3,1
%A _Daniel Krenn_, Jul 01 2017
%E a(9) from _Giovanni Resta_, Jul 05 2017