-
-
Notifications
You must be signed in to change notification settings - Fork 354
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
Test Error in Exercise "Book Store" #181
Comments
@cmccandless are you talking about this readme? If so, the Readme calls out two different groupings for the eights books, and you need to choose the cheaper one. If you're getting 51.60 it's probably because you're using a greedy algorithm and the greedy algorithm doesn't always work in this problem :) |
Copying the relevant part of the readme for your convenience:
|
Ah, that's what I get for trying to code before coffee; I misunderstood that part of the readme. My mistake. |
* book-store: Explain importance of 4+4 vs 5+3 case You cannot greedily add books to a single group in this case. You have to try the possibilities and see that two groups of four is a cheaper grouping than a group of five and a group of three. If this is not made clear, people may make assumptions that greedy is the correct way to go, as in: exercism/csharp#181 * book-store: Contrast 4+4 < 5+3 case with a 4+2 < 3+3 case In the former, you MUST NOT be greedy. In the latter, you MUST be greedy.
The test "Basket_with_eight_books" tests for a sum value of "51.20", when the correct sum should be "51.60".
E.G: books=[1,1,2,2,3,3,4,5]
groups=[count(1,2,3,4,5),count(1,2,3)]=[5,3]
discount[5]=.75
discount[3]=.9
groups8=[40,24]
groups8discount=[40.75,24*.9]=[30,21.6]
total=30+21.6=51.60
This particular example also happens to be contained in the Readme for the exercise, but the arithmetic was done correctly there.
The text was updated successfully, but these errors were encountered: