Untitled

mail@pastecode.io avatar
unknown
golang
a year ago
577 B
4
Indexable
Never
func countPoints(rings string) int {
    sticks := [10]int{0,0,0,0,0,0,0,0,0,0}
    result := 0
    for i := 0; i < len(rings); i += 2 {
        if sticks[rings[i + 1] - '0'] == 0b111{
            continue
        }
        switch rings[i]{
            case 'R':
                sticks[rings[i + 1] - '0'] |= 0b001
            case 'G':
                sticks[rings[i + 1] - '0'] |= 0b010
            case 'B':
                sticks[rings[i + 1] - '0'] |= 0b100
        }
        if sticks[rings[i + 1] - '0'] == 0b111{
            result++
        }
    }
    return result
}