Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UP my solution #14

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

Ambrwaz
Copy link

@Ambrwaz Ambrwaz commented Dec 18, 2023

No description provided.

Comment on lines 44 to 49
for k in range(X.shape[0]) :
for l in range(X.shape[1]) :
if X[k,l] > max :
max = X[k,l]
i = k
j = l
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No for loop, look at numpy.unravel_index

Comment on lines 75 to 77
for k in range(1,n_terms+1) :
k_square = k**2
pi *= (4*k_square/(4*k_square -1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the first optimization (don't compute the square twice), but you can do even better and without for loop using vectorized numpy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants