Skip to content

Commit

Permalink
all-your-base: Be decisive about zeroes (#1001)
Browse files Browse the repository at this point in the history
all-your-base 1.2.0

In #280 we made
the explicit choice to leave various cases `expected: null` where tracks
can make their own decisions (leading zeroes, the representations of
zero, whether empty sequence is acceptable as input).

There are four affected cases.

#473 results in
a discussion that some post-processing is necessary, based on the
decisions that a given track makes. One might even imagine that each
individual generator may have to reimplement base translation to arrive
at the proper answers for each case.

To ease the process of translation, instead we make some canonical
choices, explicitly show what the choices are, and offer that tracks may
make a different choice if desired.

A previous proposal did not receive support:
#468

However, this proposal differs because it does change the comments at
the top of the file.

Closes #1002 by mutual exclusion
  • Loading branch information
petertseng authored Nov 11, 2017
1 parent 9bf041b commit b3a735c
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions exercises/all-your-base/canonical-data.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
{
"exercise": "all-your-base",
"version": "1.1.0",
"version": "1.2.0",
"comments": [
"It's up to each track do decide:",
"",
"1. What's the canonical representation of zero?",
" - []?",
" - [0]?",
"",
"2. What representations of zero are allowed?",
" - []?",
" - [0]?",
" - [0,0]?",
"This canonical data makes the following choices:",
"1. Zero is always represented in outputs as [0] instead of [].",
"2. In no other instances are leading zeroes present in any outputs.",
"3. Leading zeroes are accepted in inputs.",
"4. An empty sequence of input digits is considered zero, rather than an error.",
"",
"3. Are leading zeroes allowed?",
"Tracks that wish to make different decisions for these choices may translate appropriately.",
"",
"4. How should invalid input be handled?",
"It's up to each track do decide:",
"How should invalid input be handled?",
"",
"All the undefined cases are marked as null.",
"",
Expand Down Expand Up @@ -92,31 +88,31 @@
"input_base": 2,
"input_digits": [],
"output_base": 10,
"expected": null
"expected": [0]
},
{
"description": "single zero",
"property": "rebase",
"input_base": 10,
"input_digits": [0],
"output_base": 2,
"expected": null
"expected": [0]
},
{
"description": "multiple zeros",
"property": "rebase",
"input_base": 10,
"input_digits": [0, 0, 0],
"output_base": 2,
"expected": null
"expected": [0]
},
{
"description": "leading zeros",
"property": "rebase",
"input_base": 7,
"input_digits": [0, 6, 0],
"output_base": 10,
"expected": null
"expected": [4, 2]
},
{
"description": "first base is one",
Expand Down

0 comments on commit b3a735c

Please sign in to comment.