From b9fdd52b3d7fc9d6fe3fddc7b395f25dae26da60 Mon Sep 17 00:00:00 2001 From: tommi27 Date: Thu, 16 May 2019 17:19:31 +0200 Subject: [PATCH] started repeater problem --- repeater.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 repeater.py diff --git a/repeater.py b/repeater.py new file mode 100644 index 0000000..5e4b69f --- /dev/null +++ b/repeater.py @@ -0,0 +1,39 @@ +def __main__(): + T = int(input()) + for i in range(1, T + 1): + N = int(input()) + A = [None] * N + + for j in range(0, N): + A[j] = input() + + print("Case #" + str(i) + ": " + str(repeater(A))) + +def repeater(arr): + + count_arr = [0] * len(arr) + + c = 0 + while ???: + s = 0 + tmpChar = arr[0][count_arr[0]] + for i in range(0, len(arr)): + string = arr[i] + + while string[count_arr[i] + 1] == tmpChar: + count_arr[i] += 1 + s += 1 + else: + return "Fegla Won" + + sorted = sort(count_arr) + if len(sorted) % 2 == 1: + k = len(sorted) - 1 / 2 + for count in count_arr: + c += abs(count - sorted[k]) + else: + v = 0 + bonatti = len(sorted) / 2 + k2 = everest - 1 + for count in count_arr: + c += abs(count - sorted[k])