Skip to content

Commit

Permalink
book store: Explain importance of greediness vs non-greediness (#550)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
petertseng authored and ErikSchierboom committed Feb 13, 2017
1 parent 932c674 commit 4c617d5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion exercises/book-store/canonical-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,17 @@
"expected": 30.00
},
{
"description": "Two each of first 3 books and 1 copy each of rest",
"description": "Two groups of four is cheaper than group of five plus group of three",
"basket": [1,1,2,2,3,3,4,5],
"targetgrouping": [[1,2,3,4],[1,2,3,5]],
"expected": 51.20
},
{
"description": "Group of four plus group of two is cheaper than two groups of three",
"basket": [1,1,2,2,3,4],
"targetgrouping": [[1,2,3,4],[1,2]],
"expected": 40.8
},
{
"description": "Two each of first 4 books and 1 copy each of rest",
"basket": [1,1,2,2,3,3,4,4,5],
Expand Down

0 comments on commit 4c617d5

Please sign in to comment.