-
-
Notifications
You must be signed in to change notification settings - Fork 546
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
New Exercise book-store #465
Conversation
Create harry-potter
Create description.md
Oh, this exercise looks interesting. As the README makes clear, a few choices for the optimisation. I am interested to see how it will go. It would be nice if we can have the test cases in a file in this repo too, as https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md#improving-consistency-by-extracting-shared-test-data has it. In this case, the task should only require using the same tests as those in exercism/delphi#14 |
@petertseng thanks for the tip. The json file seems pretty straight forward. |
@@ -0,0 +1,57 @@ | |||
This exercise is based on the exercise of the same name found at cyber-dojo.org |
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.
This information is provided in the source section of the metadata and does not need to be repeated here.
I'd like to see this exercise called something more generic like 'book-discounts'. The books being Harry Potter books is irrelevant to the problem. |
|
||
If you buy 4 different books, you get a 20% discount. | ||
|
||
If you go the whole hog, and buy all 5, you get a huge 25% |
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.
There are 7 books in the Harry Potter series.
Could apply to Game of Thrones, a 5 book series I think.....
Trying to make this more generic.....
was harry-potter is now book-store
Note that if you buy, say, four books, of which 3 are different titles, you get a 10% discount on the 3 that | ||
form part of a set, but the fourth book still costs 8 EUR. | ||
|
||
Your mission is to write a piece of code to calculate the price of any conceivable shopping basket (containing only books from the same series), giving as big a discount as possible. |
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.
This is a bit confusing, it sounds like it wants me to calculate every possible price/combination. But further down it seems to indicate it just wants a method that given a list of books will calculate the cheapest total price for those books.
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.
I see your point, however I don't really see a better way to word this. At this point its is just copy/pasted from cyber-dojo. I suppose, as it is, it adds to the challenge of the problem. I know when I originally worked this problem I ended up disregarding this piece, but I think it is needed initially to help the reader understand the requirements.
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.
if were were to change it, I would suggest just changing "any conceivable" to "a given", which should make it clear that the basket is the input.
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.
At this point its is just copy/pasted from cyber-dojo.
What is the licensing on that text? We may need to rewrite the text (or at least heavily edit it), even though we're referring to cyber-dojo as the source.
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.
@kytrinyx I've been scouring the cyber-dojo site and I haven't found anything at this point that makes the statement one way or the other that the exercise is protected. In general the only licensing that I see is regarding the comercial use of the site as a whole. Some of the other exercises there site other sites as sources for complete instructions. Some of the exercises have NO instructions and only reference the source site.
Should we ask for permission to use the text?
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.
I've been scouring the cyber-dojo site and I haven't found anything at this point that makes the statement one way or the other that the exercise is protected.
Anything that doesn't have a public license is copyrighted by default, and we can't use it.
The cyber-dojo website is released under a couple of variants of the BSD license. Does it cite another source for the book sale exercise?
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.
@kytrinyx I am still looking. Here is a link to a license, looks like boiler plate. https://github.com/cyber-dojo/start-points-exercises/blob/master/LICENSE.md
I am still looking around. I don't know if this license really grants permission for use of exercises or just relating to the site as a whole.
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.
That license does grant use of the exercise, but only under the same license, which we don't have. The exercises here are under an MIT license.
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.
Thanks for taking on board the suggestions, this is looking much better.
@Insti thanks, I'm trying. It's the first "original" exercise that I have added to exercism. Had I only known.... Kidding, wouldn't be doing this if I didn't want to learn too. |
Attempt at producing a canonical-data.json file book-store exercise.
I think I have completed what needs to be done. Let me know where I've errored and I'll take care of it. |
It thinks your json is invalid. |
}, | ||
{ | ||
"description": "basket 112233445512", | ||
"basket": "112233445512", |
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.
It would be nice if the basket was an array rather than a string.
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.
String type comes with the added benefit of TStringHelper which makes parsing the basket a little easier. For the sake of my example solution I could possibly convert the input to an array, I would just convert it to a string with in the class.
Also added a description for the exercise and added exercise name.
}, | ||
{ | ||
"description": "TestBasketContainsMyBooks", | ||
"mybasket": "3" |
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.
missing comma here
Read this comment I wrote on another PR, about test descriptions: #451 (comment) |
Having a good |
I will add this back via a seperate PR.
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.
I know you are planning to add canonical-data.json back later, though I'll still leave some notes for it, to prepare for the time when it gets added back.
@@ -0,0 +1,76 @@ | |||
{ | |||
"#": [ | |||
"Not sure what to type here, come back to this later." |
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.
if there is nothing in particular to add (any notes for anyone who wishes to port this exercise to a track), the entire thing can be deleted.
], | ||
"cases": [ | ||
{ | ||
"description": "TestSingleBookPrice", |
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.
what is the difference between this and "TestTotalBasketPriceSingleBook"?
If the only function under test in this exercise is "Given this basket, what is its price?" then it seems there is no need to have this one.
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.
In retrospect this probably isn't needed. I have a property that just returns the price of a single book. The test is just confirming that it equals 8.
"expected": 8.0 | ||
}, | ||
{ | ||
"description": "TestBasketContainsMyBooks", |
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.
What does this case do?
If the only function under test in this exercise is "Given this basket, what is its price?" then it seems there is no need to have this one.
This statement also seems true for this case.
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.
May be too simple of a test. It is simply echoing back the contents of its basket. It should equal what was placed in the basket.
@petertseng I've gone ahead and moved the canonical-data.json to another PR. I am not really clear on how the inner workings of the machine (exercism.io) operate so don't have a solid grasp on what the exact role the three files play (canonical-data.json, description.md, and metadata.yml). At this point I am trying to format the files as best I can to examples from other exercises. In the case of the json file I am not sure what tests should be listed and which shouldn't. I've assumed that they should all be listed. I guess further discussion related to the json file should take place here #470 . |
I think all the files for the exercise should go into the same PR, (and in a single commit) since they all belong to one, atomic change. |
That is the way I had it but was encouraged to pull the canonical data out into a separate PR.
Sent from my android device.
|
@kytrinyx I asked @rpottsoh to move the canonical data to another PR. Reasoning: By getting the exercise in place it gives multiple tracks an opportunity to implement the problem and help find/explore the required test cases, and find/resolve any issues with the description. Before getting to a place where track implementers can just assume that the canonical-data is complete and everything is ready to go. |
I think things are OK. A few minor things but I am not sure if they are blocking. |
|
||
For example, how much does this basket of books cost? | ||
|
||
2 copies of the first book |
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.
Note that at https://github.com/rpottsoh/x-common/blob/rpottsoh-patch-1/exercises/book-store/description.md the lines get mashed together. Bullet points?
Or do we expect people to always be reading the raw md file in a text editor rather than rendering? (I always read raw, but I don't know about others)
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.
The MD file gets rendered on the website at e.g. http://exercism.io/exercises/ruby/hello-world/readme
So it seems important to get the formatting to look good rendered too, not just in plain text.
1 copy of the fifth book | ||
|
||
One way of group these 8 books is: | ||
1 group of 5 --> 25% discount (1st,2nd,3rd,4th,5th) |
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.
These also get mashed together. Not sure of the best way to deal with it - use backticks?
@Insti fair enough. I saw the other PR first, and it didn't have a [WIP] to indicate that it would have to be merged after a different PR, so I was unaware of the fact that there was a different PR in progress until I got further down my notifications list. |
Good question. I will look again with this in mind as well as check other sources that might have the same/similar exercise.
Sent from my android device.
|
I see. So is the exercise dead?
Sent from my android device.
|
Made minor grammatical updates. The description is no longer an exact copy of the description found at cyber-dojo.
|
||
Resulting in: | ||
|
||
- 5 x (8 2.00) == 5 x 6.00 == $30.00 |
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.
missing minus signs, the (8 2.00)
doesn't look right
Resulting in: | ||
|
||
- 5 x (8 2.00) == 5 x 6.00 == $30.00 | ||
- +3 x (8 0.80) == 3 x 7.20 == $21.60 |
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.
also missing minus sign, should be (8 - 0.80)
right?
- 4 books at a 20% discount | ||
- +4 books at a 20% discount | ||
|
||
Resulting: |
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.
should this be "Resulting in" instead of just "Resulting"?
@PeterSeng suggestions.
I do not think there are other changes that I would suggest. I am not competent to discuss copyright, so I make no comment on that. Before I forget to mention it: Before merging this PR, please squash commits. |
In terms of copyright, as long as we don't exactly copy their text word for word, and link to them as a source, I think it is fine. |
Text was changed a little. Looks like C# and F# have already implemented the exercise. 👍 |
@rpottsoh thanks to @ErikSchierboom we now have two people that have submitted implementations on the site for the this exercise in both C# and F# 👍 |
And that's thanks to @robkeim who implemented the problem! |
@ErikSchierboom I noticed! Thanks to you and @robkeim for taking the time to get it out there. |
Attempting to create slug for new xpascal exercise.