Colorful resistors

Useful to know: dictionaries.

Let's use dictionaries (you don't have to of course) to look at resistors, which are common electric components found in virtually every electronic circuit. Resistors come with a resistance rating $\Omega$ (measured in Ohms) that describes how difficult it is to pass an electric current through the resistor. This resistance rating is indicated by four or five colored bands on the resistor itself (see table).


Resistor color table with example calculations for a four-band and a five-band resistor. (Image credit: Resistors and Color Codes, Digi-Key)

For a four band resistor, the first two color bands indicate the first two digits of the resistance value with the third band indicating a multiplier, and the last band indicates a tolerance. For a five band resistor, the first three color bands indicate the first three digits of the resistance value followed by a fourth band (multiplier) and a fifth band (tolerance). A resistor with a single black band has zero resistance.

Using a list of colors as input compute the nominal resistance (i.e. whithout any tolerance), as well as the minimum and maximum resistance value of the resistor, and return them in that order.


Input: A list of colors (could be of length 1, 4, or 5).


Output: The nominal, minimum, and maximum resistance of the resistor (in that order).


Example input

["green", "blue", "yellow", "gold"]
["red", "orange", "violet", "black", "brown"]

Example output

(560000, 532000, 588000)
(237, 234.63, 239.37)

You must be logged in to submit code but you can play around with the editor.


You must be logged in to upload code.

  • Should we include some non-standard ones?