Babbling Brooks is an example of a problem that is good for functions. There could be two functions, one of them seperates and the other joins.
There could be a simple part that isn’t in a function, but most of the work and ligic is into the functions.
Sample solution in python 3:
streams = [int(input()) for i in range(int(input()))]
def split(splitnum, percent, lis): # splitnum is the position of the split num. lis is the list of streams.
num = lis[splitnum-1]
splitnum -= 1
percent /= 100
lis.insert(splitnum, num*percent)
splitnum += 1
lis[splitnum] = (1-percent)*num
return lis
def join(leftjoinnum, lis):
rightjoinnum = lis[leftjoinnum]
leftjoinnum -= 1
lis.remove(rightjoinnum)
lis[leftjoinnum] += rightjoinnum
return lis
inputCommand = int(input())
while inputCommand > 77:
if inputCommand == 99:
splitnumber = int(input())
streams = split(splitnumber, int(input()), streams)
else:
streams = join(int(input()), streams)
inputCommand = int(input())
for i in streams:
print(int(i), end=' ')