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

Series exercise requires strange edge case handling #1047

Open
mgw93 opened this issue Feb 26, 2022 · 1 comment
Open

Series exercise requires strange edge case handling #1047

mgw93 opened this issue Feb 26, 2022 · 1 comment

Comments

@mgw93
Copy link

mgw93 commented Feb 26, 2022

The test cases for the Series exercises require that
series 0 [] = [[]]
series _ [] = []

This seems counterintuitive and is not documented in the problem description.
Is there a reason why the test cases were chosen like this?

@petertseng
Copy link
Member

For series n xs, you would expect that length (series n xs) == min 0 (length xs - n + 1)

If n == 0 and length xs == 0, then length (series n xs) should be 0 - 0 + 1 == 1. This tells us that there is one way to make a series of length 0 from the empty series: the empty series.

If n == 1 and length xs == 0, then length (series n xs) should be 0 - 1 + 1 == 0. This tells us that the empty series contains no series of length 1.

If n == 2 and length xs == 0, then length (series n xs) should be 0 because 0 - 2 + 1 < 0. This too tells us that the empty series contains no series of length 2.

I'm not sure I feel particularly great about the test cases with n == 0 though. They could all be removed, but then someone would just suggest we add them again.

It's probably better to pick exactly one of these two options:

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

No branches or pull requests

2 participants