3/29/09 8:32 PM
Mallard ECE 290: Computer Engineering I - Spring 2009 - HWK #1 Solutions
Page 1 of 7
https://mallard.cites.uiuc.edu/ECE290/material.cgi?SessionID=ramait…orial&title=HWK%20%231%20Solutions&bodyargs=&id=hwk01_s09_soln&num=
HWK #1 Solutions
SOLUTIONS
Problem 1.1
Before we begin, notice that each of the 5 cards has 16 numbers, exactly one of which is a power of 2. The
numbers are listed in numerically increasing order with the power of 2 displayed as the upper left entry. For
convenience, we refer to the card with 1 in the upper left corner as the 1-card, the card with 2 in the upper
left corner as the 2-card, etc.
a. Add the numbers in the upper left corner of each card the volunteer points to.
For instance, if the selected number is 19, the volunteer will point to the three cards that contain 19:
the 1-card, the 2-card, and the 16-card. As she points to each card in turn, the mathemagician
computes the sum 1 + 2 + 16 = 19.
b. Consider the cards arranged in left-to-right order: 16-card, 8-card, 4-card, 2-card, 1-card.
16
8
4
2
1
Every integer between 1 and 31 has a unique binary (base 2) representation. In other words, each can
be represented uniquely as a sum of powers of 2. In particular, each number between 1 and 31 has a
unique 5-bit binary representation. When the volunteer points out which cards contain her number,
she is in fact giving the powers of 2 which constitute her number.
For instance, with selected number 19, the volunteer notes that 19 does appear on the 16-card, does
not appear on the 8-card, does not appear on the 4-card, does appear on the 2-card, and does appear
on the 1-card. This corresponds to the binary number 10011, where 1 indicates the number does
appear on the corresponding card and 0 indicates it does not appear.
c. To extend the trick to include numbers 1 to 63, you will need to make 6 cards, each with 32 numbers
on it. The numbers in the upper left corner are: 1, 2, 4, 8, 16, 32. The numbers on each card are the
same as the numbers on the 5-card set, but in addition each card contains the same numbers added to
32. Another way to see this: if the binary representation of a number i has a 1 in the 2
k
position, then i
appears on the 2
k
-card.
Number in upper
left corner = 1
1
17
33
49
3
19
35
51
5
21
37
53
7
23
39
55
8
24
40
56
9
25
41
57
10
26
42
58
11
27
43
59
Number in upper
left corner = 8