From b820b69cb7186c0911d1ebfe2e565bd001063ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=9D=80=EA=B8=B0?= Date: Thu, 24 Jun 2021 01:45:52 +0900 Subject: [PATCH] =?UTF-8?q?6/24=20=EB=AC=B8=EC=9E=90=EC=97=B4=20=EB=92=A4?= =?UTF-8?q?=EC=A7=91=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- choieungi/.idea/.gitignore | 8 +++++++ choieungi/.idea/choieungi.iml | 8 +++++++ .../inspectionProfiles/Project_Default.xml | 10 +++++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++++ choieungi/.idea/misc.xml | 4 ++++ choieungi/.idea/modules.xml | 8 +++++++ choieungi/.idea/vcs.xml | 6 +++++ ...53\222\244\354\247\221\352\270\260 - 1.py" | 22 +++++++++++++++++++ ...53\222\244\354\247\221\352\270\260 - 2.py" | 7 ++++++ choieungi/main.py | 16 +++++--------- 10 files changed, 84 insertions(+), 11 deletions(-) create mode 100644 choieungi/.idea/.gitignore create mode 100644 choieungi/.idea/choieungi.iml create mode 100644 choieungi/.idea/inspectionProfiles/Project_Default.xml create mode 100644 choieungi/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 choieungi/.idea/misc.xml create mode 100644 choieungi/.idea/modules.xml create mode 100644 choieungi/.idea/vcs.xml create mode 100644 "choieungi/NewThisIsCT/11_3 \353\254\270\354\236\220\354\227\264 \353\222\244\354\247\221\352\270\260 - 1.py" create mode 100644 "choieungi/NewThisIsCT/11_3 \353\254\270\354\236\220\354\227\264 \353\222\244\354\247\221\352\270\260 - 2.py" diff --git a/choieungi/.idea/.gitignore b/choieungi/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/choieungi/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/choieungi/.idea/choieungi.iml b/choieungi/.idea/choieungi.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/choieungi/.idea/choieungi.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/choieungi/.idea/inspectionProfiles/Project_Default.xml b/choieungi/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..72ad4ef --- /dev/null +++ b/choieungi/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/choieungi/.idea/inspectionProfiles/profiles_settings.xml b/choieungi/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/choieungi/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/choieungi/.idea/misc.xml b/choieungi/.idea/misc.xml new file mode 100644 index 0000000..7ba73c2 --- /dev/null +++ b/choieungi/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/choieungi/.idea/modules.xml b/choieungi/.idea/modules.xml new file mode 100644 index 0000000..9b4fcba --- /dev/null +++ b/choieungi/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/choieungi/.idea/vcs.xml b/choieungi/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/choieungi/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git "a/choieungi/NewThisIsCT/11_3 \353\254\270\354\236\220\354\227\264 \353\222\244\354\247\221\352\270\260 - 1.py" "b/choieungi/NewThisIsCT/11_3 \353\254\270\354\236\220\354\227\264 \353\222\244\354\247\221\352\270\260 - 1.py" new file mode 100644 index 0000000..212fa7a --- /dev/null +++ "b/choieungi/NewThisIsCT/11_3 \353\254\270\354\236\220\354\227\264 \353\222\244\354\247\221\352\270\260 - 1.py" @@ -0,0 +1,22 @@ +s = list(map(int, input())) # change string to int list + +def check_str(s, find): + idx = 0 + cnt = 0 + flag = False + while True: + if idx == len(s): return cnt + + if s[idx] is not find : + flag = False + idx += 1 + + elif s[idx] == find and not flag: + idx += 1 + flag = True + cnt += 1 + + elif s[idx] == find and flag: + idx += 1 + +print(min(check_str(s, 0), check_str(s, 1))) \ No newline at end of file diff --git "a/choieungi/NewThisIsCT/11_3 \353\254\270\354\236\220\354\227\264 \353\222\244\354\247\221\352\270\260 - 2.py" "b/choieungi/NewThisIsCT/11_3 \353\254\270\354\236\220\354\227\264 \353\222\244\354\247\221\352\270\260 - 2.py" new file mode 100644 index 0000000..777bad3 --- /dev/null +++ "b/choieungi/NewThisIsCT/11_3 \353\254\270\354\236\220\354\227\264 \353\222\244\354\247\221\352\270\260 - 2.py" @@ -0,0 +1,7 @@ +def solution(s, basis): + block = s.split(str(basis)) # change basis to '' in string. ex) "001100" -> ['','','11','',''] + return len(block) - block.count('') # count the sequence number + + +s = input() +print(min(solution(s, 0),solution(s,1))) diff --git a/choieungi/main.py b/choieungi/main.py index 7cf5f50..777bad3 100644 --- a/choieungi/main.py +++ b/choieungi/main.py @@ -1,13 +1,7 @@ -import heapq +def solution(s, basis): + block = s.split(str(basis)) # change basis to '' in string. ex) "001100" -> ['','','11','',''] + return len(block) - block.count('') # count the sequence number -def solution(scoville, K): - answer = 0 - heapq.heapify(scoville) - while scoville[0]=2: - heapq.heappush(scoville, (heapq.heappop(scoville))+heapq.heappop(scoville)*2) - answer+=1 - else: - return -1 - return answer \ No newline at end of file +s = input() +print(min(solution(s, 0),solution(s,1)))