Skip to content

Added Largest Series Product Generator #474

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

Conversation

felix91gr
Copy link
Contributor

@felix91gr felix91gr commented Oct 11, 2017

  • Changed name of Property to GetLargestProduct, to fit with example and stub implementation
  • Fixed issues in example implementation, that didn't handle the newest tests' requirements. In particular, erroneous input crashed the example, while the testing suite expected it to return -1. Now the example behaves properly.
  • Updated eol to canonical (unintended, but the generator created it).

Created Generator for DifferenceOfSquares (exercism#471)
@felix91gr felix91gr changed the title Adding largest series prod generator pure Adding Largest Series Product Generator Oct 11, 2017
@felix91gr felix91gr changed the title Adding Largest Series Product Generator Added Largest Series Product Generator Oct 11, 2017
Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

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

Some small changes requested.

@@ -22,6 +36,7 @@ private static long ParseDigit(char c)
{
if (!char.IsDigit(c))
{
Console.WriteLine("Invalid digit: " + c);
Copy link
Member

Choose a reason for hiding this comment

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

Could you remove this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reverted all of my changes to Example.cs :)

[Fact(Skip = "Remove to run test")]
public void Rejects_empty_string_and_nonzero_span()
{
Assert.Equal(-1, LargestSeriesProduct.GetLargestProduct("", 1));
Copy link
Member

Choose a reason for hiding this comment

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

The -1 is an error case, and should throw an exception. Same goes for the other -1 cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, if I'm understanding this, a -1 in the canonical-data.json represents an exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes. Indeed it does:

negative numbers in canonical data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the Assert.Throws!

protected override void UpdateCanonicalData(CanonicalData canonicalData)
{
foreach (var canonicalDataCase in canonicalData.Cases)
canonicalDataCase.Property = "GetLargestProduct";
Copy link
Member

Choose a reason for hiding this comment

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

Maybe CalculateLargestSeriesProduct would be a better name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. Maybe?

I interpret GetLargestProduct as I wanna get the largest product in this series, which fits the exercise description. Basically the same as saying CalculateLargestSeriesProduct, but more precise. I would leave it, but regardless, both convey the correct meaning.

Copy link
Member

Choose a reason for hiding this comment

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

Well argued. I agree

- Changed name of Property to GetLargestProduct, to fit with example and stub implementation
- Added Assert.Throws for scenarios where `canonical-data.json` expected a failure (described as `-1`)
- Updated eol to canonical (unintended, but the generator created it).
@felix91gr felix91gr force-pushed the adding-largest-series-prod-generator-pure branch from e43e539 to ca8fd8d Compare October 12, 2017 19:35
@felix91gr
Copy link
Contributor Author

I think I've fixed all of the issues. Thanks for the feedback!

@ErikSchierboom ErikSchierboom merged commit fe40c6f into exercism:master Oct 12, 2017
@ErikSchierboom
Copy link
Member

Thanks!

@felix91gr felix91gr deleted the adding-largest-series-prod-generator-pure branch October 12, 2017 22:51
@felix91gr
Copy link
Contributor Author

⛵ :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants