Skip to content
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

Merged
merged 20 commits into from
Dec 14, 2016
Merged

New Exercise book-store #465

merged 20 commits into from
Dec 14, 2016

Conversation

rpottsoh
Copy link
Member

@rpottsoh rpottsoh commented Dec 6, 2016

Attempting to create slug for new xpascal exercise.

@petertseng
Copy link
Member

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

@rpottsoh
Copy link
Member Author

rpottsoh commented Dec 6, 2016

@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
Copy link
Contributor

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.

@Insti
Copy link
Contributor

Insti commented Dec 6, 2016

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%
Copy link
Contributor

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.

rpottsoh and others added 3 commits December 8, 2016 10:55
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
@rpottsoh rpottsoh changed the title New Exercise harry-potter New Exercise book-store Dec 8, 2016
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.
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Contributor

@Insti Insti left a 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.

@rpottsoh
Copy link
Member Author

rpottsoh commented Dec 8, 2016

@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.
@rpottsoh
Copy link
Member Author

rpottsoh commented Dec 8, 2016

I think I have completed what needs to be done. Let me know where I've errored and I'll take care of it.

@Insti
Copy link
Contributor

Insti commented Dec 8, 2016

It thinks your json is invalid.

},
{
"description": "basket 112233445512",
"basket": "112233445512",
Copy link
Contributor

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.

Copy link
Member Author

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing comma here

@Insti
Copy link
Contributor

Insti commented Dec 8, 2016

Read this comment I wrote on another PR, about test descriptions: #451 (comment)

@Insti
Copy link
Contributor

Insti commented Dec 8, 2016

Having a good canonical-data.json file can be harder than writing the original specification.
It might be good to split this off into a separate PR so we can get the initial exercise merged in and once a few tracks have implemented it we can work out what the canonical test data should be.

I will add this back via a seperate PR.
Copy link
Member

@petertseng petertseng left a 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."
Copy link
Member

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",
Copy link
Member

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.

Copy link
Member Author

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",
Copy link
Member

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.

Copy link
Member Author

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.

@rpottsoh
Copy link
Member Author

rpottsoh commented Dec 8, 2016

@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 .

@kytrinyx
Copy link
Member

kytrinyx commented Dec 8, 2016

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.

@rpottsoh
Copy link
Member Author

rpottsoh commented Dec 8, 2016 via email

@Insti
Copy link
Contributor

Insti commented Dec 9, 2016

@kytrinyx I asked @rpottsoh to move the canonical data to another PR.

Reasoning:
There are many pre-existing exercises that do not have canonoical-data files.
The description.md and metadata.yml files for this exercise were almost complete and ready to be merged.

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.

@petertseng
Copy link
Member

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
Copy link
Member

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)

Copy link
Member

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)
Copy link
Member

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?

@kytrinyx
Copy link
Member

I asked @rpottsoh to move the canonical data to another PR.

@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.

@rpottsoh
Copy link
Member Author

rpottsoh commented Dec 12, 2016 via email

@rpottsoh
Copy link
Member Author

rpottsoh commented Dec 12, 2016 via email

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
Copy link
Member

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
Copy link
Member

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:
Copy link
Member

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"?

@petertseng
Copy link
Member

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.

@rpottsoh rpottsoh self-assigned this Dec 14, 2016
@rpottsoh rpottsoh merged commit 371e55e into exercism:master Dec 14, 2016
@rpottsoh rpottsoh deleted the rpottsoh-patch-1 branch December 14, 2016 19:56
@kytrinyx
Copy link
Member

kytrinyx commented Jan 2, 2017

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.

@rpottsoh
Copy link
Member Author

rpottsoh commented Jan 3, 2017

Text was changed a little. Looks like C# and F# have already implemented the exercise. 👍

@robkeim
Copy link
Contributor

robkeim commented Jan 3, 2017

@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# 👍

@ErikSchierboom
Copy link
Member

And that's thanks to @robkeim who implemented the problem!

@rpottsoh
Copy link
Member Author

rpottsoh commented Jan 3, 2017

@ErikSchierboom I noticed! Thanks to you and @robkeim for taking the time to get it out there.

emcoding pushed a commit that referenced this pull request Nov 19, 2018
Replace hard-coded Bowling tests with test generator (#456)
Also updated the example solution to address new test case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants