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

Solution #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ CodeKiller777

Ручной ввод пути к файлу (через консоль, через правку переменной в коде и т.д.) недопустим. Необходимость любых ручных действий с файлами в процессе работы программы будут обнулять решение.

## Автор решения
## Автор решения: Маликов Алим


## Описание реализации
## Описание реализации: необходимо создать программу, которая будет вычислять трех самых активных участников на основе данных о коммитах в релизную ветку за спринт. Ниже приведен пример кода на Java

## Инструкция по сборке и запуску решения
3 changes: 3 additions & 0 deletions Task_Java/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Task_Java/.idea/Task_Croc.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Task_Java/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Task_Java/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Task_Java/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Task_Java/Task/Task.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
32 changes: 32 additions & 0 deletions Task_Java/Task/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

import java.io.*;
import java.util.*;

public class Main {
public static void main(String[] args) {
Map <String, Integer> commits = new HashMap<>();

try (BufferedReader reader = new BufferedReader(new FileReader("commits.txt"))) {
String line;
while ((line = reader.readLine()) != null) {
String[] parts = line.split(" ");
String username = parts[0];

commits.put(username, commits.getOrDefault(username, 0) + 1);
}
} catch (IOException e) {
e.printStackTrace();
}

List<String> bestContributors = new ArrayList<>(commits.keySet());
bestContributors.sort((a, b) -> commits.get(b) - commits.get(a));

try (PrintWriter writer = new PrintWriter("result.txt")) {
for (int i = 0; i < Math.min(3, bestContributors.size()); i++) {
writer.println(bestContributors.get(i));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}