Lesson goal: Contest Statistics: Mean of a Data Set (AMC 10A Problem 8)

Previous: Contest Map Coloring: Five Regions | Home | Next: Contest Combinatorics: Pairing Numbers

In the 2022 AMC 10A competition, Problem #8 tests how mathematical averages relate to individual data values:

Contest Problem Statement:
"A data set consists of 6 (not distinct) positive integers: 1, 7, 5, 2, 5, and X. The average (arithmetic mean) of the 6 numbers equals a value in the data set. What is the sum of all possible values of X?"

Mathematical Formulation

The sum of the five known numbers is:
$$1 + 7 + 5 + 2 + 5 = 20$$
Including the unknown positive integer $X$, the total sum is $20 + X$. The arithmetic mean of all 6 numbers is therefore:
$$\text{Mean} = \frac{20 + X}{6} \implies 6 \times \text{Mean} = 20 + X$$
Solving for $X$ in terms of the mean gives:
$$X = 6 \times \text{Mean} - 20$$
Since the problem specifies that $\text{Mean}$ must be equal to a value in the dataset, $\text{Mean} \in \{1, 7, 5, 2, 5, X\}$.

Let's analyze the cases:
  1. $\text{Mean} = 1$: $X = 6(1) - 20 = -14$ — rejected, because $X$ must be a positive integer ($X > 0$).
  2. $\text{Mean} = 2$: $X = 6(2) - 20 = -8$ — rejected, because $X$ must be positive.
  3. $\text{Mean} = 5$: $X = 6(5) - 20 = 10$. Check: the set is $[1, 7, 5, 2, 5, 10]$, sum is $30$, mean is $30 / 6 = 5$, which is in the set! Valid: $X = 10$.
  4. $\text{Mean} = 7$: $X = 6(7) - 20 = 22$. Check: the set is $[1, 7, 5, 2, 5, 22]$, sum is $42$, mean is $42 / 6 = 7$, which is in the set! Valid: $X = 22$.
  5. $\text{Mean} = X$: $6X = 20 + X \implies 5X = 20 \implies X = 4$. Check: the set is $[1, 7, 5, 2, 5, 4]$, sum is $24$, mean is $24 / 6 = 4 = X$, which is in the set! Valid: $X = 4$.
The possible values for $X$ are $4, 10,$ and $22$. Their sum is $4 + 10 + 22 = 36$.

Declarative Search with Prolog

In Prolog, we don't need to manually test cases by hand. We can express the data set constraint declaratively:
  • $X$ is a positive integer.
  • $\text{Mean}$ is an element of the list [1, 7, 5, 2, 5, X].
  • $20 + X = 6 \times \text{Mean}$.
Prolog's backtracking engine explores the domain and unifies all valid values of $X$ and $\text{Mean}$!
valid_solution(X, Mean) :- between_num(1, 100, X),member(Mean, [1, 7, 5, 2, 5, X]),% Sum of 6 numbers equals 6 * Mean: Replace ???? with 6 20 + X =:= 6 * Mean.
Move the mouse over a dotted box for more information.

Prolog automatically tests each member of the candidate list for the Mean, binds $X$, checks the arithmetic equation, and generates every valid solution!

Now you try. Replace ???? with 6 and click Run to see the list of valid X values [4, 10, 22] and total sum 36. Then look at Example 1 to inspect each solution pair (X, Mean) individually!

Type your code here:


See your results here: