# Ook ook

At Brilli's zoo, she is trying to train a monkey to learn how to count. The monkey is given a stack of cards, numbered 1 to 30, in some random order. The cards are laid out from left to right. Each time the monkey moves the card numbered $$i+1$$ to the immediate right of the card numbered $$i$$, he gets a banana. Otherwise, the monkey gets an ant bite and has to undo his move.

What is the most number of bananas that the monkey can get?

Details and assumptions

No monkeys (or ants) were harmed in the making of this question.

The monkey does not get a banana if the card numbered $$i+1$$ is already to the immediate right of the card numbered $$i$$.

As an explicit example, if the first four cards were $$\{1, 3, 2, 5 \}$$ and the monkey moves card number 3 to the right of card number 2, the stack becomes $$\{ 1, 2, 3, 5 \}$$ and the monkey gets a banana.

×