-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]<K: | ||
if len(scoville)>=2: | ||
heapq.heappush(scoville, (heapq.heappop(scoville))+heapq.heappop(scoville)*2) | ||
answer+=1 | ||
else: | ||
return -1 | ||
|
||
return answer | ||
s = input() | ||
print(min(solution(s, 0),solution(s,1))) |