Skip to content
Merged
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
338 changes: 192 additions & 146 deletions exercises/all-your-base/canonical-data.json
Original file line number Diff line number Diff line change
@@ -1,148 +1,194 @@
{
"#": [ "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]?"
, ""
, "3. Are leading zeroes allowed?"
, ""
, "4. How should invalid input be handled?"
, ""
, "All the undefined cases are marked as null."
, ""
, "All your numeric-base are belong to [2..]. :)"
],
"cases": [
{ "description" : "single bit one to decimal"
, "input_base" : 2
, "input_digits" : [1]
, "output_base" : 10
, "expected" : [1]
},
{ "description" : "binary to single decimal"
, "input_base" : 2
, "input_digits" : [1, 0, 1]
, "output_base" : 10
, "expected" : [5]
},
{ "description" : "single decimal to binary"
, "input_base" : 10
, "input_digits" : [5]
, "output_base" : 2
, "expected" : [1, 0, 1]
},
{ "description" : "binary to multiple decimal"
, "input_base" : 2
, "input_digits" : [1, 0, 1, 0, 1, 0]
, "output_base" : 10
, "expected" : [4, 2]
},
{ "description" : "decimal to binary"
, "input_base" : 10
, "input_digits" : [4, 2]
, "output_base" : 2
, "expected" : [1, 0, 1, 0, 1, 0]
},
{ "description" : "trinary to hexadecimal"
, "input_base" : 3
, "input_digits" : [1, 1, 2, 0]
, "output_base" : 16
, "expected" : [2, 10]
},
{ "description" : "hexadecimal to trinary"
, "input_base" : 16
, "input_digits" : [2, 10]
, "output_base" : 3
, "expected" : [1, 1, 2, 0]
},
{ "description" : "15-bit integer"
, "input_base" : 97
, "input_digits" : [3,46,60]
, "output_base" : 73
, "expected" : [6,10,45]
},
{ "description" : "empty list"
, "input_base" : 2
, "input_digits" : []
, "output_base" : 10
, "expected" : null
},
{ "description" : "single zero"
, "input_base" : 10
, "input_digits" : [0]
, "output_base" : 2
, "expected" : null
},
{ "description" : "multiple zeros"
, "input_base" : 10
, "input_digits" : [0, 0, 0]
, "output_base" : 2
, "expected" : null
},
{ "description" : "leading zeros"
, "input_base" : 7
, "input_digits" : [0, 6, 0]
, "output_base" : 10
, "expected" : null
},
{ "description" : "negative digit"
, "input_base" : 2
, "input_digits" : [1, -1, 1, 0, 1, 0]
, "output_base" : 10
, "expected" : null
},
{ "description" : "invalid positive digit"
, "input_base" : 2
, "input_digits" : [1, 2, 1, 0, 1, 0]
, "output_base" : 10
, "expected" : null
},
{ "description" : "first base is one"
, "input_base" : 1
, "input_digits" : []
, "output_base" : 10
, "expected" : null
},
{ "description" : "second base is one"
, "input_base" : 2
, "input_digits" : [1, 0, 1, 0, 1, 0]
, "output_base" : 1
, "expected" : null
},
{ "description" : "first base is zero"
, "input_base" : 0
, "input_digits" : []
, "output_base" : 10
, "expected" : null
},
{ "description" : "second base is zero"
, "input_base" : 10
, "input_digits" : [7]
, "output_base" : 0
, "expected" : null
},
{ "description" : "first base is negative"
, "input_base" : -2
, "input_digits" : [1]
, "output_base" : 10
, "expected" : null
},
{ "description" : "second base is negative"
, "input_base" : 2
, "input_digits" : [1]
, "output_base" : -7
, "expected" : null
},
{ "description" : "both bases are negative"
, "input_base" : -2
, "input_digits" : [1]
, "output_base" : -7
, "expected" : null
} ]
"exercise": "all-your-base",
"version": "1.0.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]?",
"",
"3. Are leading zeroes allowed?",
"",
"4. How should invalid input be handled?",
"",
"All the undefined cases are marked as null.",
"",
"All your numeric-base are belong to [2..]. :)"
],
"cases": [
{
"description": "single bit one to decimal",
"property": "rebase",
"input_base": 2,
"input_digits": [1],
"output_base": 10,
"expected": [1]
},
{
"description": "binary to single decimal",
"property": "rebase",
"input_base": 2,
"input_digits": [1, 0, 1],
"output_base": 10,
"expected": [5]
},
{
"description": "single decimal to binary",
"property": "rebase",
"input_base": 10,
"input_digits": [5],
"output_base": 2,
"expected": [1, 0, 1]
},
{
"description": "binary to multiple decimal",
"property": "rebase",
"input_base": 2,
"input_digits": [1, 0, 1, 0, 1, 0],
"output_base": 10,
"expected": [4, 2]
},
{
"description": "decimal to binary",
"property": "rebase",
"input_base": 10,
"input_digits": [4, 2],
"output_base": 2,
"expected": [1, 0, 1, 0, 1, 0]
},
{
"description": "trinary to hexadecimal",
"property": "rebase",
"input_base": 3,
"input_digits": [1, 1, 2, 0],
"output_base": 16,
"expected": [2, 10]
},
{
"description": "hexadecimal to trinary",
"property": "rebase",
"input_base": 16,
"input_digits": [2, 10],
"output_base": 3,
"expected": [1, 1, 2, 0]
},
{
"description": "15-bit integer",
"property": "rebase",
"input_base": 97,
"input_digits": [3, 46, 60],
"output_base": 73,
"expected": [6, 10, 45]
},
{
"description": "empty list",
"property": "rebase",
"input_base": 2,
"input_digits": [],
"output_base": 10,
"expected": null
},
{
"description": "single zero",
"property": "rebase",
"input_base": 10,
"input_digits": [0],
"output_base": 2,
"expected": null
},
{
"description": "multiple zeros",
"property": "rebase",
"input_base": 10,
"input_digits": [0, 0, 0],
"output_base": 2,
"expected": null
},
{
"description": "leading zeros",
"property": "rebase",
"input_base": 7,
"input_digits": [0, 6, 0],
"output_base": 10,
"expected": null
},
{
"description": "negative digit",
"property": "rebase",
"input_base": 2,
"input_digits": [1, -1, 1, 0, 1, 0],
"output_base": 10,
"expected": null
},
{
"description": "invalid positive digit",
"property": "rebase",
"input_base": 2,
"input_digits": [1, 2, 1, 0, 1, 0],
"output_base": 10,
"expected": null
},
{
"description": "first base is one",
"property": "rebase",
"input_base": 1,
"input_digits": [],
"output_base": 10,
"expected": null
},
{
"description": "second base is one",
"property": "rebase",
"input_base": 2,
"input_digits": [1, 0, 1, 0, 1, 0],
"output_base": 1,
"expected": null
},
{
"description": "first base is zero",
"property": "rebase",
"input_base": 0,
"input_digits": [],
"output_base": 10,
"expected": null
},
{
"description": "second base is zero",
"property": "rebase",
"input_base": 10,
"input_digits": [7],
"output_base": 0,
"expected": null
},
{
"description": "first base is negative",
"property": "rebase",
"input_base": -2,
"input_digits": [1],
"output_base": 10,
"expected": null
},
{
"description": "second base is negative",
"property": "rebase",
"input_base": 2,
"input_digits": [1],
"output_base": -7,
"expected": null
},
{
"description": "both bases are negative",
"property": "rebase",
"input_base": -2,
"input_digits": [1],
"output_base": -7,
"expected": null
}
]
}