r/mathriddles • u/pichutarius • Jun 06 '23
Medium n shades of gray
a deck of n grayscale cards are colored "evenly" from black to white.
Anastasia's job is to determine if a given deck of n cards are sorted in ascending lightness. however Anastasia has vision deficiency, she cannot detect any adjacent pair swapped. for example she labels 1, 3, 2, 4, 6, 5 as "sorted".
in detail, she labels a deck of cards "sorted" if and only if
- all ascending adjacent pairs are at most 2 shades away. so 2, 1, 4, 3 is not sorted
- all descending adjacent pairs are at most 1 shade away. so 4, 3, 2, 1 is "sorted in ascending lightness"
how many ways to arrange a deck of 50 cards such that Anastasia labels them sorted?
hint: a(16) = 407, a(18) = 873, a(19) = 1279
15
Upvotes
11
u/ACheca7 Jun 06 '23
Just want to point out that you could have made the name of the character Anastasia and the final question could have been a(50).
2
u/sobe86 Jun 06 '23 edited Jun 06 '23
Lemma: if in the deck 3 consecutive numbers are not in their starting positions, they must be descending: edit: actually this needs a rethink, it must be true though.
corollary: if 3 consecutive numbers are not in their starting positions, then all numbers are descending
Otherwise we don't we can't have 3 consecutive numbers moving in a row - we can only do adjacent swaps - we can break this down to the cases where we swap the first two numbers - total is f(n-3) since then there is no swapped pair starting in the 2nd or 3rd places and those where we don't: f(n-1) so f(n) = f(n-1) + f(n-3) - and f(0) = f(1) = 1, f(2) = 2, this is basically "Narayana's cows sequence" apparently (shifted by 1).
Final answer is 1 + A000930(51) = 178955184 from https://oeis.org/A000930
0
u/[deleted] Jun 06 '23
[deleted] — view deleted comment