From 31bdbc65e110c2c27e95df83d8b8656a5c5380a0 Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Mon, 6 Mar 2017 11:35:49 -0500 Subject: [PATCH 1/2] book-store: Make canonical-data.json compliant --- exercises/book-store/canonical-data.json | 184 ++++++++++++----------- 1 file changed, 97 insertions(+), 87 deletions(-) diff --git a/exercises/book-store/canonical-data.json b/exercises/book-store/canonical-data.json index 586ac0d5c0..b3c7ac5d97 100644 --- a/exercises/book-store/canonical-data.json +++ b/exercises/book-store/canonical-data.json @@ -1,93 +1,103 @@ { - "book-store": { - "description": [ + "exercise": "book-store", + "version": "1.0.0", + "comments": [ "Calculate lowest price for a shopping basket containing ", "books only from a single series. There is no ", "discount advantage for having more than one copy of ", "any single book in a grouping." ], - "total": { - "description": "returns the total basket price after applying best discount", - "cases": [ - { - "description": "Only a single book", - "basket": [1], - "targetgrouping": [[1]], - "expected": 8.00 - }, - { - "description": "Two of the same book", - "basket": [2,2], - "targetgrouping": [[2],[2]], - "expected": 16.00 - }, - { - "description": "Empty basket", - "basket": [], - "targetgrouping": [], - "expected": 0.00 - }, - { - "description": "Two different books", - "basket": [1,2], - "targetgrouping": [[1,2]], - "expected": 15.20 - }, - { - "description": "Three different books", - "basket": [1,2,3], - "targetgrouping": [[1,2,3]], - "expected": 21.60 - }, - { - "description": "Four different books", - "basket": [1,2,3,4], - "targetgrouping": [[1,2,3,4]], - "expected": 25.60 - }, - { - "description": "Five different books", - "basket": [1,2,3,4,5], - "targetgrouping": [[1,2,3,4,5]], - "expected": 30.00 - }, - { - "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], - "targetgrouping": [[1,2,3,4,5],[1,2,3,4]], - "expected": 55.60 - }, - { - "description": "Two copies of each book", - "basket": [1,1,2,2,3,3,4,4,5,5], - "targetgrouping": [[1,2,3,4,5],[1,2,3,4,5]], - "expected": 60.00 - }, - { - "description": "Three copies of first book and 2 each of remaining", - "basket": [1,1,2,2,3,3,4,4,5,5,1], - "targetgrouping": [[1,2,3,4,5],[1,2,3,4,5],[1]], - "expected": 68.00 - }, - { - "description": "Three each of first 2 books and 2 each of remaining books", - "basket": [1,1,2,2,3,3,4,4,5,5,1,2], - "targetgrouping": [[1,2,3,4,5],[1,2,3,4,5],[1,2]], - "expected": 75.20 - } - ] - } - } -} + "cases": [ + { + "property": "total", + "description": "Only a single book", + "basket": [1], + "targetgrouping": [[1]], + "expected": 8.00 + }, + { + "property": "total", + "description": "Two of the same book", + "basket": [2,2], + "targetgrouping": [[2],[2]], + "expected": 16.00 + }, + { + "property": "total", + "description": "Empty basket", + "basket": [], + "targetgrouping": [], + "expected": 0.00 + }, + { + "property": "total", + "description": "Two different books", + "basket": [1,2], + "targetgrouping": [[1,2]], + "expected": 15.20 + }, + { + "property": "total", + "description": "Three different books", + "basket": [1,2,3], + "targetgrouping": [[1,2,3]], + "expected": 21.60 + }, + { + "property": "total", + "description": "Four different books", + "basket": [1,2,3,4], + "targetgrouping": [[1,2,3,4]], + "expected": 25.60 + }, + { + "property": "total", + "description": "Five different books", + "basket": [1,2,3,4,5], + "targetgrouping": [[1,2,3,4,5]], + "expected": 30.00 + }, + { + "property": "total", + "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 + }, + { + "property": "total", + "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 + }, + { + "property": "total", + "description": "Two each of first 4 books and 1 copy each of rest", + "basket": [1,1,2,2,3,3,4,4,5], + "targetgrouping": [[1,2,3,4,5],[1,2,3,4]], + "expected": 55.60 + }, + { + "property": "total", + "description": "Two copies of each book", + "basket": [1,1,2,2,3,3,4,4,5,5], + "targetgrouping": [[1,2,3,4,5],[1,2,3,4,5]], + "expected": 60.00 + }, + { + "property": "total", + "description": "Three copies of first book and 2 each of remaining", + "basket": [1,1,2,2,3,3,4,4,5,5,1], + "targetgrouping": [[1,2,3,4,5],[1,2,3,4,5],[1]], + "expected": 68.00 + }, + { + "property": "total", + "description": "Three each of first 2 books and 2 each of remaining books", + "basket": [1,1,2,2,3,3,4,4,5,5,1,2], + "targetgrouping": [[1,2,3,4,5],[1,2,3,4,5],[1,2]], + "expected": 75.20 + } + ] +} \ No newline at end of file From 346f862ca59e5ae5af11468def8942df79c99768 Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Mon, 6 Mar 2017 13:05:00 -0500 Subject: [PATCH 2/2] book-store: Fix canonical-data.json formatting --- exercises/book-store/canonical-data.json | 202 ++++++++++++----------- 1 file changed, 103 insertions(+), 99 deletions(-) diff --git a/exercises/book-store/canonical-data.json b/exercises/book-store/canonical-data.json index b3c7ac5d97..128ed2a118 100644 --- a/exercises/book-store/canonical-data.json +++ b/exercises/book-store/canonical-data.json @@ -1,103 +1,107 @@ { "exercise": "book-store", "version": "1.0.0", - "comments": [ - "Calculate lowest price for a shopping basket containing ", - "books only from a single series. There is no ", - "discount advantage for having more than one copy of ", - "any single book in a grouping." - ], - "cases": [ - { - "property": "total", - "description": "Only a single book", - "basket": [1], - "targetgrouping": [[1]], - "expected": 8.00 - }, - { - "property": "total", - "description": "Two of the same book", - "basket": [2,2], - "targetgrouping": [[2],[2]], - "expected": 16.00 - }, - { - "property": "total", - "description": "Empty basket", - "basket": [], - "targetgrouping": [], - "expected": 0.00 - }, - { - "property": "total", - "description": "Two different books", - "basket": [1,2], - "targetgrouping": [[1,2]], - "expected": 15.20 - }, - { - "property": "total", - "description": "Three different books", - "basket": [1,2,3], - "targetgrouping": [[1,2,3]], - "expected": 21.60 - }, - { - "property": "total", - "description": "Four different books", - "basket": [1,2,3,4], - "targetgrouping": [[1,2,3,4]], - "expected": 25.60 - }, - { - "property": "total", - "description": "Five different books", - "basket": [1,2,3,4,5], - "targetgrouping": [[1,2,3,4,5]], - "expected": 30.00 - }, - { - "property": "total", - "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 - }, - { - "property": "total", - "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 - }, - { - "property": "total", - "description": "Two each of first 4 books and 1 copy each of rest", - "basket": [1,1,2,2,3,3,4,4,5], - "targetgrouping": [[1,2,3,4,5],[1,2,3,4]], - "expected": 55.60 - }, - { - "property": "total", - "description": "Two copies of each book", - "basket": [1,1,2,2,3,3,4,4,5,5], - "targetgrouping": [[1,2,3,4,5],[1,2,3,4,5]], - "expected": 60.00 - }, - { - "property": "total", - "description": "Three copies of first book and 2 each of remaining", - "basket": [1,1,2,2,3,3,4,4,5,5,1], - "targetgrouping": [[1,2,3,4,5],[1,2,3,4,5],[1]], - "expected": 68.00 - }, - { - "property": "total", - "description": "Three each of first 2 books and 2 each of remaining books", - "basket": [1,1,2,2,3,3,4,4,5,5,1,2], - "targetgrouping": [[1,2,3,4,5],[1,2,3,4,5],[1,2]], - "expected": 75.20 - } - ] + "cases": [ + { + "description": "Return the total basket price after applying the best discount.", + "comments": [ + "Calculate lowest price for a shopping basket containing books only from ", + "a single series. There is no discount advantage for having more than ", + "one copy of any single book in a grouping." + ], + "cases": [ + { + "property": "total", + "description": "Only a single book", + "basket": [1], + "targetgrouping": [[1]], + "expected": 8.00 + }, + { + "property": "total", + "description": "Two of the same book", + "basket": [2,2], + "targetgrouping": [[2],[2]], + "expected": 16.00 + }, + { + "property": "total", + "description": "Empty basket", + "basket": [], + "targetgrouping": [], + "expected": 0.00 + }, + { + "property": "total", + "description": "Two different books", + "basket": [1,2], + "targetgrouping": [[1,2]], + "expected": 15.20 + }, + { + "property": "total", + "description": "Three different books", + "basket": [1,2,3], + "targetgrouping": [[1,2,3]], + "expected": 21.60 + }, + { + "property": "total", + "description": "Four different books", + "basket": [1,2,3,4], + "targetgrouping": [[1,2,3,4]], + "expected": 25.60 + }, + { + "property": "total", + "description": "Five different books", + "basket": [1,2,3,4,5], + "targetgrouping": [[1,2,3,4,5]], + "expected": 30.00 + }, + { + "property": "total", + "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 + }, + { + "property": "total", + "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 + }, + { + "property": "total", + "description": "Two each of first 4 books and 1 copy each of rest", + "basket": [1,1,2,2,3,3,4,4,5], + "targetgrouping": [[1,2,3,4,5],[1,2,3,4]], + "expected": 55.60 + }, + { + "property": "total", + "description": "Two copies of each book", + "basket": [1,1,2,2,3,3,4,4,5,5], + "targetgrouping": [[1,2,3,4,5],[1,2,3,4,5]], + "expected": 60.00 + }, + { + "property": "total", + "description": "Three copies of first book and 2 each of remaining", + "basket": [1,1,2,2,3,3,4,4,5,5,1], + "targetgrouping": [[1,2,3,4,5],[1,2,3,4,5],[1]], + "expected": 68.00 + }, + { + "property": "total", + "description": "Three each of first 2 books and 2 each of remaining books", + "basket": [1,1,2,2,3,3,4,4,5,5,1,2], + "targetgrouping": [[1,2,3,4,5],[1,2,3,4,5],[1,2]], + "expected": 75.20 + } + ] + } + ] } \ No newline at end of file