Resistor color code by mitchs (jpl)

#!ruby -n
d=scan /[1-9]/
d[1]||=0
puts (d<<~/\D|$/-d.size+(/k/?3:/M/?6:0)).map{|z|%w(Black Brown Red Orange Yellow Green Blue Violet Grey White Silver Gold)[z.to_i]}*'-'

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page