diff --git a/solutions/go/resistor-color/1/resistor_color.go b/solutions/go/resistor-color/1/resistor_color.go new file mode 100644 index 0000000..1c32985 --- /dev/null +++ b/solutions/go/resistor-color/1/resistor_color.go @@ -0,0 +1,28 @@ +package resistorcolor + +// Colors returns the list of all colors. +var Size = 10 +func Colors() []string { + return []string{ + "black", + "brown", + "red", + "orange", + "yellow", + "green", + "blue", + "violet", + "grey", + "white", + } +} + +// ColorCode returns the resistance value of the given color. +func ColorCode(color string) int { + for i := 0; i < Size; i++ { + if Colors()[i] == color { + return i + } + } + return -1 +}