Resistor color code by Icewing

m@main=getLine>>=putStrLn.tail.(>>=('-':)).f>>m
g 'k'=3
g 'M'=6
g _=0
z a=a>'.'&&a<'M'
a?x|last a==2=init a++[x]|0<1=a++[x-1]
f x=map(words"Silver Gold Black Brown Red Orange Yellow Green Blue Violet Grey White"!!)$take 3[l['/'..y]|y<-x++"00",z y]?(g(last x)+(l$takeWhile z x))
l=length

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

download

return to the top page