Skip to content

For pr#111

Open
psychotrance wants to merge 107 commits intoKFalcon2022:for-prfrom
psychotrance:for-pr
Open

For pr#111
psychotrance wants to merge 107 commits intoKFalcon2022:for-prfrom
psychotrance:for-pr

Conversation

@psychotrance
Copy link
Copy Markdown

@psychotrance psychotrance commented Apr 18, 2025

Исправления в Lesson 14-17
Добавил задания из Lesson 18

Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
AVL_Tree: not ended(plz check)
AVL_tree_2: from youtube with correction

Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
… он имелся ввиду

Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
check code format, plz)

Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Scanner scanner = new Scanner(System.in);
Stream.generate(scanner::nextInt)
.takeWhile(num -> num != 1)
.forEach(_ -> System.out.println("Not guess!"));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

а как понять, что выиграл?)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Я, конечно же, написал после выполнения стрима system.out.println("Guess"), но это видимо не то, что ты хотел мне донести, по этому хелп)


@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

фуфуфу

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Убрал)

return null;
return departments.stream()
.flatMap(dep -> dep.getEmployees().stream())
.collect(Collectors.toList());
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

думаешь, нам нужен изменяемый список?

return departments.stream()
.flatMap(department -> department.getEmployees().stream())
.collect(Collectors.groupingBy(Employee::getName,
TreeMap::new,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

избыточно

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Я не понимаю, что именно избыточно, по этому прошу помощи
Если TreeMap:new убрать, IDEA пугается на несоответствующий возвращаемый тип

.stream(),
Collectors.teeing(
Collectors.filtering(Employee::isMale,
Collectors.toList()),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Collectors.counting()? Нам список не нужен

));

/* Я другие варианты как выполнить это задание не нашел.
* Но если есть - дай намёк, пж) */
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

https://github.com/KFalcon2022/practical-tasks/blob/master/src/com/walking/lesson57_stream_collect_collector/task/Task23.java

Иногда проще выйти за пределы стрима. В остальном - идея верная

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Принято, спасибо)

return null;
return departments.stream()
.sorted(Comparator.comparing(Department::getName))
.collect(LinkedList::new,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Чем обычный список не устроил?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ну в задании же конкретно LinkedList вернуть надо)
Или я снова что-то не понимаю?)

return departments.stream()
.collect(Collectors.toMap(Department::getName,
department -> ((double) department.getEmployees()
.size() / department.getVacancyAmount()) * 100));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Делимое и делитель местами перепутал. И перенос строки неудачный

public static void main(String[] args) {
}

private static Map<String, Employee> getOldestEmployees(List<Department> departments) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Боюсь, это была задачка на Map#compute()

Map<String, Integer> sumAges = new HashMap<>();
employees.forEach(employee -> {
sumAges.putIfAbsent(employee.getName(), 0);
sumAges.computeIfPresent(employee.getName(), (key, age) -> age + employee.getAge());
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

решается через один compute

Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
Signed-off-by: AlexeyNiyazov <psychotrance92@yandex.ru>
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