-
-
Notifications
You must be signed in to change notification settings - Fork 544
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
book-store: Add test that requires use of both groups of 4 and groups of 5 #1620
base: main
Are you sure you want to change the base?
Conversation
"description": "Two groups of four and a group of five", | ||
"comments": ["Suggested grouping, [[1,2,3,4],[1,2,3,5],[1,2,3,4,5]]. Solutions can pass all the other tests if they just try to group without using any groups of 5. This test case breaks that since it requires both 4-groups and 5-groups."], | ||
"input": { | ||
"basket": [1,1,1,2,2,2,3,3,3,4,4,5,5] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in my comment here, I would suggest shuffling the input numbers here (or adding an additional case that has the inputs shuffled), as this ensures a more robust solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I've added a second test to check for that.
Yeah that's brilliant idea to add test book store that gives in shuffled order |
I agree with adding this, but I've tended to consider an omitted test (as opposed to an included test that was manifestly wrong) as blocked by #1560 ... should this one also get a Hold label for the moment? Not that I want to add to the backlog. |
@sswingle Are you still interested in working on this PR? |
Many of the "brute force" solutions I see do something like run a greedy solver multiple times with different maximum group sizes. This allows them to solve test cases that check for finding 2 groups of 4 instead of a group of 5 and a group of 3.
However, this wouldn't solve cases where you need to use both groups of 5 and groups of 4. For example, consider books = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3]. The cheapest price possible is achieved by splitting it into 1 group of 5 and 2 groups of 4, with cost = 800*(150.75 + 240.8) = 8120. Solutions like those described above will typically split it into 2 groups of 5 and 1 group of 3, with a cost of 800*(250.75 + 130.9) = 8160.
For further motivation and discussion see: exercism/python#2141