Largest 5 digit number in a series
def solution(digits):
max_5_digit = 0
for k in range(len(digits)):
cur_5_digit = int(digits[k:k+5])
if cur_5_digit > max_5_digit:
max_5_digit = cur_5_digit
return max_5_digit
简写
def solution(digits):
return max((digits[k:k+5]) for k in range(len(digits)-4))