Reverse engineering a score: solving $x = 10a + 6b + 3c - 10d$

39 Views Asked by At

The problem

In a quiz, a user has 3 lives in which to answer each question. The score they get for a question is based on the number of lives they have remaining:

$3 \text{ lives left } = 10 \text{ points}$

$2 \text{ lives left } = 6 \text{ points}$

$1 \text{ life left } = 3 \text{ points}$

$0 \text{ lives left } = -10 \text{ points}$

There are $20$ questions in the quiz.

If all I have is the score, how can I reverse engineer it to find out the total number of lives they lost during the quiz?

Trying to find a solution

If I could know how many questions they got $10$ points for, how many they got $6$ points for $\dots$ and so on, I would be able to calculate the total number of lives they lost.

So say, I have a score of $170,$ with my incredibly limited abilities, I think I can say the following.

$$10a + 6b + 3c - 10d = 170$$

And I can also say

$$a + b + c + d = 20 \text{ (total questions in the quiz).}$$

But how do I go about getting a solution for this?

Background

I need to move user data between two systems and to conform it to the newer system, I need to provide detail of how many lives a user lost during the quiz. In the old system, I don't have that information, only a score. So I need a practical solution, that allows me to at least get close to how they performed, even if it is not $100\%$ accurate given that there may be multiple solutions in any given case.

1

There are 1 best solutions below

1
On BEST ANSWER

"Multiple solutions" is an understatement. There should be $\dbinom {23}3 = 1771$ different results, but only a maximum of $10\times 20- (-10)\times 20=400$ different scores. By Pigeonhole principle, some scores could give up to $5$ solutions (and $400$ is a very coarse upper bound).

In fact, although the score $170$ has a unique solution $(14, 4, 2,0)$, this is not true is general.

For example, the score $0$ has $7$ different solutions:

a, b, c, d:
----------
0, 6, 8, 6
1, 8, 4, 7
2, 10, 0, 8
4, 1, 8, 7
5, 3, 4, 8
6, 5, 0, 9
10, 0, 0, 10

Here is a program in C (by trial and error) verifying my claim. You can also check other numbers by changing the variable score. As you can see, these solutions indicate a vast diversity of results.