-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
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) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return simples[-1]
# Видимо не правильно реализовал второй алгоритм, хотя делал как понял. | ||
# Нужно было определить верхню границу для i-го простого числа, нашел формулу 2*n*ln(n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
реализация правильная (в алгоритмическом смысле). Просто не самый эффективный код написан, ничего страшного в этом нету :)
No description provided.