add PascalsTriangle generator#459
Conversation
…dhear to generation
| dataCases.ExceptionThrown = typeof(ArgumentOutOfRangeException); | ||
| if (dataCases.Properties["count"] == null) | ||
| dataCases.Properties["count"] = -1; | ||
| } |
There was a problem hiding this comment.
Should we be converting this to a -1? It should be entirely possible to pass in null (int?), or pass in nothing with a default param.
There was a problem hiding this comment.
@jpreese Well, I think the canonical data is at fault here. In what way would passing null make sense for calculating pascal's triangle? I've created an issue to discuss removing this strange case. In the mean time, I'm in favor of manually removing this error case from the canonical data to make sure we don't output it.
There was a problem hiding this comment.
@jpreese @bmeverett I've created a PR to fix the canonical data.
There was a problem hiding this comment.
Yeah, I'd agree. I know there was a PR over in the problem-specs repo about wanting to test edge cases (e.g. null). I'm not sure if this is a result of that or where that got left off.
| } | ||
|
|
||
| private static IEnumerable<IEnumerable<int>> ItterateRows(int rows) | ||
| { |
There was a problem hiding this comment.
ItterateRows should be IterateRows
| protected override void UpdateCanonicalData(CanonicalData canonicalData) | ||
| { | ||
| foreach (var dataCases in canonicalData.Cases) | ||
| { |
There was a problem hiding this comment.
I would change dataCases to dataCase (most use canonicalDataCase). Since the variable is a single case.
|
Just some small nits @bmeverett, looks good though! |
| dataCases.ExceptionThrown = typeof(ArgumentOutOfRangeException); | ||
| if (dataCases.Properties["count"] == null) | ||
| dataCases.Properties["count"] = -1; | ||
| } |
There was a problem hiding this comment.
@jpreese Well, I think the canonical data is at fault here. In what way would passing null make sense for calculating pascal's triangle? I've created an issue to discuss removing this strange case. In the mean time, I'm in favor of manually removing this error case from the canonical data to make sure we don't output it.
ErikSchierboom
left a comment
There was a problem hiding this comment.
I've found one last issue, and once that is fixed I'll merge :)
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| private static IEnumerable<int> Row(int row) |
There was a problem hiding this comment.
Could you remove this function? The stub implementation only needs the public methods to allow it to compile.
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| private static IEnumerable<IEnumerable<int>> IterateRows(int rows) |
There was a problem hiding this comment.
Could you remove this function? The stub implementation only needs the public methods to allow it to compile.
|
Merged. Thanks a lot! 🎉 |
Adds the PascalsTriangle generator. Pretty straight forward, except for the exception cases. I modified the Example to get around the yield return so the exception would be thrown. And the final test case, where the value is null, I converted that back to -1 because you can't run a test with the incorrect number of parameters as the solution doesn't build.
Closes #418