-
Notifications
You must be signed in to change notification settings - Fork 0
HW3 is completed #3
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
base: master
Are you sure you want to change the base?
Conversation
sshaplygin
left a comment
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/10
Нотация:
👍 - Классное, не обычное, оригинальное решение
👀 - Стоит обратить внимание. Рекомендация, которая не влияет на успешность выполнения задания
🔥 - Критичное замечание, которое влияет на сдачу задания
p.s. Имя модуля необходимо править, тоже
module github.com/fixme_my_friend/hw03_frequency_analysis
| require.Len(t, Top10(""), 0) | ||
| }) | ||
|
|
||
| t.Run("no words in string with only spaces", func(t *testing.T) { |
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.
👀
что-то случилось с вашим форматированием кода. рекомендую перед коммитом в репозиторий
| } | ||
|
|
||
| func GroupWords(words []string) []Word { | ||
| var result = make([]Word, 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.
👀
Так как вы в момент определения не знаете финальный размер слайса, то лучше его не инициализировать, а просто определить:
var result []WordДалее с помощью функции append(...) слайс инициализируется и в него будет добавлен новый элемент
| } | ||
|
|
||
| func ValueIsExists(word string, Words []Word) (Word, int) { | ||
| for i, value := range Words { |
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.
👀
Очень дорогая операция поиска в слайсе. Она по времени будет нам стоить O(N). Можно сделать эффективнее этот поиск введя дополнительный хешмап, для которого поиск будет осуществляться в среднем за O(1)
| return groupedWords[i].Count > groupedWords[j].Count | ||
| }) | ||
|
|
||
| var result = make([]string, 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.
👀
В данный момент времени вы знаете сколько вам нужно элементов, поэтому лучше инициализировать слайс определенной длины.
length := 10
if len(groupedWords) < 10 {
length = len(groupedWords)
}
result := make([]string, 0, length)
Домашнее задание №3 «Частотный анализ»
Чек-лист студента (Что это?)
go mod tidy..syncфайл. Зачем его удалять?Критерии оценки
Зачёт от 7 баллов