My issue
I’m getting a runtime error with no details, I can’t find the bug.
Link: CodeChef: Practical coding for everyone
My code
def f(idx, i, j):
if idx >= len(s):
return 0
ans = float("inf")
for c in ["R", "G", "B"]:
if c != i and c != j:
v = f(idx + 1, j, c)
v += 0 if c == s[idx] else 1
ans = min(ans, v)
return ans
for _ in range(int(input())):
n = int(input())
s = input()
ans = f(0, -1, -1)
print(ans)
Problem Link: White Wall Practice Coding Problem