-
-
Save jezinka/ea40d83447e14713c9e4fd1e9e444b78 to your computer and use it in GitHub Desktop.
first
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| large_number = open("source.txt", 'r').read() | |
| large_number_array = list(map(int, str(large_number))) | |
| def find_max_product(k): | |
| max_product = 1 | |
| for i in range(0, k): | |
| max_product *= large_number_array[i] | |
| window_product = max_product | |
| for i in range(k, len(large_number_array)): | |
| window_product = window_product // large_number_array[i - k] * large_number_array[i] | |
| max_product = max(window_product, max_product) | |
| return max_product | |
| assert find_max_product(4) == 5832 | |
| print(find_max_product(13)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment