Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Creative category for Count Consecutive Summers by dig
def count_consecutive_summers(num):
def start_number(start):
count = start
while True:
if count == num:
return True
elif count > num:
return False
start += 1
count+=start
return len(list(filter(start_number,[i for i in range(1, num+1)])))
if __name__ == '__main__':
print("Example:")
print(count_consecutive_summers(42))
# These "asserts" are used for self-checking and not for an auto-testing
assert count_consecutive_summers(42) == 4
assert count_consecutive_summers(99) == 6
assert count_consecutive_summers(1) == 1
print("Coding complete? Click 'Check' to earn cool rewards!")
April 17, 2023