elm icon indicating copy to clipboard operation
elm copied to clipboard

Unprecise description and solution for exercise 01 in chapter 03

Open mrvary opened this issue 6 years ago • 0 comments

There are some minor flaws in that excercise. Basically the solution provided does not match the logic that is suggested.

The exercise descriptions wants you to

[...] set the freeQty of each record using the following logic: Purchases of 5 or more receive 1 free. Purchases of 10 or more receive 3 free.

As I understand this, there are three cases here:

  1. with < 5 purchases you get 0 free items
  2. with at least 5 and < 10 purchases you get 1 free item
  3. with at least 10 and any more than that you get 3 free items

When I looked into the solution the logic behind it seems different, though. The implementation lets you get 3 free items for every 10 and 1 free item for every 5 purchases. The only issue is that if you already got any extra items for having a multiple of 10 purchases, you'll be missing out on another free item in case you have at least 5 more purchases remaining (because the free function checks freeQty == 0).

I'd love to fix it (would be my first PR 🎉 ), but what would be the prefered solution? I think the second way of solving this is a bit more difficult, how about splitting the first exercise into two?

mrvary avatar Jun 20 '18 14:06 mrvary