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

all-your-base: Show all the choices that tracks could make #1002

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 51 additions & 11 deletions exercises/all-your-base/canonical-data.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
{
"exercise": "all-your-base",
"version": "1.1.0",
"version": "2.0.0",
"comments": [
"It's up to each track do decide:",
"",
"1. What's the canonical representation of zero?",
" - []?",
" - [0]?",
" - []? (if your track does this iff the input was empty, then follow if_your_track_translates_empty_to_empty)",
" - [0]? (if your track does this, then follow if_your_track_outputs_zero_as_a_single_zero)",
"",
"2. What representations of zero are allowed?",
" - []?",
" - [0]?",
" - [0,0]?",
" - []? (if your track allows this, then follow if_your_track_allows_empty_input_digits)",
" - [0]? (if your track allows this, then follow if_your_track_allows_single_zero_as_input)",
" - [0,0]? (if your track allows this, then follow if_your_track_allows_leading_zeroes_in_input)",
"",
"3. Are leading zeroes allowed?",
"If so then follow if_your_track_allows_leading_zeroes_in_input",
"",
"4. How should invalid input be handled?",
"",
"All the undefined cases are marked as null.",
"All the undefined cases have objects under the `expected` key",
"showing the different possible choices one can take.",
"",
"todo: one could imagine an explanation of the choices object",
"",
"All your numeric-base are belong to [2..]. :)"
],
Expand Down Expand Up @@ -92,31 +96,67 @@
"input_base": 2,
"input_digits": [],
"output_base": 10,
"expected": null
"expected": {
"choices": {
"if_your_track_allows_empty_input_digits": {
"choices": {
"if_your_track_translates_empty_to_empty": [],
"if_your_track_outputs_zero_as_a_single_zero": [0],
"otherwise": []
}
},
"otherwise": {"error": "input digits cannot be empty"}
}
}
},
{
"description": "single zero",
"property": "rebase",
"input_base": 10,
"input_digits": [0],
"output_base": 2,
"expected": null
"expected": {
"choices": {
"if_your_track_allows_single_zero_as_input": {
"choices": {
"if_your_track_outputs_zero_as_a_single_zero": [0],
"otherwise": []
}
},
"otherwise": {"error": "leading zeroes not allowed"}
}
}
},
{
"description": "multiple zeros",
"property": "rebase",
"input_base": 10,
"input_digits": [0, 0, 0],
"output_base": 2,
"expected": null
"expected": {
"choices": {
"if_your_track_allows_leading_zeroes_in_input": {
"choices": {
Copy link
Member Author

Choose a reason for hiding this comment

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

bug: For tracks that allow leading zeroes in nonzero inputs BUT expect their zeroes to nonetheless be [], this should be an error, but currently isn't. Oh no, how could I make such a grievous error on such an important PR

"if_your_track_outputs_zero_as_a_single_zero": [0],
"otherwise": []
}
},
"otherwise": {"error": "leading zeroes not allowed"}
}
}
},
{
"description": "leading zeros",
"property": "rebase",
"input_base": 7,
"input_digits": [0, 6, 0],
"output_base": 10,
"expected": null
"expected": {
"choices": {
"if_your_track_allows_leading_zeroes_in_input": [4, 2],
"otherwise": {"error": "leading zeroes not allowed"}
}
}
},
{
"description": "first base is one",
Expand Down