diff --git a/exercises/resistor-color/canonical-data.json b/exercises/resistor-color/canonical-data.json new file mode 100644 index 0000000000..1a64c58288 --- /dev/null +++ b/exercises/resistor-color/canonical-data.json @@ -0,0 +1,41 @@ +{ + "exercise": "resistor-color", + "version": "1.0.0", + "cases": [ + { + "description": "Color codes", + "cases": [ + { + "description": "Black", + "property": "colorCode", + "input": { + "color": "black" + }, + "expected": 0 + }, + { + "description": "White", + "property": "colorCode", + "input": { + "color": "white" + }, + "expected": 9 + }, + { + "description": "Orange", + "property": "colorCode", + "input": { + "color": "orange" + }, + "expected": 3 + } + ] + }, + { + "description": "Colors", + "property": "colors", + "input": {}, + "expected": ["black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"] + } + ] +} diff --git a/exercises/resistor-color/description.md b/exercises/resistor-color/description.md new file mode 100644 index 0000000000..226f0f2e63 --- /dev/null +++ b/exercises/resistor-color/description.md @@ -0,0 +1,18 @@ +Resistors have color coded bands, where each color maps to a number. The first 2 bands of a resistor have a simple encoding scheme: each color maps to a single number. + +These colors are encoded as follows: + +- Black: 0 +- Brown: 1 +- Red: 2 +- Orange: 3 +- Yellow: 4 +- Green: 5 +- Blue: 6 +- Violet: 7 +- Grey: 8 +- White: 9 + +Mnemonics map the colors to the numbers, that, when stored as an array, happen to map to their index in the array: Better Be Right Or Your Great Big Values Go Wrong. + +More information on the color encoding of resistors can be found in the [Electronic color code Wikipedia article](https://en.wikipedia.org/wiki/Electronic_color_code) diff --git a/exercises/resistor-color/metadata.yml b/exercises/resistor-color/metadata.yml new file mode 100644 index 0000000000..4b02507aba --- /dev/null +++ b/exercises/resistor-color/metadata.yml @@ -0,0 +1,4 @@ +--- +blurb: "Convert a resistor band's color to its numeric representation" +source: "Maud de Vries, Erik Schierboom" +source_url: "https://github.com/exercism/problem-specifications/issues/1458"