MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / solution

Function solution

project_euler/problem_115/sol1.py:30–58  ·  view source on GitHub ↗

Returns for given minimum block length the least value of n for which the fill-count function first exceeds one million >>> solution(3) 30 >>> solution(10) 57

(min_block_length: int = 50)

Source from the content-addressed store, hash-verified

28
29
30def solution(min_block_length: int = 50) -> int:
31 """
32 Returns for given minimum block length the least value of n
33 for which the fill-count function first exceeds one million
34
35 >>> solution(3)
36 30
37
38 >>> solution(10)
39 57
40 """
41
42 fill_count_functions = [1] * min_block_length
43
44 for n in count(min_block_length):
45 fill_count_functions.append(1)
46
47 for block_length in range(min_block_length, n + 1):
48 for block_start in range(n - block_length):
49 fill_count_functions[n] += fill_count_functions[
50 n - block_start - block_length - 1
51 ]
52
53 fill_count_functions[n] += 1
54
55 if fill_count_functions[n] > 1_000_000:
56 break
57
58 return n
59
60
61if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected