Skip to content

Commit cb7eab5

Browse files
authored
Resistor Color Trio: extend tests, borrowing from awk (#2162)
* Resistor Color Trio: extend tests, borrowing from awk * [resistor-color-trio] Update description to mention more unit prefixes * Drop "ambiguous" values * Drop reference to larger prefixes
1 parent b4bc494 commit cb7eab5

File tree

2 files changed

+65
-3
lines changed

2 files changed

+65
-3
lines changed

exercises/resistor-color-trio/canonical-data.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,66 @@
6060
"value": 470,
6161
"unit": "kiloohms"
6262
}
63+
},
64+
{
65+
"uuid": "5f6404a7-5bb3-4283-877d-3d39bcc33854",
66+
"description": "Blue and violet and blue",
67+
"property": "label",
68+
"input": {
69+
"colors": ["blue", "violet", "blue"]
70+
},
71+
"expected": {
72+
"value": 67,
73+
"unit": "megaohms"
74+
}
75+
},
76+
{
77+
"uuid": "7d3a6ab8-e40e-46c3-98b1-91639fff2344",
78+
"description": "Minimum possible value",
79+
"property": "label",
80+
"input": {
81+
"colors": ["black", "black", "black"]
82+
},
83+
"expected": {
84+
"value": 0,
85+
"unit": "ohms"
86+
}
87+
},
88+
{
89+
"uuid": "ca0aa0ac-3825-42de-9f07-dac68cc580fd",
90+
"description": "Maximum possible value",
91+
"property": "label",
92+
"input": {
93+
"colors": ["white", "white", "white"]
94+
},
95+
"expected": {
96+
"value": 99,
97+
"unit": "gigaohms"
98+
}
99+
},
100+
{
101+
"uuid": "0061a76c-903a-4714-8ce2-f26ce23b0e09",
102+
"description": "First two colors make an invalid octal number",
103+
"property": "label",
104+
"input": {
105+
"colors": ["black", "grey", "black"]
106+
},
107+
"expected": {
108+
"value": 8,
109+
"unit": "ohms"
110+
}
111+
},
112+
{
113+
"uuid": "30872c92-f567-4b69-a105-8455611c10c4",
114+
"description": "Ignore extra colors",
115+
"property": "label",
116+
"input": {
117+
"colors": ["blue", "green", "yellow", "orange"]
118+
},
119+
"expected": {
120+
"value": 650,
121+
"unit": "kiloohms"
122+
}
63123
}
64124
]
65125
}

exercises/resistor-color-trio/description.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ So an input of `"orange", "orange", "black"` should return:
4646

4747
> "33 ohms"
4848
49-
When we get more than a thousand ohms, we say "kiloohms".
50-
That's similar to saying "kilometer" for 1000 meters, and "kilograms" for 1000 grams.
49+
When we get to larger resistors, a [metric prefix][metric-prefix] is used to indicate a larger magnitude of ohms, such as "kiloohms".
50+
That is similar to saying "2 kilometers" instead of "2000 meters", or "2 kilograms" for "2000 grams".
5151

52-
So an input of `"orange", "orange", "orange"` should return:
52+
For example, an input of `"orange", "orange", "orange"` should return:
5353

5454
> "33 kiloohms"
55+
56+
[metric-prefix]: https://en.wikipedia.org/wiki/Metric_prefix

0 commit comments

Comments
 (0)