'''
solve dutch balls
'''

def dutch_balls(arr):
    end = len(arr)
    r = 0
    g = 0
    b = len(arr) - 1
    while g <= b:
        if arr[g] == 'R':
            arr[g],arr[r] = arr[r],arr[g]
            g = g + 1
            r = r + 1
        elif arr[g] == 'G':
            g = g + 1
        else:
            arr[g], arr[b] = arr[b], arr[g]
            b = b - 1
    return arr

arr1 = ['B','R','G']
r1 = dutch_balls(arr1)
print(r1)

32ec6b396889195ca570140a39cfd21a169a5df9
<mask token>

<mask token>


def dutch_balls(arr):
    end = len(arr)
    r = 0
    g = 0
    b = len(arr) - 1
    while g <= b:
        if arr[g] == 'R':
            arr[g], arr[r] = arr[r], arr[g]
            g = g + 1
            r = r + 1
        elif arr[g] == 'G':
            g = g + 1
        else:
            arr[g], arr[b] = arr[b], arr[g]
            b = b - 1
    return arr


<mask token>

<mask token>


def dutch_balls(arr):
    end = len(arr)
    r = 0
    g = 0
    b = len(arr) - 1
    while g <= b:
        if arr[g] == 'R':
            arr[g], arr[r] = arr[r], arr[g]
            g = g + 1
            r = r + 1
        elif arr[g] == 'G':
            g = g + 1
        else:
            arr[g], arr[b] = arr[b], arr[g]
            b = b - 1
    return arr


<mask token>
print(r1)

<mask token>


def dutch_balls(arr):
    end = len(arr)
    r = 0
    g = 0
    b = len(arr) - 1
    while g <= b:
        if arr[g] == 'R':
            arr[g], arr[r] = arr[r], arr[g]
            g = g + 1
            r = r + 1
        elif arr[g] == 'G':
            g = g + 1
        else:
            arr[g], arr[b] = arr[b], arr[g]
            b = b - 1
    return arr


arr1 = ['B', 'R', 'G']
r1 = dutch_balls(arr1)
print(r1)

'''
solve dutch balls
'''

def dutch_balls(arr):
    end = len(arr)
    r = 0
    g = 0
    b = len(arr) - 1
    while g <= b:
        if arr[g] == 'R':
            arr[g],arr[r] = arr[r],arr[g]
            g = g + 1
            r = r + 1
        elif arr[g] == 'G':
            g = g + 1
        else:
            arr[g], arr[b] = arr[b], arr[g]
            b = b - 1
    return arr

arr1 = ['B','R','G']
r1 = dutch_balls(arr1)
print(r1)
