Skip to content

Commit e1c6d44

Browse files
resistor-colors: add new exercise (#1466)
* resistor-colors: add new exercise Co-Authored-By: ErikSchierboom <[email protected]>
1 parent 18875ec commit e1c6d44

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"exercise": "resistor-colors",
3+
"version": "1.0.0",
4+
"cases": [
5+
{
6+
"description": "Brown and black",
7+
"property": "value",
8+
"input": {
9+
"colors": ["brown", "black"]
10+
},
11+
"expected": 10
12+
},
13+
{
14+
"description": "Blue and grey",
15+
"property": "value",
16+
"input": {
17+
"colors": ["blue", "grey"]
18+
},
19+
"expected": 68
20+
},
21+
{
22+
"description": "Yellow and violet",
23+
"property": "value",
24+
"input": {
25+
"colors": ["yellow", "violet"]
26+
},
27+
"expected": 47
28+
},
29+
{
30+
"description": "Orange and orange",
31+
"property": "value",
32+
"input": {
33+
"colors": ["orange", "orange"]
34+
},
35+
"expected": 33
36+
}
37+
]
38+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
If you want to build something using a Raspberry Pi, you'll probably use _resistors_. For this exercise, you need to know two things about them:
2+
3+
* Each resistor has a resistance value.
4+
* Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read.
5+
To get around this problem, manufacturers print color-coded bands onto the resistors to denote their resistance values. Each band acts as a digit of a number. For example, if they printed a brown band (value 1) followed by a green band (value 5), it would translate to the number 15.
6+
7+
In this exercise, you are going to create a helpful program so that you don't have to remember the values of the bands. The program will take two colors as input, and output the correct number.
8+
9+
The band colors are encoded as follows:
10+
11+
- Black: 0
12+
- Brown: 1
13+
- Red: 2
14+
- Orange: 3
15+
- Yellow: 4
16+
- Green: 5
17+
- Blue: 6
18+
- Violet: 7
19+
- Grey: 8
20+
- White: 9
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
blurb: "Convert color codes, as used on resistors, to a numeric value."
3+
source: "Maud de Vries, Erik Schierboom"
4+
source_url: "https://github.com/exercism/problem-specifications/issues/1464"

0 commit comments

Comments
 (0)