2025-08-17 10:34:11 +0000 UTC
Rings and Rods
Categories:
Links
Code
class Solution:
def countPoints(self, rings: str) -> int:
rods = [(False, False, False)] * 10
res = 0
for i in range(0, len(rings), 2):
rod = int(rings[i + 1])
color = rings[i]
has_red, has_green, has_blue = rods[rod]
if color == "R":
has_red = True
elif color == "G":
has_green = True
else:
has_blue = True
rods[rod] = (has_red, has_green, has_blue)
for vals in rods:
if all(vals):
res += 1
return res