Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = input().split(' ')
- command = input()
- while not command == '3:1':
- details = command.split(' ')
- if details[0] == 'merge':
- start_index = int(details[1])
- end_index = int(details[2])
- if start_index < 0:
- start_index = 0
- if end_index > (len(data) - 1):
- end_index = len(data) - 1
- merged_string = "".join(data[start_index:(end_index + 1)])
- data[start_index:end_index + 1] = [merged_string]
- elif details[0] == 'divide':
- divide = int(details[1])
- parts = int(details[2])
- element = data[divide]
- result = len(element) // parts
- new_data = []
- while len(element) > 0:
- new_data.append(element[:result])
- removed = element.replace(element[:result], "")
- element = removed
- while len(new_data) > parts:
- poped = new_data.pop(-1)
- new_data[-1] += poped
- new_data = ' '.join(new_data)
- data[divide] = new_data
- command = input()
- print(*data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement