본문 바로가기

hacking sorcerer

really beautiful

728x90
반응형

def count_pattern(sound, pattern):
count = 0
i = 0
m = len(pattern)

for _ in range(len(sound)):
    if i > len(sound) - m:
        break  

    if sound[i:i + m] == pattern:
        count += 1
        i += m    
    else:
        i += 1     

return count

sound = input().strip()
pattern = input().strip()
print(count_pattern(sound, pattern))

728x90
반응형

'hacking sorcerer' 카테고리의 다른 글

Problem Solving: Balance the Boxes  (0) 2025.12.16
Problem: Balance the Boxes  (0) 2025.12.16
Problem: Valley Count in a Number Path  (0) 2025.12.02
너무 잘 만들어진 해커들의 놀이터 한국  (0) 2025.12.01
coffee heaven  (0) 2025.11.25