My friend and I play card games that often result in some very interesting mathematical conversations. One such conversation turned into a puzzle a few weeks back, and it was only a matter of time before it happened again:
You and a friend have a large deck of cards, all of which are numbered 1, 2, 3, or 4. There are many of each of these numbers in the deck.
You alternate placing down one card at a time in a pile. If, at any point, the sum of the most recently played group of cards equals the sum of a group of cards played immediately before them, then you and your friend both slap the pile. Whoever slaps first wins the pile.
Here are some sequences of cards that would be slapped once the last card in the sequence is played:
3, 2, 3, 4, 1 (because the last two cards have a sum equal to that of the two cards prior)
1, 2, 4, 3, 3 (because the last one card has a “sum” equal to that of the one card prior)
2, 3, 1, 2 (because the last two cards have a sum equal to that of the one card prior)
How many cards are in the longest possible sequence that is never slapped?
By the way, if you’re someone who’s just dying to see a Fiddler in more concise (and precise) mathematical language, then you’re in luck this week! Here’s the very same puzzle, but without that bothersome card game:
Determine the maximum k for which there exists a sequence a1, a2, ..., ak ∈ {1, 2, 3, 4}, such that for all values p, q, r with 1 ≤ p ≤ q < r ≤ k it is never true that
\(\sum_{m=p}^{q}{a_m} = \sum_{n=q+1}^{r}{a_n}.\)
I looked at simpler problems first. Let $H(N)$ be the number or cards in the maximum sized unslapped hand for $N$ unique cards.
$[1,1]$ would get slapped.
$[1,1]$ and $[2,2]$ would get slapped. This leaves $[1,2]$ and $[2,1]$.
$[1,2,2]$ and $[2,1,1]$ would get slapped. This leaves $[1,2,1]$ and $[2,1,2]$.
$[1,2,1,1]$, $[1,2,1,2]$, $[2,1,2,1]$ and $[2,1,2,2]$ would get slapped.
I created code that did the following :
There are four sequences of length 7 which remain unslapped :
$H(4) = 9$
Using my code, there is a single sequence of length 9 which remains unslapped.
$$[1, 4, 3, 4, 2, 4, 3, 4, 1]$$In the preceding puzzle, the numbers on the cards were 1 through 4. Suppose, instead, they were numbered 1 through N.
When N is 5, how many cards are in the longest possible sequence that is never slapped? What if N is 6? What if N is 7?
I used the same code from above. It took $N=1,2,3,4$ were calculated almost immediately. $N=5$ took less than 10 minutes, $N=6$ took about an hour, and $N=7$ took well over a day to calculate.
There are many sequences of maximum length for each $N$.