top | item 28353085

(no title)

ajennings | 4 years ago

Here's how I did it by hand (assuming you can buy multiple of a given item):

Work in cents, modulo 87 (the cost of the cheapest item, the pinwheel).

The total we want is 4394 (or 44 mod 87). Write down the price of every item modulo 87.

The whistle is 98 (or 11 mod 87) so you can buy 4 whistles and make up the rest in pinwheels (46).

The dog is 457 (or 22 mod 87) so you can buy 2 dogs and make up the rest in pinwheels (40).

Lots of other combinations.

However, the paper doesn't seem to suggest that buying multiple is okay.

I'm glad others mentioned the dynamic programming solution. That one feels elegant. Should've thought of that.

discuss

order

No comments yet.