-
Notifications
You must be signed in to change notification settings - Fork 20
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
Week1 #22
base: main
Are you sure you want to change the base?
Week1 #22
Conversation
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.
Задачки решены правильно! Есть вопросы по стилистике. Часть решений можно сделать сильно быстрей, часть решений можно написать одной строкой.
|
||
''' def unique_in_order(unique:str): | ||
list_1 = [] | ||
for id in range(len(unique)): |
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(unique) - в переменную нужно вынести, ты каждый раз вычисляешь ее
pass | ||
else: | ||
list_1.append(unique[id]) | ||
return list_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.
лапки должны быть на след строке
|
||
''' def unique_in_order(unique:str): | ||
list_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.
странное название переменной, нужно переназвать чтобы было понятно что в ней
list_1 = [] | ||
for id in range(len(unique)): | ||
if id == len(unique) - 1: | ||
list_1.append(unique[id]) |
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.
не нужное условие, тут два более питоньих решения 1) сделать через enumerate 2) одной строкой через filter
@@ -1,6 +1,6 @@ | |||
# 1. Unique on order | |||
|
|||
''' def unique_in_order(unique:str): | |||
``` def unique_in_order(unique:str): |
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.
три лапки слово питон новая строка
|
||
```python | ||
def disemvowel(string_): | ||
for i in "aeiouAEIOU": |
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 "".join(...)
def get_middle(s): | ||
if len(s) % 2 == 0: | ||
return s[(len(s) // 2) - 1 : (len(s) // 2) + 1] | ||
elif len(s) % 2 != 0: |
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.
тут должен быть else, ни в одном языке нет конструкции if ... else if ...
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.
и позицию среднего элемента в отдельную переменную, чтобы не считать ее каждый раз
list_1 = [] | ||
for i in a: | ||
if i in b: | ||
pass |
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.
if ... pass else something не надо испльзовать
она равнозначна конструкции одного if, еще это можно одной строкой
```python | ||
def likes(names): | ||
if len(names) == 0: | ||
return "no one likes this" |
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.
Есть три варианта использования кавычек, у тебя перемешано
- двойные кавычки строки, одинарные символы (у нас)
- везде двойные
- везде одинарные
# [10. Unique on order.] | ||
```python | ||
def to_time(seconds): | ||
return f"{seconds//3600} hour(s) and {seconds%3600//60} minute(s)" |
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.
в целом вычисление в темплейтах плохо, это очень сложно и читать и поддерживать
внутри темплейта должны быть переменные
Исправила решения и добавила новые
Add codware