Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More specific answer #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

More specific answer #5

wants to merge 1 commit into from

Conversation

Zesky665
Copy link

@Zesky665 Zesky665 commented Aug 1, 2016

The given answer failed to account for qty values above 20. In the case of the "banana" item, it returned an freeQty value of 6. In the exercise description it states "Purchases of 5 or more receive 1 free. Purchases of 10 or more receive 3 free". The original code added +3 for each 10 instead of +3 if qty is >= 10. Great course otherwise :) .

The given answer failed to account for qty values above 20. In the case of the "banana" item, it returned an freeQty value of 6.  In the exercise description it states "Purchases of 5 or more receive 1 free.  Purchases of 10 or more receive 3 free". The original code added +3 for each 10 instead of +3 if qty is >= 10.  Great course otherwise :) .
@anshumanf
Copy link

anshumanf commented Aug 11, 2016

In your diff, you should retain a generic free function that takes three parameters.

@WickyNilliams
Copy link

Like this, right?

free minQty freeQty item =
    if item.freeQty == 0 && item.qty >= minQty then
        { item | freeQty = freeQty }
    else
        item

I just noticed this issue, and came here to make a PR for the same reason :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants