Problem p02954 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)
char = list(input())
char_list_num = len(char)
count_list = [0] * char_list_num

def f(first_char,n,add_num):
    if first_char == char[n+add_num] and n + add_num != char_list_num - 1:
        return f(first_char,n+add_num,add_num)
    else:
        return n+add_num

num = 0
while not num == char_list_num - 1:
    reach_loop_num = f(char[num],num,1)
    diff = reach_loop_num - num
    if reach_loop_num == char_list_num - 1:
        if char[num] == char[reach_loop_num]:
            diff += 1
        else:
            count_list[reach_loop_num] += 1
    if char[num] == 'R':
        if diff % 2 == 0:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2)
        else:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2) +1
    else:
        if diff % 2 == 0:
            count_list[num] += int(diff/2)
            count_list[num-1] += int(diff/2)
        else:
            count_list[num] += int(diff/2) +1
            count_list[num-1] += int(diff/2)
    num = reach_loop_num
print(' '.join(map(str,count_list)))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
char = list(input())
char_list_num = len(char)
count_list = [0] * char_list_num

def f(first_char,n,add_num):
    if first_char == char[n+add_num] and n + add_num != char_list_num - 1:
        return f(first_char,n+add_num,add_num)
    else:
        return n+add_num

num = 0
while not num == char_list_num - 1:
    reach_loop_num = f(char[num],num,1)
    diff = reach_loop_num - num
    if reach_loop_num == char_list_num - 1:
        diff += 1
    if char[num] == 'R':
        if diff % 2 == 0:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2)
        else:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2) +1
    else:
        if diff % 2 == 0:
            count_list[num] += int(diff/2)
            count_list[num-1] += int(diff/2)
        else:
            count_list[num] += int(diff/2) +1
            count_list[num-1] += int(diff/2)
    num = reach_loop_num
print(' '.join(map(str,count_list)))

Buggy submission (verdict: Runtime Error):
char = list(input())
char_list_num = len(char)
count_list = [0] * char_list_num

def f(first_char,n,add_num):
    if first_char == char[n+add_num] and n + add_num != char_list_num - 1:
        return f(first_char,n+add_num,add_num)
    else:
        return n+add_num

num = 0
while not num == char_list_num - 1:
    reach_loop_num = f(char[num],num,1)
    diff = reach_loop_num - num
    if reach_loop_num == char_list_num - 1:
        diff += 1
    if char[num] == 'R':
        if diff % 2 == 0:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2)
        else:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2) +1
    else:
        if diff % 2 == 0:
            count_list[num] += int(diff/2)
            count_list[num-1] += int(diff/2)
        else:
            count_list[num] += int(diff/2) +1
            count_list[num-1] += int(diff/2)
    num = reach_loop_num
print(' '.join(map(str,count_list)))

Buggy submission (verdict: Runtime Error):
char = list(input())
char_list_num = len(char)
count_list = [0] * char_list_num

def f(first_char,n,add_num):
    if first_char == char[n+add_num] and n + add_num != char_list_num - 1:
        return f(first_char,n+add_num,add_num)
    else:
        return n+add_num

num = 0
while not num == char_list_num - 1:
    reach_loop_num = f(char[num],num,1)
    diff = reach_loop_num - num
    if char[num] == 'R':
        if diff % 2 == 0:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2)
        else:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2) +1
    else:
        if diff % 2 == 0:
            count_list[num] += int(diff/2)
            count_list[num-1] += int(diff/2)
        else:
            count_list[num] += int(diff/2)
            count_list[num-1] += int(diff/2) +1
    num = reach_loop_num
print(' '.join(map(str,count_list)))

Buggy submission (verdict: Runtime Error):
char_list = list(input())
char_list_num = len(char_list)
count_list = [0] * char_list_num

def f(first_char,n):
    if first_char == char_list[n+1]:
        return f(first_char,n+1)
    else:
        return n+1

def f2(first_char,n):
    if first_char == char_list[n-1]:
        return f2(first_char,n-1)
    else:
        return n-1

for i in range(char_list_num):
    if char_list[i] == 'R':
        reach_loop_num = f(char_list[i],i)
        decided_num = reach_loop_num - i
        if decided_num % 2 == 0:
            count_list[reach_loop_num] += 1
        else:
            count_list[reach_loop_num-1] += 1
    else:
        reach_loop_num = f2(char_list[i],i)
        decided_num =  i - reach_loop_num
        if decided_num % 2 == 0:
            count_list[reach_loop_num] += 1
        else:
            count_list[reach_loop_num+1] += 1
print(' '.join(map(str,count_list)))

Buggy submission (verdict: Runtime Error):
char_list = list(input())
print(char_list)
char_list_num = len(char_list)
count_list = [0] * char_list_num

def f(first_char,n):
    if first_char == char_list[n+1]:
        return f(first_char,n+1)
    else:
        return n+1

def f2(first_char,n):
    if first_char == char_list[n-1]:
        return f2(first_char,n-1)
    else:
        return n-1

for i in range(char_list_num):
    if char_list[i] == 'R':
        reach_loop_num = f(char_list[i],i)
        decided_num = reach_loop_num - i
        if decided_num % 2 == 0:
            count_list[reach_loop_num-1] += 1
        else:
            count_list[reach_loop_num] += 1
    else:
        reach_loop_num = f2(char_list[i],i)
        decided_num = reach_loop_num - i
        if decided_num % 2 == 0:
            count_list[reach_loop_num+1] += 1
        else:
            count_list[reach_loop_num] += 1
print(' '.join(map(str,count_list)))