def solution(t, p):
answer = 0
tLength = len(t)
pLength = len(p)
gap = tLength - pLength + 1
for i in range(0, gap):
if int(p) >= int(t[i:i+pLength]):
answer += 1
return answer
내 풀이
대부분 비슷하게 풀었고 파이써닉하게 한줄로 표현한 코드도 있다.
def solution(t, p):
return sum([int(t[i:i+len(p)]) <= int(p) for i in range(len(t)-len(p)+1)])