Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions solutions/go/resistor-color/1/resistor_color.go
Original file line number Diff line number Diff line change
@@ -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
}