Created
September 11, 2017 06:05
-
-
Save anonymous/845f57c2cb99b845c112dadfc5228856 to your computer and use it in GitHub Desktop.
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
import numpy as np | |
import time | |
from tqdm import tnrange, tqdm | |
from bokeh.plotting import figure, output_notebook, show | |
def solve(a): | |
diag = np.diag(np.fliplr(a)) # n + log(n) | |
min_elem_index = diag.argmin() # n^2 | |
avrg_sum = a[a < 0].mean() # nlog(n) | |
min_elem_row, min_elem_columns = min_elem_index, a.shape[1] - min_elem_index - 1 # 5 | |
a = a.astype(float) # n | |
a[min_elem_row, min_elem_columns] = avrg_sum # 1 | |
# n + log(n) + n^2 + nlog(n) + 5 + n + 1 = n2 + (1+n)log(n) + 2n + 6 | |
size_values = list(range(100, 900, 200)) + list(range(1000, 19000, 1000)) | |
timings = [] | |
print('there') | |
for size in size_values: | |
arr = np.random.randint(-10000, 10000, (size, size)) | |
start_time = time.time() | |
solve(arr) | |
end_time = time.time() | |
timings.append(end_time - start_time) | |
print('here') | |
# output_notebook() | |
print(there) | |
print(timings) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment