Skip to content

resistor-color: add new exercise #1457

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

Merged
merged 1 commit into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
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
41 changes: 41 additions & 0 deletions exercises/resistor-color/canonical-data.json
Original file line number Diff line number Diff line change
@@ -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"]
}
]
}
18 changes: 18 additions & 0 deletions exercises/resistor-color/description.md
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions exercises/resistor-color/metadata.yml
Original file line number Diff line number Diff line change
@@ -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"