# This is a sample Python script. from functools import reduce # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. def main(): # Use a breakpoint in the code line below to debug your script. sentence = input() a = find_splits_for_sentence(sentence) arr2 = [] start = 0 print(len(a)//2 + len(a) % 2) # for sequence in a: # arr2.append(sentence[start * 2:sequence * 2]) # start = sequence # arr2.append(sentence[start * 2:]) # for i in range(len(arr2)): # swap(i, arr2.copy()) def swap(pair, arr): arr[pair] = reverse(arr[pair]) seq = reduce(lambda x,y: x+y, arr) new_splits = find_splits_for_sentence(seq) pass def reverse(str): new_str = "" for i in range(len(str) - 1, -1, -1): new_str += str[i] return new_str def find_splits_for_sentence(sentence): a = [] end = 0 previous = "" for ind in range(0, len(sentence), 2): if ind > 0: end += 1 if (sentence[ind], sentence[ind + 1]) != previous: a.append(end) previous = (sentence[ind], sentence[ind + 1]) return a # Press the green button in the gutter to run the script. if __name__ == '__main__': main() # See PyCharm help at https://www.jetbrains.com/help/pycharm/