|
| 1 | +# Instructions |
| 2 | + |
| 3 | +If you want to build something using a Raspberry Pi, you'll probably use _resistors_. |
| 4 | +For this exercise, you need to know only three things about them: |
| 5 | + |
| 6 | +- Each resistor has a resistance value. |
| 7 | +- Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read. |
| 8 | + To get around this problem, manufacturers print color-coded bands onto the resistors to denote their resistance values. |
| 9 | +- Each band acts as a digit of a number. |
| 10 | + For example, if they printed a brown band (value 1) followed by a green band (value 5), it would translate to the number 15. |
| 11 | + In this exercise, you are going to create a helpful program so that you don't have to remember the values of the bands. |
| 12 | + The program will take 3 colors as input, and outputs the correct value, in ohms. |
| 13 | + The color bands are encoded as follows: |
| 14 | + |
| 15 | +- Black: 0 |
| 16 | +- Brown: 1 |
| 17 | +- Red: 2 |
| 18 | +- Orange: 3 |
| 19 | +- Yellow: 4 |
| 20 | +- Green: 5 |
| 21 | +- Blue: 6 |
| 22 | +- Violet: 7 |
| 23 | +- Grey: 8 |
| 24 | +- White: 9 |
| 25 | + |
| 26 | +In Resistor Color Duo you decoded the first two colors. |
| 27 | +For instance: orange-orange got the main value `33`. |
| 28 | +The third color stands for how many zeros need to be added to the main value. |
| 29 | +The main value plus the zeros gives us a value in ohms. |
| 30 | +For the exercise it doesn't matter what ohms really are. |
| 31 | +For example: |
| 32 | + |
| 33 | +- orange-orange-black would be 33 and no zeros, which becomes 33 ohms. |
| 34 | +- orange-orange-red would be 33 and 2 zeros, which becomes 3300 ohms. |
| 35 | +- orange-orange-orange would be 33 and 3 zeros, which becomes 33000 ohms. |
| 36 | + |
| 37 | +(If Math is your thing, you may want to think of the zeros as exponents of 10. |
| 38 | +If Math is not your thing, go with the zeros. |
| 39 | +It really is the same thing, just in plain English instead of Math lingo.) |
| 40 | + |
| 41 | +This exercise is about translating the colors into a label: |
| 42 | + |
| 43 | +> "... ohms" |
| 44 | +
|
| 45 | +So an input of `"orange", "orange", "black"` should return: |
| 46 | + |
| 47 | +> "33 ohms" |
| 48 | +
|
| 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". |
| 51 | + |
| 52 | +For example, an input of `"orange", "orange", "orange"` should return: |
| 53 | + |
| 54 | +> "33 kiloohms" |
| 55 | +
|
| 56 | +[metric-prefix]: https://en.wikipedia.org/wiki/Metric_prefix |
0 commit comments