I apologize for the length of the spoiler. You have been warned.

[spoiler]

The seven questions are all of the form, "Is your number one of the following: _, _, _, _, _, _, _, _?" where each blank stands for one of the integers between 0 and 15.

As stated, these 16 ints can be expressed in binary as no more than 4 bits long. Thus, four of the questions are immediately apparent: you need to ask if there is a 1 in the bit corresponding to 1, 2, 4 or 8.

(1) 1, 3, 5, 7, 9, 11, 13, 15 //for the 1 bit

(2) 2, 3, 6, 7, 10, 11, 14, 15 //for the 2 bit

(3) 4, 5, 6, 7, 12, 13, 14, 15 //for the 4 bit

(4) 8, 9, 10, 11, 12, 13, 14, 15 //for the 8 bit

Notice that if the problem stated that the person could not lie at all, these four questions would suffice. Let 1 represent a "yes" and let 0 represent "no" and place these answers in a row from right to left; the sequence of 4 chars will give you the binary representation of the desired number.

However, the problem is that the person can lie once, and you can not determine from these four questions alone if the person lied and, if so, which answer is false. This is where the Hamming code comes in. A (7,4) Hamming code is a code where every four bits of info is sent as a string of seven bits: four for the actual data, and 3 additional bits as "parity check" bits. I believe that this is the smallest Hamming code possible for correcting single-bit errors in a set of four bits of info.

Thus the other three questions must somehow correspond to these 3 "check" bits. I will not explain the math here on how the following three questions can uniquely determine if an error occurred and, if so, which questions. You can check out this page which I think is at the level of a high school student or maybe 1st-year college student. Nothing harder than knowledge of base 2 and a bit of patience to work through an example step-by-step is required.

(5) 1, 2, 5, 6, 8, 11, 12, 15 //for the 1st check bit

(6) 1, 3, 4, 6, 8, 10, 13, 15 //for the 2nd check bit

(7) 2, 3, 4, 5, 8, 9, 14, 15 //for the 3rd check bit

How are these numbers grouped?

- The 1st "check" question lists numbers which, when expressed in binary, will yield an odd number when adding up the values in the bits for 8, 2, 1.
- The 2nd "check" question lists numbers which, when expressed in binary, will yield an odd number when adding up the values in the bits for 8, 4, 1.
- The 3rd "check" question lists numbers which, when expressed in binary, will yield an odd number when adding up the values in the bits for 8, 4, 2.

Another way of thinking of it is:

- Question 5 lists numbers for which you would get an odd number of "yes" answers between Questions 4, 2, and 1; that is, either exactly one of these questions or all three question would be answered "yes".
- Question 6 lists numbers for which you would get an odd number of "yes" answers for Questions 4, 3, and 1.
- Question 7 lists numbers for which you would get an odd number of "yes" answers for Questions 4, 3, and 2.

That's confusing. Here's an example. The number 11 in binary is (1011). Notice that there is a 0 in the place for the 4 bit, and a 1 for the bits for 8, 2, and 1. Thus, if the person answered these 3 questions truthfully, then you would get a yes for question (5), since 1+1+1 is an odd number, a no for question (6) since 1+0+1 is even, and a no for question (7) since 1+0+1 is an even number. Sorry, that's the best I can do.

OK, so you're probably wondering how you can detect a lie with these questions...again, I won't go into the math and will instead ask you to look at the page linked to earlier in my post.

[/spoiler]