Skip to content

Commit

Permalink
Hippopotamus
Browse files Browse the repository at this point in the history
  • Loading branch information
Pastor committed Dec 26, 2024
1 parent 3ac742c commit 206753d
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ vol8/5.fsm.utext
vol8/5.rgx.utext
duplicate.csv
.output
questions.adoc
questions.pdf
questions.docx
questions.html
4 changes: 2 additions & 2 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@
LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_WHILE, METHOD_CALL,
METHOD_DEF, QUESTION, RESOURCE_SPECIFICATION, SUPER_CTOR_CALL, LAMBDA"/>
</module>
<module name="OperatorWrap">
<!--module name="OperatorWrap">
<property name="option" value="NL"/>
<property name="tokens"
value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR,
LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR, METHOD_REF "/>
</module>
</module-->
<module name="AnnotationLocation">
<property name="id" value="AnnotationLocationMostCases"/>
<property name="tokens"
Expand Down
27 changes: 18 additions & 9 deletions vol8/src/main/java/ru/mifi/practice/vol8/process/Information.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
public abstract class Information {
private static final Set<String> ACCEPTING = Set.of("КАБО-01-23", "КАБО-02-23", "КВБО-01-23");

private record Student(String code, String group, String fio) implements Comparable<Student> {
public record Student(String code, String group, String fio) implements Comparable<Student> {
@Override
public int compareTo(Student o) {
return code.compareTo(o.code);
}
}

public static void main(String[] args) throws IOException {
String fileName = "C:\\Users\\Pastor\\Downloads\\courseid_9687_participants.csv";
String output = ".output";
Statistics statistics = new Statistics.Default("E:\\GitHub\\algorithms-and-data-structures-2024\\students");
final Map<String, Statistics.Information> scanned = statistics.scan();
static Map<String, List<Student>> parseStudents(String fileName) throws IOException {
return parseStudents(fileName, ACCEPTING);
}

static Map<String, List<Student>> parseStudents(String fileName, Set<String> accepting) throws IOException {
Map<String, List<Student>> students = new HashMap<>();
try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
String line;
Expand All @@ -39,6 +39,9 @@ public static void main(String[] args) throws IOException {
String code = values[2].trim().toUpperCase(Locale.ROOT).replaceAll("\"", "")
.replace('К', 'K').replace('Л', 'L').replace('Р', 'R');
String group = values[4].trim().toUpperCase(Locale.ROOT).replaceAll("\"", "");
if (!accepting.contains(group)) {
continue;
}
if (!code.isEmpty()) {
String reduced = String.join(".", io.chars().filter(Character::isUpperCase).mapToObj(Character::toString).reduce("",
(a, b) -> a + b, (a, b) -> a + b).split("")) + ".";
Expand All @@ -48,12 +51,18 @@ public static void main(String[] args) throws IOException {
}
}
students.forEach((k, v) -> v.sort(Student::compareTo));
return students;
}

public static void main(String[] args) throws IOException {
String fileName = "C:\\Users\\Pastor\\Downloads\\courseid_9687_participants.csv";
String output = ".output";
Statistics statistics = new Statistics.Default("E:\\GitHub\\algorithms-and-data-structures-2024\\students");
final Map<String, Statistics.Information> scanned = statistics.scan();
Map<String, List<Student>> students = parseStudents(fileName, ACCEPTING);
File outputFile = new File(output);
outputFile.mkdirs();
for (Map.Entry<String, List<Student>> entry : students.entrySet()) {
if (!ACCEPTING.contains(entry.getKey())) {
continue;
}
try (BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outputFile, entry.getKey() + ".adoc")))) {
bw.append(":stem: latexmath").append("\n\n");
bw.append("= `").append(entry.getKey()).append("`\n").append("\n");
Expand Down
74 changes: 74 additions & 0 deletions vol8/src/main/java/ru/mifi/practice/vol8/process/Questions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package ru.mifi.practice.vol8.process;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.Map;

import static ru.mifi.practice.vol8.process.Information.parseStudents;

public abstract class Questions {
private static final String[][] QUESTIONS = new String[][]{
{"Двусвязный циклический", ""},
{"Двусвязный список", ""},
{"Односвязный список", ""},
{"Стек на списке", ""},
{"Стек на массиве", ""},
{"Очередь на списке", ""},
{"Очередь на массиве", ""},
{"Очередь на куче", ""},
{"BST", ""},
{"2-3", ""},
{"AVL", ""},
{"Хеш таблица", ""},
{"Обход в глубину", ""},
{"Обход в ширину", ""},
{"Кратчайший путь", ""},
{"Алгоритм Дейкстры", ""},
{"Бинарный поиск", ""},
{"Сортировка слиянием", ""},
{"Сортировка быстрая", ""},
{"Джонсона-Троттера", ""},
{"Алгоритм Хаффмана", ""},
};

@SuppressWarnings("checkstyle:OperatorWrap")
static final String PREAMBLE = "" +
"[small]#*Нельзя*:\n" +
"1. Использовать стандартные классы входяще в `JDK` реализующие алгоритмы или структуры данных;\n" +
"2. Пользоваться помощью `ИИ`;\n" +
"3. Пользоваться любыми ресурсами из сети интернет.#\n" +
"[small]#*Необходимо*:\n" +
"1. Рассказать устно об алгоритме и/или структуре данных в задании. Дать асимптотические характеристики " +
"алгоритму(-ам) используемым в задании;\n" +
"2. Реализовать при помощи ЯПВУ `Java`;\n" +
"3. Привести примеры данных позволяющие проверить работоспособность реализации и рассмотреть граничные характеристики алгоритма;\n" +
"4. Для структуры данных реализовать набор базовых алгоритмов для нее и дать описание им в соответствии с п.1.#";

public static void main(String[] args) throws IOException {
var students = parseStudents("C:\\Users\\Pastor\\Downloads\\courseid_9687_participants.csv");
var output = new File(".output/questions");
output.mkdirs();
for (Map.Entry<String, List<Information.Student>> entry : students.entrySet()) {
try (BufferedWriter w = new BufferedWriter(new FileWriter(new File(output, entry.getKey() + ".adoc")))) {
w.append("= `").append(entry.getKey()).append("`").append("\n").append(":hardbreaks-option:").append("\n").append("\n");
w.append(PREAMBLE).append("\n").append("\n");
w.append("[cols=\"^5%m,25%m,^40%m,^25%m,^5%m\"]").append("\n");
w.append("|===").append("\n");
w.append("|№|Алгоритм/Структура|Ф.И.О.|Примечание|Оц.").append("\n");
int count = 0;
for (String[] question : QUESTIONS) {
w.append("\n");
w.append("|").append(String.valueOf(count++)).append("\n");
w.append("|**").append(question[0]).append("**\n");
w.append("|").append(question[1]).append("\n");
w.append("|").append("\n");
w.append("|").append("\n");
}
w.append("|===").append("\n");
}
}
}
}

0 comments on commit 206753d

Please sign in to comment.