From 7f63bba59b5b61a2749b84e35b0c1176ba035132 Mon Sep 17 00:00:00 2001 From: ChoiEungi Date: Tue, 29 Jun 2021 11:35:28 +0900 Subject: [PATCH] =?UTF-8?q?6/28=20=EB=AC=B8=EC=9E=90=EC=97=B4=20=EC=95=95?= =?UTF-8?q?=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\227\264 \354\225\225\354\266\225.py" | 19 +++++++++++++++ choieungi/TeamNote/__init__.py | 0 choieungi/TeamNote/rotate_array.py | 24 +++++++++++++++++++ choieungi/main.py | 22 ++++++++++++++--- 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 "choieungi/12-9 \353\254\270\354\236\220\354\227\264 \354\225\225\354\266\225.py" create mode 100644 choieungi/TeamNote/__init__.py create mode 100644 choieungi/TeamNote/rotate_array.py diff --git "a/choieungi/12-9 \353\254\270\354\236\220\354\227\264 \354\225\225\354\266\225.py" "b/choieungi/12-9 \353\254\270\354\236\220\354\227\264 \354\225\225\354\266\225.py" new file mode 100644 index 0000000..77ed37f --- /dev/null +++ "b/choieungi/12-9 \353\254\270\354\236\220\354\227\264 \354\225\225\354\266\225.py" @@ -0,0 +1,19 @@ +def solution(s): + answer = len(s) + l = len(s) + for step in range(1, l // 2 + 1): + cnt = 1 + compressed = "" + prev = s[0:step] + for i in range(step, l, step): + if s[i:i + step] == prev: + cnt += 1 + else: + compressed += str(cnt) + prev if cnt > 1 else prev + prev = s[i: i + step] + cnt = 1 + compressed += str(cnt) + prev if cnt > 1 else prev + + answer = min(answer, len(compressed)) + + return answer \ No newline at end of file diff --git a/choieungi/TeamNote/__init__.py b/choieungi/TeamNote/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/choieungi/TeamNote/rotate_array.py b/choieungi/TeamNote/rotate_array.py new file mode 100644 index 0000000..43a50c9 --- /dev/null +++ b/choieungi/TeamNote/rotate_array.py @@ -0,0 +1,24 @@ +# rotate left n*m array + +def rotate(space, n, m): + new_space = [[0]*m for _ in range(n)] + + for i in range(n): + for j in range(m): + new_space[n-j-1][i] = space[i][j] + return new_space + + +test_space = [[1, 2, 3], + [4, 5, 6], + [7, 8, 9]] + +return_val = rotate(test_space,len(test_space), len(test_space[0])) + +for i in return_val: + print (i) +""" +[3, 6, 9] +[2, 5, 8] +[1, 4, 7] +""" diff --git a/choieungi/main.py b/choieungi/main.py index b0e080d..77ed37f 100644 --- a/choieungi/main.py +++ b/choieungi/main.py @@ -1,3 +1,19 @@ -s = [*map(int, input())] -l = len(s)//2 -print("READY"if sum(s[:l])-sum(s[l:])else"LUCKY") \ No newline at end of file +def solution(s): + answer = len(s) + l = len(s) + for step in range(1, l // 2 + 1): + cnt = 1 + compressed = "" + prev = s[0:step] + for i in range(step, l, step): + if s[i:i + step] == prev: + cnt += 1 + else: + compressed += str(cnt) + prev if cnt > 1 else prev + prev = s[i: i + step] + cnt = 1 + compressed += str(cnt) + prev if cnt > 1 else prev + + answer = min(answer, len(compressed)) + + return answer \ No newline at end of file