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

Kropotov - algo - hw04 #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Kropotov - algo - hw04 #2

wants to merge 1 commit into from

Conversation

alex-kropotov
Copy link
Owner

No description provided.

min_e = e if e < min_e else min_e
max_e = e if e > max_e else max_e
for idx, e in enumerate(a):
a[idx] = max_e if e == min_e else (min_e if e == max_e else e)
Copy link

Choose a reason for hiding this comment

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

тут все же лучше проверять через отдельные условия. Иначе много раз будем перезаписывать одни и те же значения в массив, что не очень хорошо

start_ind = 0
cur_simple = 0
res = 0
while start_ind < len(ma):
Copy link

Choose a reason for hiding this comment

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

len(ma) у нас постоянное значение, поэтому лучше один раз вычислить его и хранить в переменной отдельной. так быстрее будет работать программа

simples.append(cur)
ind += 1
cur += 2
return simples[len(simples) - 1]
Copy link

Choose a reason for hiding this comment

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

return simples[-1]

Comment on lines +73 to +74
# Видимо не правильно реализовал второй алгоритм, хотя делал как понял.
# Нужно было определить верхню границу для i-го простого числа, нашел формулу 2*n*ln(n)
Copy link

Choose a reason for hiding this comment

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

реализация правильная (в алгоритмическом смысле). Просто не самый эффективный код написан, ничего страшного в этом нету :)

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