# 2004 AIME I Problems/Problem 6

## Problem

An integer is called snakelike if its decimal representation $a_1a_2a_3\cdots a_k$ satisfies $a_i if $i$ is odd and $a_i>a_{i+1}$ if $i$ is even. How many snakelike integers between 1000 and 9999 have four distinct digits?

## Solution 1

We divide the problem into two cases: one in which zero is one of the digits and one in which it is not. In the latter case, suppose we pick digits $x_1,x_2,x_3,x_4$ such that $x_1. There are five arrangements of these digits that satisfy the condition of being snakelike: $x_1x_3x_2x_4$, $x_1x_4x_2x_3$, $x_2x_3x_1x_4$, $x_2x_4x_1x_3$, $x_3x_4x_1x_2$. Thus there are $5\cdot {9\choose 4}=630$ snakelike numbers which do not contain the digit zero.

In the second case we choose zero and three other digits such that $0. There are three arrangements of these digits that satisfy the condition of being snakelike: $x_2x_30x_4$, $x_2x_40x_3$, $x_3x_40x_2$. Because we know that zero is a digit, there are $3\cdot{9\choose 3}=252$ snakelike numbers which contain the digit zero. Thus there are $630+252=\boxed{882}$ snakelike numbers.

## Solution 2

We use complementary counting. Let's create the number from digits $a < b < c < d$, and, if we already picked the digits there are 5 ways to do so, as said in the first solution. And, let's just pick the digits from 0-9. This get's a total count of $5\cdot{10 \choose 4}$ But, this over-counts since it counts numbers like 0213. We can correct for this over-counting. Let's lock the first digit as 0, and permute 3 other chosen digits $a < b < c$. There are 2 ways to permute to make the number snakelike, b-a-c, or c-a-b. And, we pick a,b,c from 1 to 9, since 0 has already been chosen as one of the digits. So, the amount we have overcounted by is $2\cdot{9 \choose 3}$. $5\cdot{10 \choose 4} - 2\cdot{9 \choose 3} = \boxed{882}$