Online Course Discussion Forum
Week 1 Homework
Hi Alex,
Let me give both an example of weights and a hint for this problem.
As an example, suppose you have the weights of $5$, $8$, and $13$ grams. Using one of these weights you can get $5$, $8$, or $13$ grams, with two weights you can get $13$, $18$, or $21$ grams, and using all three gives $26$ grams. Thus, in total you can get$$5, 8, 13, 18, 21, \text{ or } 26$$grams. (Note $13$ we can get two ways for later.)
As a hint for the actual problem, try to work your way up. Clearly you need to get $1$ gram, so you need a $1$ gram weight. How can we $2$ grams? Well either we add another $1$ gram weight or a $2$ gram weight. To avoid duplicates, suppose you add a $2$ gram weight. Now we can get $1$, $2$, or $1+2 = 3$ grams, so $4$ grams is the smallest weight we cannot get so far. What if we then add a $4$ gram weight?
Try to continue from here and see if you can find a pattern.
Hope this helps!
Social networks