1
0

Compare commits

...

14 Commits

Author SHA1 Message Date
Sytnyk Yehor
d22b7ddcaf SMP all works 2025-06-05 12:21:37 +03:00
Sytnyk Yehor
bdcbdb850a JAVA lb-4 fixes 2025-06-05 12:21:12 +03:00
Sytnyk Yehor
232422d9d9 JAVA all works 2025-06-01 08:56:01 +03:00
Sytnyk Yehor
1e4d20b6a8 PRPA lb-4 2025-05-30 22:56:34 +03:00
Sytnyk Yehor
84f7393e78 PRPA lb-3 2025-05-30 22:56:25 +03:00
Sytnyk Yehor
e79109c81a OS lb-8 2025-05-30 22:55:57 +03:00
Sytnyk Yehor
28ccfa72ac OS lb-7 mark 2025-05-27 23:23:28 +03:00
Sytnyk Yehor
a63c29ff99 added pdfs to SMP works 2025-05-17 21:13:08 +03:00
Sytnyk Yehor
bcc528f060 PRPA lb-2 (figma) 2025-05-15 20:54:30 +03:00
Sytnyk Yehor
62049428c0 OS lb-7 2025-05-15 20:51:24 +03:00
Sytnyk Yehor
24939470e5 OS lb-6 mark 2025-05-15 20:51:05 +03:00
Sytnyk Yehor
9fb9f66f27 OS lb-6 2025-05-15 13:11:19 +03:00
Sytnyk Yehor
4c01c2fe11 added pdfs to all OS labs 2025-05-15 13:10:01 +03:00
Sytnyk Yehor
dbea0e87fd added gitignore 2025-05-15 13:05:20 +03:00
248 changed files with 13373 additions and 28 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*build*

202
semester-4/ОПJа/lb-1/task1/.gitignore vendored Normal file
View File

@@ -0,0 +1,202 @@
/target/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
# Created by https://www.gitignore.io/api/git,java,maven,eclipse,windows
### Eclipse ###
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
### Eclipse Patch ###
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
# Annotation Processing
.apt_generated
.sts4-cache/
### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig
# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Some additional ignores (sort later)
*.DS_Store
*.sw?
.#*
*#
*~
.classpath
.project
.settings
bin
build
target
dependency-reduced-pom.xml
*.sublime-*
/scratch
.gradle
README.html
*.iml
.idea
.exercism

202
semester-4/ОПJа/lb-2/task2/.gitignore vendored Normal file
View File

@@ -0,0 +1,202 @@
/target/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
# Created by https://www.gitignore.io/api/git,java,maven,eclipse,windows
### Eclipse ###
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
### Eclipse Patch ###
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
# Annotation Processing
.apt_generated
.sts4-cache/
### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig
# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Some additional ignores (sort later)
*.DS_Store
*.sw?
.#*
*#
*~
.classpath
.project
.settings
bin
build
target
dependency-reduced-pom.xml
*.sublime-*
/scratch
.gradle
README.html
*.iml
.idea
.exercism

View File

@@ -1,6 +1,7 @@
package ua.nure.jfn.task2;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class ArrayImpl<T> implements Array<T> {
@@ -11,10 +12,10 @@ public class ArrayImpl<T> implements Array<T> {
}
public ArrayImpl(Container<T> container) {
this.elements = new Object[container.size() + 1];
elements = new Object[container.size() + 1];
for (T element : container)
this.add(element);
add(element);
}
@Override
@@ -43,7 +44,7 @@ public class ArrayImpl<T> implements Array<T> {
@Override
public int size() {
return this.size;
return size;
}
@SuppressWarnings("unchecked")
@@ -127,7 +128,7 @@ public class ArrayImpl<T> implements Array<T> {
@Override
public T next() {
if (!hasNext())
throw new java.util.NoSuchElementException();
throw new NoSuchElementException();
lastReturnedIndex = currentIndex;
return (T) elements[currentIndex++];

View File

@@ -1,6 +1,7 @@
package ua.nure.jfn.task2;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class ListImpl<T> implements List<T> {
@@ -114,7 +115,7 @@ public class ListImpl<T> implements List<T> {
@Override
public void removeFirst() {
if (head == null)
throw new java.util.NoSuchElementException();
throw new NoSuchElementException();
head = head.next;
size--;
@@ -123,7 +124,7 @@ public class ListImpl<T> implements List<T> {
@Override
public void removeLast() {
if (head == null)
throw new java.util.NoSuchElementException();
throw new NoSuchElementException();
if (head.isLast())
head = null;
@@ -137,7 +138,7 @@ public class ListImpl<T> implements List<T> {
@Override
public T getFirst() {
if (head == null)
throw new java.util.NoSuchElementException();
throw new NoSuchElementException();
return (T) head.data;
}
@@ -146,12 +147,12 @@ public class ListImpl<T> implements List<T> {
@Override
public T getLast() {
if (head == null)
throw new java.util.NoSuchElementException();
throw new NoSuchElementException();
if (head.isLast())
return (T) head.data;
else
return (T) head.getLast();
return (T) head.getLast();
}
@SuppressWarnings("unchecked")
@@ -162,7 +163,8 @@ public class ListImpl<T> implements List<T> {
if (head.data != null && head.data.equals(element))
return (T) head.data;
else if (head.next != null)
if (head.next != null)
return (T) head.search(element);
return null;
@@ -178,9 +180,8 @@ public class ListImpl<T> implements List<T> {
return true;
}
if (head.next != null) {
if (head.next != null)
return head.remove(element);
}
return false;
}
@@ -224,7 +225,7 @@ public class ListImpl<T> implements List<T> {
@Override
public T next() {
if (!hasNext())
throw new java.util.NoSuchElementException();
throw new NoSuchElementException();
prev = curr;
curr = curr.next;

View File

@@ -20,10 +20,9 @@ public class StreamImpl<T> implements Stream<T> {
public Container<?> apply(Container<?> input) {
Array<T> newContainer = new ArrayImpl<T>();
for (Object element : input) {
for (Object element : input)
if (predicate.apply((T) element))
newContainer.add((T) element);
}
return newContainer;
}
@@ -41,9 +40,8 @@ public class StreamImpl<T> implements Stream<T> {
public Container<?> apply(Container<?> input) {
Array<R> newContainer = new ArrayImpl<R>();
for (Object element : input) {
for (Object element : input)
newContainer.add(function.apply((T) element));
}
return newContainer;
}
@@ -61,14 +59,14 @@ public class StreamImpl<T> implements Stream<T> {
@Override
public Stream<T> filter(Function<? super T, Boolean> predicate) {
Array<Operation> newOperations = new ArrayImpl<>(this.operations);
Array<Operation> newOperations = new ArrayImpl<>(operations);
newOperations.add(new FilterOperation<>(predicate));
return new StreamImpl<T>(source, newOperations);
}
@Override
public <R> Stream<R> map(Function<? super T, ? extends R> function) {
Array<Operation> newOperations = new ArrayImpl<>(this.operations);
Array<Operation> newOperations = new ArrayImpl<>(operations);
newOperations.add(new MapOperation<>(function));
return new StreamImpl<R>(source, newOperations);
}
@@ -88,13 +86,10 @@ public class StreamImpl<T> implements Stream<T> {
@SuppressWarnings("unchecked")
@Override
public void forEach(Action<? super T> action) {
for (Operation operation : operations) {
for (Operation operation : operations)
source = operation.apply(source);
}
for (Object element : source) {
for (Object element : source)
action.perform((T) element);
}
}
}

View File

@@ -0,0 +1,4 @@
> [!NOTE]
> Викладач: Колесников Д. О.
>
> Оцінка: In Progress

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

202
semester-4/ОПJа/lb-3/task3/.gitignore vendored Normal file
View File

@@ -0,0 +1,202 @@
/target/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
# Created by https://www.gitignore.io/api/git,java,maven,eclipse,windows
### Eclipse ###
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
### Eclipse Patch ###
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
# Annotation Processing
.apt_generated
.sts4-cache/
### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig
# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Some additional ignores (sort later)
*.DS_Store
*.sw?
.#*
*#
*~
.classpath
.project
.settings
bin
build
target
dependency-reduced-pom.xml
*.sublime-*
/scratch
.gradle
README.html
*.iml
.idea
.exercism

View File

@@ -0,0 +1,6 @@
Login;Name;Email
petrenko;Ìàð³ÿ Ïåòðåíêî;petrenko2@mail.com
ivanenko;Áåàòðèññà-Âàëåði ²âàíåíêî;ivanenko@mail.com
obama;Barack Hussein Obama;obama@gmail.com
lennon;John Lennon;lennon@live.com
bush;Äæîðäæ Âîêåð Áóø;bush@gmail.com

View File

@@ -0,0 +1,2 @@
When I was younger, so much younger than today
I never needed anybody's help in any way

View File

@@ -0,0 +1,2 @@
when I was younger younger than today was
I never needed needed never never was I was

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ua.nure.jfn</groupId>
<artifactId>task3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
<junit5.version>5.12.0</junit5.version>
<surefire.version>3.5.2</surefire.version>
<spoon.version>11.2.0</spoon.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-core</artifactId>
<version>${spoon.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.17</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>task3</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@@ -0,0 +1,46 @@
package ua.nure.jfn.task3;
import ua.nure.jfn.task3.converter.CyrillicConverter;
import ua.nure.jfn.task3.converter.MayaConverter;
import ua.nure.jfn.task3.converter.PositionalConverter;
import ua.nure.jfn.task3.converter.RomanConverter;
public class Demo {
private static final String[] EMPTY = new String[] {};
public static void main(String[] args) {
System.out.println("----Part 1----");
Part1.main(EMPTY);
System.out.println("----Part 2----");
Part2.main(EMPTY);
System.out.println("----Part 3----");
Part3.main(EMPTY);
String s;
System.out.println("----Cyrillic----");
s = "999_999";
System.out.println(s);
System.out.println(CyrillicConverter.convert(s));
System.out.println();
System.out.println("----Maya----");
s = "100_000";
System.out.println(s);
System.out.println(MayaConverter.convert(s));
System.out.println();
System.out.println("----Roman----");
s = "3_999";
System.out.println(s);
System.out.println(RomanConverter.convert(s));
System.out.println();
System.out.println("----Positional----");
PositionalConverter.main(EMPTY);
}
}

View File

@@ -0,0 +1,64 @@
package ua.nure.jfn.task3;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Part1 {
private static final String PATH = "part1.txt";
public static void main(String[] args) {
String lines = Utils.getContent(PATH);
System.out.println(convert1(lines));
System.out.println();
System.out.println(convert2(lines));
System.out.println();
System.out.println(convert3(lines));
}
public static String convert1(String input) {
Matcher matcher = Pattern.compile(" ([\\S]*;[\\S]*@[\\S]*)").matcher(input);
String result = "LastName;Email";
while (matcher.find())
result += "\n" + matcher.group(1);
return result;
}
public static String convert2(String input) {
Matcher matcher = Pattern.compile(";([\\S]*) *([\\S]*) ([\\S]*);").matcher(input);
String result = "LastName;MiddleName;FirstName";
while (matcher.find())
result += String.format(
"\n%s;%s;%s",
matcher.group(3),
matcher.group(2),
matcher.group(1));
return result;
}
public static String convert3(String input) {
Matcher matcher = Pattern.compile("(.*);(.*) ([^\\s]*);").matcher(input);
int[] len = { 0, 0, 0 };
while (matcher.find())
for (int i = 0; i < 3; i++)
len[i] = Utils.max(len[i], matcher.group(i + 1).length());
matcher.reset();
String result = "";
while (matcher.find())
result += String.format(
"\n%-" + len[2] + "s %-" + len[1] + "s %-" + len[0] + "s",
matcher.group(3),
matcher.group(2),
matcher.group(1));
return result.trim();
}
}

View File

@@ -0,0 +1,48 @@
package ua.nure.jfn.task3;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Part2 {
private static final String PATH = "part2.txt";
public static void main(String[] args) {
String lines = Utils.getContent(PATH);
for (int j = 1; j < 10; j++)
System.out.println(convert(lines, j));
}
public static String convert(String input, int k) {
int lengths = 0;
for (String word : input.split(" "))
lengths |= 1 << (word.length() - 1);
int kLength = 0;
int currLength = 0;
for (; lengths > 0 && currLength != k; lengths >>= 1) {
kLength++;
if ((lengths & 1) == 1)
currLength++;
}
if (currLength != k)
kLength = 0;
Matcher matcher = Pattern.compile(String.format("(?<=^|\\s)(\\S{%d})(?=$|\\s)", kLength)).matcher(input);
String result = "";
while (matcher.find())
if (!result.matches(".*(?<=^|\\s)" + matcher.group(1) + "(?=$|\\s).*"))
result += " " + matcher.group(1);
if (result != "")
result = k + ":" + result;
return result;
}
}

View File

@@ -0,0 +1,40 @@
package ua.nure.jfn.task3;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Part3 {
private static final String PATH = "part3.txt";
public static void main(String[] args) {
String lines = Utils.getContent(PATH);
System.out.println(convert(lines));
}
public static String convert(String input) {
String[] words = input.split("\\s+");
String result = input;
int last = 0;
String[] processed = new String[words.length];
for (String word : words) {
if (Utils.contains(word, processed))
continue;
Pattern pattern = Pattern.compile("(?<=^|\\s)(\\Q" + word + "\\E)(?=$|\\s)",
Pattern.UNICODE_CHARACTER_CLASS);
Matcher matcher = pattern.matcher(input);
for (int i = 0; matcher.find(); i++) {
if (i % 2 != 0)
result = Utils.copyOfRange(result, 0, matcher.start()) + Utils.changeCase(matcher.group())
+ Utils.copyOfRange(result, matcher.end(), input.length());
}
processed[last++] = word;
}
return result.toString();
}
}

View File

@@ -0,0 +1,91 @@
package ua.nure.jfn.task3;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public final class Utils {
private static final String ENCODING = "Cp1251";
private Utils() {
}
public static int parseInt(String s, int base) {
int num = 0;
int pow = 1;
char[] chArray = s.toCharArray();
for (int i = chArray.length - 1; i >= 0; i--) {
char ch = chArray[i];
if (ch >= '0' && ch <= '9') {
num += (ch - '0') * pow;
pow *= base;
} else if (ch >= 'A' && ch <= 'Z') {
num += (ch - 'A' + 10) * pow;
pow *= base;
}
}
return num;
}
public static int parseInt(String s) {
return parseInt(s, 10);
}
public static String changeCase(String s) {
String arr1 = "abcdefghijklmnopqrstuvwxyzабвгґдеєжзиіїйклмнопрстуфхцчшщьюяABCDEFGHIJKLMNOPQRSTUVWXYZАБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯ";
String arr2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZАБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯabcdefghijklmnopqrstuvwxyzабвгґдеєжзиіїйклмнопрстуфхцчшщьюя";
String result = "";
for (char c : s.toCharArray()) {
int i = arr1.indexOf(c);
if (i != -1)
c = arr2.charAt(i);
result += c;
}
return result;
}
public static boolean contains(String o, String[] arr) {
for (String e : arr)
if (e != null && e.equals(o))
return true;
return false;
}
public static String copyOfRange(String s, int start, int end) {
char[] arr = s.toCharArray();
char[] result = new char[end - start];
for (int i = 0; i < end - start; i++)
result[i] = arr[start + i];
return new String(result);
}
public static int max(int a, int b) {
return a > b ? a : b;
}
public static String getContent(String path) {
String res = null;
try {
byte[] bytes = Files.readAllBytes(Paths.get(path));
res = new String(bytes, ENCODING);
} catch (IOException ex) {
ex.printStackTrace();
}
return res;
}
public static void main(String[] args) {
System.out.println(getContent("part1.txt"));
}
}

View File

@@ -0,0 +1,55 @@
package ua.nure.jfn.task3.converter;
import ua.nure.jfn.task3.Utils;
// Cyrillic numerals.
public class CyrillicConverter {
private static char[][] digits = {
{ '\u0430', '\u0432', '\u0433', '\u0434', '\u0454', '\u0455', '\u0437', '\u0438', '\u0473' },
{ '\u0456', '\u043A', '\u043B', '\u043C', '\u043D', '\u046F', '\u043E', '\u043F', '\u0447' },
{ '\u0440', '\u0441', '\u0442', '\u0443', '\u0444', '\u0445', '\u0471', '\u0461', '\u0446' }
};
/**
* The thousands sign to multiply the number's value.
*/
private static char kMul = '\u0482';
public static String convert(String str) {
int num = Utils.parseInt(str);
String result = "";
boolean isK = false;
int digitPlace = 0;
while (num != 0) {
int digit = (num % 10);
if (digit > 0)
result = String.format("%s%s%s", isK ? kMul : "", digits[digitPlace][digit - 1], result);
num /= 10;
isK = digitPlace == 2 ? true : isK;
digitPlace += digitPlace == 2 ? -2 : 1;
}
return result;
}
public static void main(String[] args) {
System.out.println("All the digits:");
int k = 1;
for (int j = 0; j < 3; j++) {
for (int i = 0; i < 9; i++) {
System.out.printf("%3s: %s [%s, %s]%n", (i + 1) * k, digits[j][i], j, i);
}
k *= 10;
}
System.out.println(kMul);
String s = "999_999";
System.out.printf("Maximum value (%s):%n", s);
System.out.println(CyrillicConverter.convert(s));
}
}

View File

@@ -0,0 +1,44 @@
package ua.nure.jfn.task3.converter;
import ua.nure.jfn.task3.Utils;
// Maya numerals.
// You can use Google Font: "Noto Sans Mayan Numerals" to see the Mayan digits.
public class MayaConverter {
private static final String[] ar = new String[20];
static {
int mayaZeroHighSurrogate = 0xDEE0;
for (int j = 0; j < 20; j++) {
ar[j] = "\uD834" + (char) (mayaZeroHighSurrogate + j);
}
}
public static String convert(String from) {
int num = Utils.parseInt(from);
String result = "";
if (num == 0)
result = ar[0];
for (; num > 0; num /= 20)
result = ar[num % 20] + result;
return result;
}
public static void main(String[] args) {
System.out.println("All the digits:");
for (int j = 0; j < ar.length; j++) {
System.out.printf("%2s: %s%n", j, ar[j]);
}
System.out.println("~~~");
System.out.println(429);
System.out.println(MayaConverter.convert("429"));
System.out.println("~~~");
System.out.println("100_000");
System.out.println(MayaConverter.convert(String.valueOf("100_000")));
}
}

View File

@@ -0,0 +1,44 @@
package ua.nure.jfn.task3.converter;
import ua.nure.jfn.task3.Utils;
public class PositionalConverter {
public static String convert(String s) {
String[] parts = s.split(":");
int from = Utils.parseInt(parts[0]);
int num = Utils.parseInt(parts[1], from);
int to = Utils.parseInt(parts[2]);
if (num == 0)
return "0";
String result = "";
for (; num > 0; num /= to) {
char c = (char) (num % to);
if (c <= 9) {
c += '0';
} else {
c += 'A' - 10;
}
result = c + result;
}
return result;
}
public static void main(String[] args) {
String s;
s = "10:15:16";
System.out.printf("%s ==> %s%n", s, PositionalConverter.convert(s));
s = "36:XYZ:2";
System.out.printf("%s ==> %s%n", s, PositionalConverter.convert(s));
s = "10:171:36";
System.out.printf("%s ==> %s%n", s, PositionalConverter.convert(s));
}
}

View File

@@ -0,0 +1,70 @@
package ua.nure.jfn.task3.converter;
import ua.nure.jfn.task3.Utils;
// Roman numerals.
public class RomanConverter {
private static final String[] digits = {
"\u216F", // M
"\u216D\u216F", // CM
"\u216E", // D
"\u216D\u216E", // CD
"\u216D", // C
"\u2169\u216D", // XC
"\u216C", // L
"\u2169\u216C", // XL
"\u2169", // X
"\u2160\u2169", // IX
"\u2164", // V
"\u2160\u2164", // IV
"\u2160" // I
};
private static final int[] values = {
1000, // M
900, // CM
500, // D
400, // CD
100, // C
90, // XC
50, // L
40, // XL
10, // X
9, // IX
5, // V
4, // IV
1 // I
};
public static String convert(String str) {
int num = Utils.parseInt(str);
String result = "";
for (int i = 0; i < values.length; i++) {
while (num >= values[i]) {
num -= values[i];
result += digits[i];
}
}
return result.toString();
}
public static void main(String[] args) {
System.out.println("All the digits");
for (int j = 0; j < digits.length; j++) {
System.out.printf("%s: %s%n", digits[j], values[j]);
}
String s;
System.out.println("~~~");
s = "444";
System.out.println(s);
System.out.println(RomanConverter.convert(s));
System.out.println("~~~");
s = "3_999";
System.out.println(s);
System.out.println(RomanConverter.convert(s));
}
}

View File

@@ -0,0 +1,16 @@
package ua.nure.jfn.task3;
import org.junit.jupiter.api.Assertions;
/**
* @author Dmytro Kolesnykov
*/
public class Base {
{
if (ComplianceTest.MAKE_ALL_TESTS_FAILED) {
Assertions.fail("Compliance tests have not been passed", ComplianceTest.CAUSE);
}
}
}

View File

@@ -0,0 +1,122 @@
package ua.nure.jfn.task3;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import spoon.Launcher;
import spoon.SpoonAPI;
import spoon.reflect.declaration.CtType;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.visitor.filter.TypeFilter;
/**
* @author Dmytro Kolesnykov
*/
@Disabled("This test is used as a trigger to fail all the other tests")
class ComplianceTest {
// Assign this option to false to skip the compliance test
// Note, during testing at the stand this option will be turned on!!!
// private static final boolean TURN_TEST_COMPLIANCE_ON = false;
private static final boolean TURN_TEST_COMPLIANCE_ON = true;
public static final boolean MAKE_ALL_TESTS_FAILED;
public static final Throwable CAUSE;
private static final Object EOL = System.lineSeparator();
static {
L: {
try {
if (TURN_TEST_COMPLIANCE_ON) {
initSpoon();
startCompianceTests();
}
} catch (ReflectiveOperationException ex) {
MAKE_ALL_TESTS_FAILED = true;
CAUSE = ex.getCause();
break L;
}
MAKE_ALL_TESTS_FAILED = false;
CAUSE = null;
}
}
private static SpoonAPI spoon;
private static void initSpoon() {
spoon = new Launcher();
spoon.addInputResource("src/main/java/");
spoon.buildModel();
}
private static void startCompianceTests() throws ReflectiveOperationException {
ComplianceTest cTest = new ComplianceTest();
for (Method m : ComplianceTest.class.getDeclaredMethods()) {
if (Modifier.isPrivate(m.getModifiers())) {
continue;
}
Test[] ar = m.getAnnotationsByType(Test.class);
if (ar.length > 0 && m.getAnnotationsByType(Test.class)[0] != null) {
m.invoke(cTest);
}
}
}
///////////////////////////////////////////////////
@Test
void appShouldNotUseForbiddenAPI() throws IOException, URISyntaxException {
URL url = getClass().getResource("forbidden-api-regex.txt");
String regex = Files.readString(Path.of(url.toURI()));
Pattern forbiddenAPIRegex = Pattern.compile(regex.toString());
StringBuilder errorMessage = new StringBuilder();
for (CtType<?> ctType : spoon.getModel().getAllTypes()) {
List<String> forbiddenAPI = ctType.getElements(new TypeFilter<>(CtTypeReference.class))
.stream()
.distinct()
.filter(r -> forbiddenAPIRegex.matcher(r.toString()).matches())
.map(CtTypeReference::getQualifiedName)
.toList();
if (!forbiddenAPI.isEmpty()) {
errorMessage.append(EOL)
.append(ctType.getQualifiedName()).append(": ")
.append(forbiddenAPI);
}
}
if (!errorMessage.isEmpty()) {
fail(() -> "Using of this API is forbidden: " + errorMessage);
}
}
@Test
void shouldBeAppropriateNumberOfPackagesAndClasses() throws IOException, URISyntaxException {
URL url = getClass().getResource("list-of-types.txt");
String expected = Files.readString(Path.of(url.toURI()));
// '\n' character is used for clarity in error message
String actual = spoon.getModel().getAllPackages().stream()
.filter(p -> p.getTypes().size() != 0)
.map(p -> p.getTypes().stream()
.map(CtType::getQualifiedName)
.sorted()
.collect(Collectors.joining("\n")))
.collect(Collectors.joining("\n"));
assertEquals('\n' + expected.trim(), '\n' + actual.trim());
}
}

View File

@@ -0,0 +1,40 @@
package ua.nure.jfn.task3;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
/**
* @author Dmytro Kolesnykov
*/
class Part1Test extends Base {
@ParameterizedTest
@CsvFileSource(delimiter = '|', encoding = "Cp1251", resources = "part1-convert1.csv")
void testConvert1(String inputString, String expectedString) {
String expected = expectedString.replace("~", "\n");
String input = inputString.replace("~", "\n");
String actual = Part1.convert1(input).replaceAll("\r", "");
assertEquals(expected, actual);
}
@ParameterizedTest
@CsvFileSource(delimiter = '|', encoding = "Cp1251", resources = "part1-convert2.csv")
void testConvert2(String inputString, String expectedString) {
String expected = expectedString.replace("~", "\n");
String input = inputString.replace("~", "\n");
String actual = Part1.convert2(input).replaceAll("\r", "");
assertEquals(expected, actual);
}
@ParameterizedTest
@CsvFileSource(delimiter = '|', encoding = "Cp1251", resources = "part1-convert3.csv")
void testConvert3(String inputString, String expectedString) {
String expected = expectedString.replace("~", "\n");
String input = inputString.replace("~", "\n");
String actual = Part1.convert3(input).replaceAll("\r", "");
assertEquals(expected, actual);
}
}

View File

@@ -0,0 +1,23 @@
package ua.nure.jfn.task3;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
/**
* @author Dmytro Kolesnykov
*/
class Part2Test extends Base {
@ParameterizedTest
@CsvFileSource(delimiter = '|', encoding = "Cp1251", resources = "part2.csv")
void testConvert(String inputString, String kString, String expectedString) {
String expected = expectedString != null ? expectedString.replace("~", "\n") : "";
int k = Integer.parseInt(kString);
String input = inputString.replace("~", "\n");
String actual = Part2.convert(input, k).replaceAll("\r", "");
assertEquals(expected, actual);
}
}

View File

@@ -0,0 +1,22 @@
package ua.nure.jfn.task3;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
/**
* @author Dmytro Kolesnykov
*/
class Part3Test extends Base {
@ParameterizedTest
@CsvFileSource(delimiter = '|', encoding = "Cp1251", resources = "part3.csv")
void testConvert(String inputString, String expectedString) {
String expected = expectedString.replace("~", "\n");
String input = inputString.replace("~", "\n");
String actual = Part3.convert(input).replaceAll("\r", "");
assertEquals(expected, actual);
}
}

View File

@@ -0,0 +1,43 @@
package ua.nure.jfn.task3.converter;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
import ua.nure.jfn.task3.Base;
/**
* @author Dmytro Kolesnykov
*/
public class ConverterTest extends Base {
@ParameterizedTest
@CsvFileSource(delimiter = '|', encoding = "UTF-8", resources = "cyrillic.csv")
void testCyrillicConvert(String input, String expected) {
String actual = CyrillicConverter.convert(input);
assertEquals(expected, actual);
}
@ParameterizedTest
@CsvFileSource(delimiter = '|', encoding = "UTF-8", resources = "positional.csv")
void testPositionalConvert(String input, String expected) {
String actual = PositionalConverter.convert(input);
assertEquals(expected, actual);
}
@ParameterizedTest
@CsvFileSource(delimiter = '|', encoding = "UTF-8", resources = "maya.csv")
void testMayanConvert(String input, String expected) {
String actual = MayaConverter.convert(input);
assertEquals(expected, actual);
}
@ParameterizedTest
@CsvFileSource(delimiter = '|', encoding = "UTF-8", resources = "roman.csv")
void testRomanConvert(String input, String expected) {
String actual = RomanConverter.convert(input);
assertEquals(expected, actual);
}
}

View File

@@ -0,0 +1,12 @@
# To see Cyrillic digits you can use 'Consolas' font
1 | а
10 | і
19 | іѳ
20 | к
901 | ца
410 | уі
80_030 | ҂пл
999_999 | ҂ц҂ч҂ѳцчѳ
987_321 | ҂ц҂п҂зтка
100_290 | ҂рсч
1 # To see Cyrillic digits you can use 'Consolas' font
2 1 | а
3 10 | і
4 19 | іѳ
5 20 | к
6 901 | ца
7 410 | уі
8 80_030 | ҂пл
9 999_999 | ҂ц҂ч҂ѳцчѳ
10 987_321 | ҂ц҂п҂зтка
11 100_290 | ҂рсч

View File

@@ -0,0 +1,12 @@
# To see Mayan digits you can use 'BabelStone Mayan Numerals' font
429 | 𝋡𝋡𝋩
100_000 | 𝋬𝋪𝋠𝋠
2147483647 | 𝋡𝋭𝋫𝋡𝋯𝋩𝋢𝋧
1 | 𝋡
202020 | 𝋡𝋥𝋥𝋡𝋠
19 | 𝋳
20 | 𝋡𝋠
3_999 | 𝋩𝋳𝋳
399 | 𝋳𝋳
400 | 𝋡𝋠𝋠
1 # To see Mayan digits you can use 'BabelStone Mayan Numerals' font
2 429 | 𝋡𝋡𝋩
3 100_000 | 𝋬𝋪𝋠𝋠
4 2147483647 | 𝋡𝋭𝋫𝋡𝋯𝋩𝋢𝋧
5 1 | 𝋡
6 202020 | 𝋡𝋥𝋥𝋡𝋠
7 19 | 𝋳
8 20 | 𝋡𝋠
9 3_999 | 𝋩𝋳𝋳
10 399 | 𝋳𝋳
11 400 | 𝋡𝋠𝋠

View File

@@ -0,0 +1,10 @@
10:429:36 | BX
15:10_000:4 | 30113001
10:2147483647:16 | 7FFFFFFF
10:1:36 | 1
3:202020:10 | 546
36:XYZ:2 | 1010101111111011
36:1:2 | 1
2:1:36 | 1
10:36:36 | 10
10:8:8 | 10
1 10:429:36 BX
2 15:10_000:4 30113001
3 10:2147483647:16 7FFFFFFF
4 10:1:36 1
5 3:202020:10 546
6 36:XYZ:2 1010101111111011
7 36:1:2 1
8 2:1:36 1
9 10:36:36 10
10 10:8:8 10

View File

@@ -0,0 +1,12 @@
# To see Roman digits you can use 'Microsoft Sans Serif' font
3_999 |
444 |
949 |
1 |
2949 |
4 |
3_201 |
1003 |
770 |
9 |
1 # To see Roman digits you can use 'Microsoft Sans Serif' font
2 3_999 | ⅯⅯⅯⅭⅯⅩⅭⅠⅩ
3 444 | ⅭⅮⅩⅬⅠⅤ
4 949 | ⅭⅯⅩⅬⅠⅩ
5 1 | Ⅰ
6 2949 | ⅯⅯⅭⅯⅩⅬⅠⅩ
7 4 | ⅠⅤ
8 3_201 | ⅯⅯⅯⅭⅭⅠ
9 1003 | ⅯⅠⅠⅠ
10 770 | ⅮⅭⅭⅬⅩⅩ
11 9 | ⅠⅩ

View File

@@ -0,0 +1,8 @@
(?x)
^
(?:java\.util\.[^.]+)
|
(?:java\.util\.stream\.[^.]+)
|
(?:java\.lang\.(?:Byte|Short|Integer|Long|Float|Double|Character))
$

View File

@@ -0,0 +1,9 @@
ua.nure.jfn.task3.Demo
ua.nure.jfn.task3.Part1
ua.nure.jfn.task3.Part2
ua.nure.jfn.task3.Part3
ua.nure.jfn.task3.Utils
ua.nure.jfn.task3.converter.CyrillicConverter
ua.nure.jfn.task3.converter.MayaConverter
ua.nure.jfn.task3.converter.PositionalConverter
ua.nure.jfn.task3.converter.RomanConverter

View File

@@ -0,0 +1,56 @@
Login;Name;Email
petrenko;Ìàð³ÿ Ïåòðåíêî;petrenko2@mail.com
ivanenko;Áåàòðèññà-Âàëåði ²âàíåíêî;ivanenko@mail.com
obama;Barack Hussein Obama;obama@gmail.com
lennon;John Lennon;lennon@live.com
bush;Äæîðäæ Âîêåð Áóø;bush@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LastName;Email
Ïåòðåíêî;petrenko2@mail.com
²âàíåíêî;ivanenko@mail.com
Obama;obama@gmail.com
Lennon;lennon@live.com
Áóø;bush@gmail.com
====================================
Login;Name;Email
petrenko;Ìàð³ÿ Ïåòðåíêî;petrenko2@mail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LastName;Email
Ïåòðåíêî;petrenko2@mail.com
====================================
Login;Name;Email
petrenko;Ìàð³ÿ Ïåòðåíêî;petrenko2@mail.com
ivanenko;Áåàòðèññà ²âàííà ²âàíåíêî;ivanenko@mail.com
obama;Barack Hussein Obama;obama@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LastName;Email
Ïåòðåíêî;petrenko2@mail.com
²âàíåíêî;ivanenko@mail.com
Obama;obama@gmail.com
====================================
Login;Name;Email
obama;Barack Hussein Obama;obama@gmail.com
obama;Barack Hussein Obama;obama@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LastName;Email
Obama;obama@gmail.com
Obama;obama@gmail.com
====================================
Login;Name;Email
a;b c d;e@f.g
h;i j k;l@n.n
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LastName;Email
d;e@f.g
k;l@n.n
====================================

View File

@@ -0,0 +1,5 @@
Login;Name;Email~petrenko;Ìàð³ÿ Ïåòðåíêî;petrenko2@mail.com~ivanenko;Áåàòðèññà-Âàëåði ²âàíåíêî;ivanenko@mail.com~obama;Barack Hussein Obama;obama@gmail.com~lennon;John Lennon;lennon@live.com~bush;Äæîðäæ Âîêåð Áóø;bush@gmail.com|LastName;Email~Ïåòðåíêî;petrenko2@mail.com~²âàíåíêî;ivanenko@mail.com~Obama;obama@gmail.com~Lennon;lennon@live.com~Áóø;bush@gmail.com
Login;Name;Email~petrenko;Ìàð³ÿ Ïåòðåíêî;petrenko2@mail.com|LastName;Email~Ïåòðåíêî;petrenko2@mail.com
Login;Name;Email~petrenko;Ìàð³ÿ Ïåòðåíêî;petrenko2@mail.com~ivanenko;Áåàòðèññà ²âàííà ²âàíåíêî;ivanenko@mail.com~obama;Barack Hussein Obama;obama@gmail.com|LastName;Email~Ïåòðåíêî;petrenko2@mail.com~²âàíåíêî;ivanenko@mail.com~Obama;obama@gmail.com
Login;Name;Email~obama;Barack Hussein Obama;obama@gmail.com~obama;Barack Hussein Obama;obama@gmail.com|LastName;Email~Obama;obama@gmail.com~Obama;obama@gmail.com
Login;Name;Email~a;b c d;e@f.g~h;i j k;l@n.n|LastName;Email~d;e@f.g~k;l@n.n
1 Login;Name;Email~petrenko;Ìàð³ÿ Ïåòðåíêî;petrenko2@mail.com~ivanenko;Áåàòðèññà-Âàëåði ²âàíåíêî;ivanenko@mail.com~obama;Barack Hussein Obama;obama@gmail.com~lennon;John Lennon;lennon@live.com~bush;Äæîðäæ Âîêåð Áóø;bush@gmail.com LastName;Email~Ïåòðåíêî;petrenko2@mail.com~²âàíåíêî;ivanenko@mail.com~Obama;obama@gmail.com~Lennon;lennon@live.com~Áóø;bush@gmail.com
2 Login;Name;Email~petrenko;Ìàð³ÿ Ïåòðåíêî;petrenko2@mail.com LastName;Email~Ïåòðåíêî;petrenko2@mail.com
3 Login;Name;Email~petrenko;Ìàð³ÿ Ïåòðåíêî;petrenko2@mail.com~ivanenko;Áåàòðèññà ²âàííà ²âàíåíêî;ivanenko@mail.com~obama;Barack Hussein Obama;obama@gmail.com LastName;Email~Ïåòðåíêî;petrenko2@mail.com~²âàíåíêî;ivanenko@mail.com~Obama;obama@gmail.com
4 Login;Name;Email~obama;Barack Hussein Obama;obama@gmail.com~obama;Barack Hussein Obama;obama@gmail.com LastName;Email~Obama;obama@gmail.com~Obama;obama@gmail.com
5 Login;Name;Email~a;b c d;e@f.g~h;i j k;l@n.n LastName;Email~d;e@f.g~k;l@n.n

View File

@@ -0,0 +1,56 @@
Login;Name;Email
petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com
ivanenko;Áåàòğèññà-Âàëåği ²âàíåíêî;ivanenko@mail.com
obama;Barack Hussein Obama;obama@gmail.com
lennon;John Lennon;lennon@live.com
bush;Äæîğäæ Âîêåğ Áóø;bush@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LastName;MiddleName;FirstName
Ïåòğåíêî;;Ìàğ³ÿ
²âàíåíêî;;Áåàòğèññà-Âàëåği
Obama;Hussein;Barack
Lennon;;John
Áóø;Âîêåğ;Äæîğäæ
====================================
Login;Name;Email
petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LastName;MiddleName;FirstName
Ïåòğåíêî;;Ìàğ³ÿ
====================================
Login;Name;Email
petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com
ivanenko;Áåàòğèññà ²âàííà ²âàíåíêî;ivanenko@mail.com
obama;Barack Hussein Obama;obama@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LastName;MiddleName;FirstName
Ïåòğåíêî;;Ìàğ³ÿ
²âàíåíêî;²âàííà;Áåàòğèññà
Obama;Hussein;Barack
====================================
Login;Name;Email
obama;Barack Hussein Obama;obama@gmail.com
obama;Barack Hussein Obama;obama@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LastName;MiddleName;FirstName
Obama;Hussein;Barack
Obama;Hussein;Barack
====================================
Login;Name;Email
a;b c d;e@f.g
h;i j k;l@n.n
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LastName;MiddleName;FirstName
d;c;b
k;j;i
====================================

View File

@@ -0,0 +1,5 @@
Login;Name;Email~petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com~ivanenko;Áåàòğèññà-Âàëåği ²âàíåíêî;ivanenko@mail.com~obama;Barack Hussein Obama;obama@gmail.com~lennon;John Lennon;lennon@live.com~bush;Äæîğäæ Âîêåğ Áóø;bush@gmail.com|LastName;MiddleName;FirstName~Ïåòğåíêî;;Ìàğ³ÿ~²âàíåíêî;;Áåàòğèññà-Âàëåği~Obama;Hussein;Barack~Lennon;;John~Áóø;Âîêåğ;Äæîğäæ
Login;Name;Email~petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com|LastName;MiddleName;FirstName~Ïåòğåíêî;;Ìàğ³ÿ
Login;Name;Email~petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com~ivanenko;Áåàòğèññà ²âàííà ²âàíåíêî;ivanenko@mail.com~obama;Barack Hussein Obama;obama@gmail.com|LastName;MiddleName;FirstName~Ïåòğåíêî;;Ìàğ³ÿ~²âàíåíêî;²âàííà;Áåàòğèññà~Obama;Hussein;Barack
Login;Name;Email~obama;Barack Hussein Obama;obama@gmail.com~obama;Barack Hussein Obama;obama@gmail.com|LastName;MiddleName;FirstName~Obama;Hussein;Barack~Obama;Hussein;Barack
Login;Name;Email~a;b c d;e@f.g~h;i j k;l@n.n|LastName;MiddleName;FirstName~d;c;b~k;j;i
1 Login;Name;Email~petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com~ivanenko;Áåàòğèññà-Âàëåği ²âàíåíêî;ivanenko@mail.com~obama;Barack Hussein Obama;obama@gmail.com~lennon;John Lennon;lennon@live.com~bush;Äæîğäæ Âîêåğ Áóø;bush@gmail.com LastName;MiddleName;FirstName~Ïåòğåíêî;;Ìàğ³ÿ~²âàíåíêî;;Áåàòğèññà-Âàëåği~Obama;Hussein;Barack~Lennon;;John~Áóø;Âîêåğ;Äæîğäæ
2 Login;Name;Email~petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com LastName;MiddleName;FirstName~Ïåòğåíêî;;Ìàğ³ÿ
3 Login;Name;Email~petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com~ivanenko;Áåàòğèññà ²âàííà ²âàíåíêî;ivanenko@mail.com~obama;Barack Hussein Obama;obama@gmail.com LastName;MiddleName;FirstName~Ïåòğåíêî;;Ìàğ³ÿ~²âàíåíêî;²âàííà;Áåàòğèññà~Obama;Hussein;Barack
4 Login;Name;Email~obama;Barack Hussein Obama;obama@gmail.com~obama;Barack Hussein Obama;obama@gmail.com LastName;MiddleName;FirstName~Obama;Hussein;Barack~Obama;Hussein;Barack
5 Login;Name;Email~a;b c d;e@f.g~h;i j k;l@n.n LastName;MiddleName;FirstName~d;c;b~k;j;i

View File

@@ -0,0 +1,51 @@
Login;Name;Email
petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com
ivanenko;Áåàòğèññà-Âàëåği ²âàíåíêî;ivanenko@mail.com
obama;Barack Hussein Obama;obama@gmail.com
lennon;John Lennon;lennon@live.com
bush;Äæîğäæ Âîêåğ Áóø;bush@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ïåòğåíêî Ìàğ³ÿ petrenko
²âàíåíêî Áåàòğèññà-Âàëåği ivanenko
Obama Barack Hussein obama
Lennon John lennon
Áóø Äæîğäæ Âîêåğ bush
====================================
Login;Name;Email
petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ïåòğåíêî Ìàğ³ÿ petrenko
====================================
Login;Name;Email
petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com
ivanenko;Áåàòğèññà ²âàííà ²âàíåíêî;ivanenko@mail.com
obama;Barack Hussein Obama;obama@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ïåòğåíêî Ìàğ³ÿ petrenko
²âàíåíêî Áåàòğèññà ²âàííà ivanenko
Obama Barack Hussein obama
====================================
Login;Name;Email
obama;Barack Hussein Obama;obama@gmail.com
obama;Barack Hussein Obama;obama@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Obama Barack Hussein obama
Obama Barack Hussein obama
====================================
Login;Name;Email
a;b c d;e@f.g
h;i j k;l@n.n
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
d b c a
k i j h
====================================

View File

@@ -0,0 +1,5 @@
Login;Name;Email~petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com~ivanenko;Áåàòğèññà-Âàëåği ²âàíåíêî;ivanenko@mail.com~obama;Barack Hussein Obama;obama@gmail.com~lennon;John Lennon;lennon@live.com~bush;Äæîğäæ Âîêåğ Áóø;bush@gmail.com|Ïåòğåíêî Ìàğ³ÿ petrenko~²âàíåíêî Áåàòğèññà-Âàëåği ivanenko~Obama Barack Hussein obama ~Lennon John lennon ~Áóø Äæîğäæ Âîêåğ bush
Login;Name;Email~petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com|Ïåòğåíêî Ìàğ³ÿ petrenko
Login;Name;Email~petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com~ivanenko;Áåàòğèññà ²âàííà ²âàíåíêî;ivanenko@mail.com~obama;Barack Hussein Obama;obama@gmail.com|Ïåòğåíêî Ìàğ³ÿ petrenko~²âàíåíêî Áåàòğèññà ²âàííà ivanenko~Obama Barack Hussein obama
Login;Name;Email~obama;Barack Hussein Obama;obama@gmail.com~obama;Barack Hussein Obama;obama@gmail.com|Obama Barack Hussein obama~Obama Barack Hussein obama
Login;Name;Email~a;b c d;e@f.g~h;i j k;l@n.n|d b c a~k i j h
1 Login;Name;Email~petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com~ivanenko;Áåàòğèññà-Âàëåği ²âàíåíêî;ivanenko@mail.com~obama;Barack Hussein Obama;obama@gmail.com~lennon;John Lennon;lennon@live.com~bush;Äæîğäæ Âîêåğ Áóø;bush@gmail.com Ïåòğåíêî Ìàğ³ÿ petrenko~²âàíåíêî Áåàòğèññà-Âàëåği ivanenko~Obama Barack Hussein obama ~Lennon John lennon ~Áóø Äæîğäæ Âîêåğ bush
2 Login;Name;Email~petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com Ïåòğåíêî Ìàğ³ÿ petrenko
3 Login;Name;Email~petrenko;Ìàğ³ÿ Ïåòğåíêî;petrenko2@mail.com~ivanenko;Áåàòğèññà ²âàííà ²âàíåíêî;ivanenko@mail.com~obama;Barack Hussein Obama;obama@gmail.com Ïåòğåíêî Ìàğ³ÿ petrenko~²âàíåíêî Áåàòğèññà ²âàííà ivanenko~Obama Barack Hussein obama
4 Login;Name;Email~obama;Barack Hussein Obama;obama@gmail.com~obama;Barack Hussein Obama;obama@gmail.com Obama Barack Hussein obama~Obama Barack Hussein obama
5 Login;Name;Email~a;b c d;e@f.g~h;i j k;l@n.n d b c a~k i j h

View File

@@ -0,0 +1,48 @@
When I was younger, so much younger than today
I never needed anybody's help in any way
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1: I
====================================
When I was younger, so much younger than today
I never needed anybody's help in any way
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2: so in
====================================
When I was younger, so much younger than today
I never needed anybody's help in any way
Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³. Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5: today never Ëÿãຠäåíü. íà䳿 íî÷³.
====================================
When I was younger, so much younger than today
I never needed anybody's help in any way
Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³. Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6: needed â³ääຠâîãí³, ëàìïè.
====================================
When I was younger, so much younger than today
I never needed anybody's help in any way
Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³. Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8: younger,
====================================

View File

@@ -0,0 +1,9 @@
a b a abc bca abc abcde abcdf|1|1: a b
a b a abc bca abc abcde abcdf|2|2: abc bca
a b a abc bca abc abcde abcdf|3|3: abcde abcdf
a b a abc bca abc abcde abcdf|4|
When I was younger, so much younger than today~I never needed anybody's help in any way|1|1: I
When I was younger, so much younger than today~I never needed anybody's help in any way|2|2: so in
When I was younger, so much younger than today~I never needed anybody's help in any way~Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³. Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.|5|5: today never Ëÿãຠäåíü. íà䳿 íî÷³.
When I was younger, so much younger than today~I never needed anybody's help in any way~Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³. Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.|6|6: needed â³ääຠâîãí³, ëàìïè.
When I was younger, so much younger than today~I never needed anybody's help in any way~Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³. Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.|8|8: younger,
1 a b a abc bca abc abcde abcdf 1 1: a b
2 a b a abc bca abc abcde abcdf 2 2: abc bca
3 a b a abc bca abc abcde abcdf 3 3: abcde abcdf
4 a b a abc bca abc abcde abcdf 4
5 When I was younger, so much younger than today~I never needed anybody's help in any way 1 1: I
6 When I was younger, so much younger than today~I never needed anybody's help in any way 2 2: so in
7 When I was younger, so much younger than today~I never needed anybody's help in any way~Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³. Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè. 5 5: today never Ëÿãຠäåíü. íà䳿 íî÷³.
8 When I was younger, so much younger than today~I never needed anybody's help in any way~Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³. Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè. 6 6: needed â³ääຠâîãí³, ëàìïè.
9 When I was younger, so much younger than today~I never needed anybody's help in any way~Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³. Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè. 8 8: younger,

View File

@@ -0,0 +1,54 @@
when I was younger younger than today was
I never needed needed never never was I was
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
when I was younger YOUNGER than today WAS
i never needed NEEDED NEVER never was I WAS
====================================
Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³.
Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè.
Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.
Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.
Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè.
Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³.
Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè.
Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.
òÀÌ ÂÎÃͲ, ÿÑÊÐÀ² ÁËÈÙÓÒÜ ËÀÌÏÈ.
ðÎÁ²ÒÍÈÊÈ çÀÌÎÐÈËÈÑÜ ÏÐÀÖÞÂÀÒÈ.
Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè.
====================================
asdf adsf asdfa sd fa sdf adfa sdfa
asdfas dfasd
asd f
asdfasdfasdf
asdf asdf asdf asdf a sdf
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
asdf adsf asdfa sd fa sdf adfa sdfa
asdfas dfasd
asd f
asdfasdfasdf
ASDF asdf ASDF asdf a SDF
====================================
a b c a b c a b c
b c b c a b c a
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a b c A B C a b c
B C b c A B C a
====================================
éöóê éóöê éóöê éöóê éóöê
éóöê éöóê éöóê éóöê éóöê
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
éöóê éóöê ÉÓÖÊ ÉÖÓÊ éóöê
ÉÓÖÊ éöóê ÉÖÓÊ éóöê ÉÓÖÊ
====================================

View File

@@ -0,0 +1,5 @@
when I was younger younger than today was~I never needed needed never never was I was|when I was younger YOUNGER than today WAS~i never needed NEEDED NEVER never was I WAS
Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³. ~Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. ~Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.~Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.~Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. ~Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. |Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³. ~Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. ~Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.~òÀÌ ÂÎÃͲ, ÿÑÊÐÀ² ÁËÈÙÓÒÜ ËÀÌÏÈ.~ðÎÁ²ÒÍÈÊÈ çÀÌÎÐÈËÈÑÜ ÏÐÀÖÞÂÀÒÈ. ~Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè.
asdf adsf asdfa sd fa sdf adfa sdfa ~asdfas dfasd~asd f~asdfasdfasdf~asdf asdf asdf asdf a sdf |asdf adsf asdfa sd fa sdf adfa sdfa ~asdfas dfasd~asd f~asdfasdfasdf~ASDF asdf ASDF asdf a SDF
a b c a b c a b c~b c b c a b c a |a b c A B C a b c~B C b c A B C a
éöóê éóöê éóöê éöóê éóöê~éóöê éöóê éöóê éóöê éóöê |éöóê éóöê ÉÓÖÊ ÉÖÓÊ éóöê~ÉÓÖÊ éöóê ÉÖÓÊ éóöê ÉÓÖÊ
1 when I was younger younger than today was~I never needed needed never never was I was when I was younger YOUNGER than today WAS~i never needed NEEDED NEVER never was I WAS
2 Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³. ~Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. ~Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.~Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.~Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. ~Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. Ëÿãຠäåíü. ³í â³ääຠñâî¿ íà䳿 íî÷³. ~Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè. ~Òàì âîãí³, ßñêðàâ³ áëèùóòü ëàìïè.~òÀÌ ÂÎÃͲ, ÿÑÊÐÀ² ÁËÈÙÓÒÜ ËÀÌÏÈ.~ðÎÁ²ÒÍÈÊÈ çÀÌÎÐÈËÈÑÜ ÏÐÀÖÞÂÀÒÈ. ~Ðîá³òíèêè Çàìîðèëèñü ïðàöþâàòè.
3 asdf adsf asdfa sd fa sdf adfa sdfa ~asdfas dfasd~asd f~asdfasdfasdf~asdf asdf asdf asdf a sdf asdf adsf asdfa sd fa sdf adfa sdfa ~asdfas dfasd~asd f~asdfasdfasdf~ASDF asdf ASDF asdf a SDF
4 a b c a b c a b c~b c b c a b c a a b c A B C a b c~B C b c A B C a
5 éöóê éóöê éóöê éöóê éóöê~éóöê éöóê éöóê éóöê éóöê éöóê éóöê ÉÓÖÊ ÉÖÓÊ éóöê~ÉÓÖÊ éöóê ÉÖÓÊ éóöê ÉÓÖÊ

Binary file not shown.

202
semester-4/ОПJа/lb-4/task4/.gitignore vendored Normal file
View File

@@ -0,0 +1,202 @@
/target/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
# Created by https://www.gitignore.io/api/git,java,maven,eclipse,windows
### Eclipse ###
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
### Eclipse Patch ###
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
# Annotation Processing
.apt_generated
.sts4-cache/
### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig
# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Some additional ignores (sort later)
*.DS_Store
*.sw?
.#*
*#
*~
.classpath
.project
.settings
bin
build
target
dependency-reduced-pom.xml
*.sublime-*
/scratch
.gradle
README.html
*.iml
.idea
.exercism

View File

@@ -0,0 +1,2 @@
set JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
mvn clean test

View File

@@ -0,0 +1,2 @@
JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
mvn clean test

View File

@@ -0,0 +1,5 @@
Сонце гріє лице,
Радує це!
Ooh
What more
can I say

View File

@@ -0,0 +1,3 @@
asd asdf asd asdf
asdf 43 asdsf 43 43 434
stop

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ua.nure.jfn</groupId>
<artifactId>task4</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
<junit5.version>5.12.0</junit5.version>
<surefire.version>3.5.3</surefire.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>task4</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@@ -0,0 +1,37 @@
package ua.nure.jfn.task4;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
public class Demo {
public static void main(String[] args) {
String symin;
InputStream stdin = System.in;
// Part1
symin = "asdf\n" +
"Latn\n" +
"Cyrl\n" +
"Stop\n";
System.setIn(new ByteArrayInputStream(symin.getBytes(StandardCharsets.UTF_8)));
Part1.main(args);
// ~Part1
// Part3
symin = "table en\n" +
"table uk\n" +
"apple en\n" +
"asfd asdf\n" +
"apple uk\n" +
"stop\n";
System.setIn(new ByteArrayInputStream(symin.getBytes(StandardCharsets.UTF_8)));
Part3.main(args);
// ~Part3
System.setIn(stdin);
}
}

View File

@@ -0,0 +1,61 @@
package ua.nure.jfn.task4;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Part1 {
private static final String PATH = "part1.txt";
private static final Pattern LATN_PATTERN = Pattern.compile("\\b\\p{IsLatin}+\\b",
Pattern.UNICODE_CHARACTER_CLASS);
private static final Pattern CYRL_PATTERN = Pattern.compile("\\b\\p{IsCyrillic}+\\b",
Pattern.UNICODE_CHARACTER_CLASS);
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String fileContent = null;
try {
fileContent = new String(Files.readAllBytes(Paths.get(PATH)));
} catch (IOException ex) {
ex.printStackTrace();
scanner.close();
return;
}
String result;
String input;
while (scanner.hasNextLine()) {
input = scanner.nextLine();
if (input.equalsIgnoreCase("stop")) {
break;
}
if (input.equals("Latn")) {
result = extractWords(fileContent, LATN_PATTERN);
} else if (input.equals("Cyrl")) {
result = extractWords(fileContent, CYRL_PATTERN);
} else {
result = "Incorrect input";
}
System.out.printf("%s: %s\n", input, result);
}
scanner.close();
}
private static String extractWords(String text, Pattern pattern) {
String words = "";
Matcher matcher = pattern.matcher(text);
while (matcher.find())
words += " " + matcher.group();
return words.trim();
}
}

View File

@@ -0,0 +1,26 @@
package ua.nure.jfn.task4;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
public class Part2 {
public static void main(String[] args) {
String symin = "asdf\n" +
"asdf\n" +
"fdsa\n" +
"Stop\n";
InputStream stdin = System.in;
try {
System.setIn(new ByteArrayInputStream(symin.getBytes(StandardCharsets.UTF_8)));
WordContainer.main(args);
} finally {
System.setIn(stdin);
}
}
}

View File

@@ -0,0 +1,29 @@
package ua.nure.jfn.task4;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.Scanner;
public class Part3 {
private static final String BASE_NAME = "resources";
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String input;
while (scanner.hasNextLine()) {
input = scanner.nextLine();
if (input.equalsIgnoreCase("stop")) {
break;
}
String[] parts = input.split(" ");
Locale locale = new Locale(parts[1]);
ResourceBundle bundle = ResourceBundle.getBundle(BASE_NAME, locale);
System.out.println(bundle.getString(parts[0]));
}
}
}

View File

@@ -0,0 +1,110 @@
package ua.nure.jfn.task4;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class Part4 {
private static final Path INPUT_FILE = Paths.get("part4.txt");
private static final Path OUTPUT_FILE = Paths.get("part4_sorted.txt");
private static final int NUM_INTEGERS = 10;
private static final int MAX_VALUE = 50;
public static void main(String[] args) {
List<Integer> nums;
if (!Files.exists(INPUT_FILE)) {
Random random = new Random();
nums = new ArrayList<Integer>(NUM_INTEGERS);
for (int i = 0; i < NUM_INTEGERS; i++) {
nums.add(random.nextInt(MAX_VALUE + 1));
}
if (!tryWriteNums(INPUT_FILE, nums)) {
return;
}
}
nums = tryReadNums(INPUT_FILE);
if (nums == null) {
return;
}
System.out.printf("input ==> %s\n", joinInts(nums));
nums = sortDedup(nums);
if (!tryWriteNums(OUTPUT_FILE, nums)) {
return;
}
System.out.printf("output ==> %s\n", joinInts(nums));
}
private static List<Integer> sortDedup(List<Integer> nums) {
for (int i = 0; i < nums.size() - 1; i++) {
for (int j = 0; j < nums.size() - i - 1; j++) {
int a = nums.get(j);
int b = nums.get(j + 1);
if (a > b) {
nums.set(j, b);
nums.set(j + 1, a);
}
}
}
List<Integer> dedup = new ArrayList<Integer>();
for (int num : nums) {
if (dedup.indexOf(num) == -1)
dedup.add(num);
}
return dedup;
}
private static boolean tryWriteNums(Path path, List<Integer> nums) {
try {
String s = "";
for (int i = 0; i < nums.size(); i++) {
s += " " + nums.get(i);
}
Files.write(path, s.trim().getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
return false;
}
return true;
}
private static List<Integer> tryReadNums(Path path) {
List<Integer> nums = new ArrayList<Integer>(NUM_INTEGERS);
try {
String content = Files.readString(path);
for (String s : content.trim().split(" ")) {
nums.add(Integer.parseInt(s));
}
} catch (Exception e) {
return null;
}
return nums;
}
private static String joinInts(Iterable<Integer> numbers) {
String result = "";
for (int num : numbers) {
result += " " + num;
}
return result.trim();
}
}

View File

@@ -0,0 +1,25 @@
package ua.nure.jfn.task4;
public class Part5 {
private static final String SEPARATOR = "~~~~~~~";
public static void main(String[] args) {
Tree<Integer> tree = new Tree<>();
System.out.println(tree.add(3));
System.out.println(tree.add(3));
System.out.println(SEPARATOR);
tree.add(new Integer[] { 1, 2, 6, 4, 7, 0, 5 });
tree.print();
System.out.println(SEPARATOR);
System.out.println(tree.remove(5));
System.out.println(tree.remove(5));
System.out.println(SEPARATOR);
tree.print();
}
}

View File

@@ -0,0 +1,194 @@
package ua.nure.jfn.task4;
public class Tree<E extends Comparable<E>> {
private Node<E> root;
private int size;
public Tree() {
root = null;
size = 0;
}
public boolean add(E element) {
if (element == null) {
return false;
}
int oldSize = size;
root = addRecursive(root, element);
return size > oldSize;
}
private Node<E> addRecursive(Node<E> node, E element) {
if (node == null) {
size++;
return new Node<>(element);
}
int comparison = element.compareTo(node.data);
if (comparison < 0) {
node.left = addRecursive(node.left, element);
} else if (comparison > 0) {
node.right = addRecursive(node.right, element);
}
return node;
}
public void add(E[] elements) {
if (elements == null) {
throw new IllegalArgumentException("Array cannot be null");
}
for (E e : elements) {
if (e != null) {
add(e);
}
}
}
public boolean remove(E element) {
if (element == null) {
return false;
}
int oldSize = size;
root = removeRecursive(root, element);
return size < oldSize;
}
private Node<E> removeRecursive(Node<E> node, E element) {
if (node == null) {
return null;
}
int comparison = element.compareTo(node.data);
if (comparison < 0) {
node.left = removeRecursive(node.left, element);
} else if (comparison > 0) {
node.right = removeRecursive(node.right, element);
} else {
size--;
if (node.left == null && node.right == null) {
return null;
}
if (node.left == null) {
return node.right;
}
if (node.right == null) {
return node.left;
}
Node<E> successor = findMin(node.right);
node.data = successor.data;
node.right = removeRecursive(node.right, successor.data);
size++;
}
return node;
}
private Node<E> findMin(Node<E> node) {
while (node.left != null) {
node = node.left;
}
return node;
}
public boolean contains(E element) {
if (element == null) {
return false;
}
return containsRecursive(root, element);
}
private boolean containsRecursive(Node<E> node, E element) {
if (node == null) {
return false;
}
int comparison = element.compareTo(node.data);
if (comparison == 0) {
return true;
} else if (comparison < 0) {
return containsRecursive(node.left, element);
} else {
return containsRecursive(node.right, element);
}
}
public int size() {
return size;
}
public void clear() {
root = null;
size = 0;
}
public void print() {
if (root == null) {
return;
}
String pad = " ".repeat(root.width());
if (root.left != null) {
root.left.print(pad, "", false);
}
System.out.printf("%s%s\n", root.data, root.pointer());
if (root.right != null) {
root.right.print(pad, "", true);
}
}
private static class Node<E> {
E data;
Node<E> left;
Node<E> right;
Node(E data) {
this.data = data;
this.left = null;
this.right = null;
}
int width() {
return data.toString().length();
}
String pointer() {
if (right != null && left != null) {
return "";
} else if (right != null) {
return "";
} else if (left != null) {
return "";
} else {
return "";
}
}
public void print(String prev, String handle, boolean nested) {
String pad = " ".repeat(width());
String ptr = pointer();
if (left != null) {
left.print(prev + (nested ? "" : " ") + pad, "", false);
}
System.out.printf("%s%s%s%s\n", prev, handle, data, ptr);
if (right != null) {
right.print(prev + (!nested ? "" : " ") + pad, "", true);
}
}
}
}

View File

@@ -0,0 +1,61 @@
package ua.nure.jfn.task4;
import java.util.Objects;
public class Word implements Comparable<Word> {
private String content;
private int frequency;
public Word(String content) {
this.content = content;
this.frequency = 1;
}
public String getContent() {
return content;
}
public int getFrequency() {
return frequency;
}
public void incrementFrequency() {
this.frequency++;
}
@Override
public boolean equals(Object o) {
if (o == null) {
return false;
}
if (this == o) {
return true;
}
Word word = (Word) o;
return content.equals(word.content);
}
@Override
public int hashCode() {
return Objects.hash(content);
}
@Override
public String toString() {
return content + " : " + frequency;
}
@Override
public int compareTo(Word other) {
int frequencyComparison = Integer.compare(this.frequency, other.frequency);
if (frequencyComparison != 0) {
return frequencyComparison;
}
return this.content.compareTo(other.content);
}
}

View File

@@ -0,0 +1,56 @@
package ua.nure.jfn.task4;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class WordContainer {
private static Pattern WORD_PATTERN = Pattern.compile("\\S+");
private ArrayList<Word> words = new ArrayList<>();
public static void main(String[] args) {
WordContainer container = new WordContainer();
container.readAndProcessInput();
container.printWords();
}
private void readAndProcessInput() {
Scanner scanner = new Scanner(System.in);
String input;
outer: while (scanner.hasNextLine()) {
input = scanner.nextLine();
Matcher matcher = WORD_PATTERN.matcher(input);
while (matcher.find()) {
String wordContent = matcher.group();
if (wordContent.equalsIgnoreCase("stop"))
break outer;
addWord(wordContent);
}
}
scanner.close();
}
private void addWord(String content) {
Word newWord = new Word(content);
int i = words.indexOf(newWord);
if (i == -1) {
words.add(newWord);
} else {
words.get(i).incrementFrequency();
}
}
private void printWords() {
words.sort(null);
for (Word word : words)
System.out.println(word);
}
}

View File

@@ -0,0 +1,2 @@
table = table
apple = apple

View File

@@ -0,0 +1,2 @@
table = \u0441\u0442\u0456\u043b
apple = \u044f\u0431\u043b\u0443\u043a\u043e

View File

@@ -0,0 +1,67 @@
package ua.nure.jfn.task4;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
/**
* @author Dmytro Kolesnykov
*/
public class Part1Test {
private static final InputStream STD_IN = System.in;
private static final PrintStream STD_OUT = System.out;
private static final String ENCODING = "UTF-8";
private static final String EOL_CHAR = "~";
private static final String[] EMPTY_ARGS = {};
private static final String INPUT_FILE = "part1.txt";
private static final String EOL = System.lineSeparator();
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
private final PrintStream out = new PrintStream(baos);
private static String toMultiline(String line) {
return line.replaceAll(EOL_CHAR, EOL).trim();
}
@ParameterizedTest
@CsvFileSource(resources = "part1.csv", delimiter = ';')
void part1(String data, String consoleInput, String expectedLine) throws Exception {
String expected = toMultiline(expectedLine);
String input = toMultiline(consoleInput);
byte[] buf = input.getBytes(ENCODING);
ByteArrayInputStream bais = new ByteArrayInputStream(buf);
System.setOut(out);
System.setIn(bais);
String actual = "";
byte[] content = null;
try {
content = Utils.getContent(INPUT_FILE);
Utils.saveContent(INPUT_FILE, toMultiline(data).getBytes(ENCODING));
Part1.main(EMPTY_ARGS);
out.flush();
actual = baos.toString();
} finally {
System.setOut(STD_OUT);
System.setIn(STD_IN);
Utils.saveContent(INPUT_FILE, content);
}
assertEquals(expected.trim(), actual.trim());
}
}

View File

@@ -0,0 +1,53 @@
package ua.nure.jfn.task4;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
/**
* @author Dmytro Kolesnykov
*/
public class Part2Test {
private static final InputStream STD_IN = System.in;
private static final PrintStream STD_OUT = System.out;
private static final String TEST_DATA_FILE_ENCODINE = "UTF-8";
private static final String EOL_CHAR = "~";
private static final String[] EMPTY_ARGS = {};
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
private final PrintStream out = new PrintStream(baos);
@ParameterizedTest
@CsvFileSource(resources = "part2.csv", delimiter = ';')
void part2(String inputLine, String expectedLine) throws Exception {
String input = inputLine.replace(EOL_CHAR, System.lineSeparator());
String expected = expectedLine.replace(EOL_CHAR, System.lineSeparator());
byte[] buf = input.getBytes(TEST_DATA_FILE_ENCODINE);
ByteArrayInputStream bais = new ByteArrayInputStream(buf);
System.setOut(out);
System.setIn(bais);
try {
WordContainer.main(EMPTY_ARGS);
out.flush();
String actual = baos.toString();
assertEquals(expected.trim(), actual.trim());
} finally {
System.setOut(STD_OUT);
System.setIn(STD_IN);
}
}
}

View File

@@ -0,0 +1,111 @@
package ua.nure.jfn.task4;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
/**
* @author Dmytro Kolesnykov
*/
public class Part3Test {
private static final InputStream STD_IN = System.in;
private static final PrintStream STD_OUT = System.out;
private static final String TEST_DATA_FILE_ENCODINE = "UTF-8";
private static final String EOL_CHAR = "~";
private static final String[] EMPTY_ARGS = {};
private static final String EOL = System.lineSeparator();
private static final String BASE_NAME = "resources";
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
private final PrintStream out = new PrintStream(baos);
private static String toMultiline(String line) {
return line.replaceAll(EOL_CHAR, EOL).trim();
}
private static String removeCR(String s) {
return s.replaceAll("\r?", "");
}
private static final URI classPathURI;
static {
try {
classPathURI = Part3.class.getProtectionDomain().getCodeSource().getLocation().toURI();
} catch (URISyntaxException ex) {
throw new IllegalStateException(ex);
}
}
@ParameterizedTest
@CsvFileSource(resources = "part3.csv", delimiter = ';')
void part3(String defaultLocale, String localesString, String consoleInput, String expectedLine) throws Exception {
ResourceBundle.clearCache();
Locale.setDefault(new Locale(defaultLocale));
try (DirectoryStream<Path> stream = Files.newDirectoryStream(Path.of(classPathURI))) {
for (Path p : stream) {
if (p.toString().endsWith(".properties")) {
Files.delete(p);
}
}
}
Path classPath = Paths.get(classPathURI);
List<String> locales = Arrays.asList(localesString.trim().split(" "));
String actual = "";
InputStream is = null;
try {
for (String locale : locales) {
String bundleName = BASE_NAME + '_' + locale + ".properties";
is = getClass().getClassLoader().getResourceAsStream(locale + ".props");
try (OutputStream out = new FileOutputStream(new File(classPath.toString(), bundleName))) {
is.transferTo(out);
is.close();
}
}
String input = toMultiline(consoleInput);
byte[] buf = input.getBytes(TEST_DATA_FILE_ENCODINE);
ByteArrayInputStream bais = new ByteArrayInputStream(buf);
System.setOut(out);
System.setIn(bais);
Part3.main(EMPTY_ARGS);
out.flush();
actual = baos.toString();
} finally {
System.setOut(STD_OUT);
System.setIn(STD_IN);
}
assertEquals(removeCR(toMultiline(expectedLine)).trim(), removeCR(actual).trim());
}
}

View File

@@ -0,0 +1,65 @@
package ua.nure.jfn.task4;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
/**
* @author Dmytro Kolesnykov
*/
public class Part4Test {
private static final InputStream STD_IN = System.in;
private static final PrintStream STD_OUT = System.out;
private static final String EOL_CHAR = "~";
private static final String[] EMPTY_ARGS = {};
private static final String INPUT_FILE = "part4.txt";
private static final String EOL = System.lineSeparator();
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
private final PrintStream out = new PrintStream(baos);
private static String toMultiline(String line) {
return line.replaceAll(EOL_CHAR, EOL).trim();
}
@AfterAll
static void tearDown() throws IOException {
Files.deleteIfExists(Path.of(INPUT_FILE));
}
@ParameterizedTest
@CsvFileSource(resources = "part4.csv", delimiter = ';')
void part4(String inputData, String expected) throws Exception {
Files.writeString(Paths.get(INPUT_FILE), inputData);
System.setOut(out);
String actual = "";
try {
Part4.main(EMPTY_ARGS);
out.flush();
actual = baos.toString();
} finally {
System.setOut(STD_OUT);
System.setIn(STD_IN);
}
assertEquals(toMultiline(expected).trim(), actual.trim());
}
}

View File

@@ -0,0 +1,69 @@
package ua.nure.jfn.task4;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.lang.reflect.Method;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
/**
* @author Dmytro Kolesnykov
*/
public class Part5Test {
private static final PrintStream STD_OUT = System.out;
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
private final PrintStream out = new PrintStream(baos);
private static String removeCR(String s) {
return s.replaceAll("\r?", "");
}
@ParameterizedTest
@CsvFileSource(resources = "part5.csv", delimiter = ';', ignoreLeadingAndTrailingWhitespace = false)
void part5(String actionsData, String expectedTree) throws Exception {
String expected = expectedTree == null
? ""
: expectedTree.replaceAll("~", System.lineSeparator());
Tree<Integer> tree = new Tree<>();
for (String action : actionsData.split("\\s+")) {
String actionName = actionResolver(action.charAt(0));
Method actionMethod = Tree.class.getMethod(actionName, Comparable.class);
String actionValues = action.substring(action.indexOf('-') + 1);
for (String value : actionValues.split("-")) {
actionMethod.invoke(tree, new Object[] { Integer.parseInt(value) });
}
}
String actual = null;
try {
System.setOut(out);
tree.print();
out.flush();
actual = baos.toString();
} finally {
System.setOut(STD_OUT);
}
expected = removeCR(expected).stripTrailing();
actual = removeCR(actual.replaceAll("(?m)\\s+$", "").stripTrailing());
assertEquals(expected, actual);
}
private static String actionResolver(char actionChar) {
switch (actionChar) {
case 'a':
return "add";
case 'r':
return "remove";
}
return null;
}
}

View File

@@ -0,0 +1,19 @@
package ua.nure.jfn.task4;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class Utils {
public static byte[] getContent(String fileName) throws IOException {
return Files.readAllBytes(Paths.get(fileName));
}
public static void saveContent(String fileName, byte[] content) throws IOException {
if (content != null) {
Files.write(Paths.get(fileName), content);
}
}
}

View File

@@ -0,0 +1,2 @@
table = table
apple = apple

View File

@@ -0,0 +1,2 @@
table = \u10db\u10d0\u10d2\u10d8\u10d3\u10d0
apple = \u10d5\u10d0\u10e8\u10da\u10d8

View File

@@ -0,0 +1,27 @@
for f in *-data.txt; do
sed -rne '
/^#/d
/^\s*$/d
/^~~~/ {
g
s/\n/~/g
s/$/;/
h
b
}
/^===/ {
g
s/\n/~/g
s/;~/;/g
s/^~//
p
s/^.*$//
h
b
}
H
' $f>${f/-data.txt/.csv}
done

View File

@@ -0,0 +1,72 @@
#1
Is there anybody
going to listen to my story
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
asdf
Latn
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
asdf: Incorrect input
Latn: Is there anybody going to listen to my story
====================================
#2
Is there anybody going to listen
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
asdf
Latn
stop
Latn
asdf
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
asdf: Incorrect input
Latn: Is there anybody going to listen
====================================
#3
Is there listen
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
asdf
Latn
Stop
Latn
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
asdf: Incorrect input
Latn: Is there listen
====================================
#4
Incorrect input
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a
Latn
b
stop
a
Latn
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a: Incorrect input
Latn: Incorrect input
b: Incorrect input
====================================
#5
Сонце гріє лице,
Радує це!
Ooh, baby, I love you
What more
can I say
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
latn
Latn
cyrl
Cyrl
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
latn: Incorrect input
Latn: Ooh baby I love you What more can I say
cyrl: Incorrect input
Cyrl: Сонце гріє лице Радує це
====================================

View File

@@ -0,0 +1,5 @@
Is there anybody ~going to listen to my story;asdf~Latn;asdf: Incorrect input~Latn: Is there anybody going to listen to my story
Is there anybody going to listen;asdf~Latn~stop~Latn~asdf;asdf: Incorrect input~Latn: Is there anybody going to listen
Is there listen;asdf~Latn~Stop~Latn;asdf: Incorrect input~Latn: Is there listen
Incorrect input;a~Latn~b~stop~a~Latn;a: Incorrect input~Latn: Incorrect input~b: Incorrect input
Сонце гріє лице,~ Радує це!~Ooh, baby, I love you~ What more ~can I say;latn~Latn~cyrl~Cyrl;latn: Incorrect input~Latn: Ooh baby I love you What more can I say~cyrl: Incorrect input~Cyrl: Сонце гріє лице Радує це
1 Is there anybody ~going to listen to my story asdf~Latn asdf: Incorrect input~Latn: Is there anybody going to listen to my story
2 Is there anybody going to listen asdf~Latn~stop~Latn~asdf asdf: Incorrect input~Latn: Is there anybody going to listen
3 Is there listen asdf~Latn~Stop~Latn asdf: Incorrect input~Latn: Is there listen
4 Incorrect input a~Latn~b~stop~a~Latn a: Incorrect input~Latn: Incorrect input~b: Incorrect input
5 Сонце гріє лице,~ Радує це!~Ooh, baby, I love you~ What more ~can I say latn~Latn~cyrl~Cyrl latn: Incorrect input~Latn: Ooh baby I love you What more can I say~cyrl: Incorrect input~Cyrl: Сонце гріє лице Радує це

View File

@@ -0,0 +1,44 @@
#1
a~b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a : 1
b : 1
====================================
#2
a b a d~b c stop b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c : 1
d : 1
a : 2
b : 2
====================================
#3
a b a stop d~b c stop b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
b : 1
a : 2
====================================
#4
ab ab abd
b abd
stop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
b : 1
ab : 2
abd : 2
====================================
#5
a a a b b stop c c
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
b : 2
a : 3
====================================

View File

@@ -0,0 +1,5 @@
a~b;a : 1~b : 1
a b a d~b c stop b;c : 1~d : 1~a : 2~b : 2
a b a stop d~b c stop b;b : 1~a : 2
ab ab abd~b abd~stop;b : 1~ab : 2~abd : 2
a a a b b stop c c;b : 2~a : 3
1 a~b a : 1~b : 1
2 a b a d~b c stop b c : 1~d : 1~a : 2~b : 2
3 a b a stop d~b c stop b b : 1~a : 2
4 ab ab abd~b abd~stop b : 1~ab : 2~abd : 2
5 a a a b b stop c c b : 2~a : 3

View File

@@ -0,0 +1,101 @@
#1
en
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
en uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
table en
table ka
table uk
apple en
apple uk
stop
ka
apple
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
table
table
стіл
apple
яблуко
====================================
#2
uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
en uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
table en
table ka
table uk
apple en
apple uk
stop
ka
apple
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
table
стіл
стіл
apple
яблуко
====================================
#3
en
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
en uk ka
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
table en
table ka
table uk
apple en
apple uk
stop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
table
მაგიდა
стіл
apple
яблуко
====================================
#4
ka
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
en ka uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
table en
table ka
table uk
apple en
apple uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
table
მაგიდა
стіл
apple
яблуко
====================================
#5
uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
en uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
table en
table en
apple uk
apple uk
stop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
table
table
яблуко
яблуко
====================================

View File

@@ -0,0 +1,5 @@
en;en uk;table en~table ka~table uk~apple en~apple uk~stop~ka~apple;table~table~стіл~apple~яблуко
uk;en uk;table en~table ka~table uk~apple en~apple uk~stop~ka~apple;table~стіл~стіл~apple~яблуко
en;en uk ka;table en~table ka~table uk~apple en~apple uk~stop;table~მაგიდა~стіл~apple~яблуко
ka;en ka uk;table en~table ka~table uk~apple en~apple uk;table~მაგიდა~стіл~apple~яблуко
uk;en uk;table en~table en~apple uk~apple uk~stop;table~table~яблуко~яблуко
1 en en uk table en~table ka~table uk~apple en~apple uk~stop~ka~apple table~table~стіл~apple~яблуко
2 uk en uk table en~table ka~table uk~apple en~apple uk~stop~ka~apple table~стіл~стіл~apple~яблуко
3 en en uk ka table en~table ka~table uk~apple en~apple uk~stop table~მაგიდა~стіл~apple~яблуко
4 ka en ka uk table en~table ka~table uk~apple en~apple uk table~მაგიდა~стіл~apple~яблуко
5 uk en uk table en~table en~apple uk~apple uk~stop table~table~яблуко~яблуко

View File

@@ -0,0 +1,39 @@
#1
1 2 3 4 5 4 3 2 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input ==> 1 2 3 4 5 4 3 2 1
output ==> 1 2 3 4 5
====================================
#2
4 3 1 3 4 1 3 4 1 3 4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input ==> 4 3 1 3 4 1 3 4 1 3 4
output ==> 1 3 4
====================================
#3
4 9 8 2 9 4 8 9 1 9
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input ==> 4 9 8 2 9 4 8 9 1 9
output ==> 1 2 4 8 9
====================================
#4
11 12 11 18 12 11 18 17
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input ==> 11 12 11 18 12 11 18 17
output ==> 11 12 17 18
====================================
#5
0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input ==> 0
output ==> 0
====================================

View File

@@ -0,0 +1,5 @@
1 2 3 4 5 4 3 2 1;input ==> 1 2 3 4 5 4 3 2 1~output ==> 1 2 3 4 5
4 3 1 3 4 1 3 4 1 3 4;input ==> 4 3 1 3 4 1 3 4 1 3 4~output ==> 1 3 4
4 9 8 2 9 4 8 9 1 9;input ==> 4 9 8 2 9 4 8 9 1 9~output ==> 1 2 4 8 9
11 12 11 18 12 11 18 17;input ==> 11 12 11 18 12 11 18 17~output ==> 11 12 17 18
0;input ==> 0~output ==> 0
1 1 2 3 4 5 4 3 2 1 input ==> 1 2 3 4 5 4 3 2 1~output ==> 1 2 3 4 5
2 4 3 1 3 4 1 3 4 1 3 4 input ==> 4 3 1 3 4 1 3 4 1 3 4~output ==> 1 3 4
3 4 9 8 2 9 4 8 9 1 9 input ==> 4 9 8 2 9 4 8 9 1 9~output ==> 1 2 4 8 9
4 11 12 11 18 12 11 18 17 input ==> 11 12 11 18 12 11 18 17~output ==> 11 12 17 18
5 0 input ==> 0~output ==> 0

View File

@@ -0,0 +1,199 @@
#1
a-3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
====================================
#2
a-3-1-2-6-4-7-0-5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌0
┌1┤
│ └2
3┤
│ ┌4┐
│ │ └5
└6┤
└7
====================================
#3
a-3-1-2-6-4-7-0-5 r-3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌0
┌1┤
│ └2
4┤
│ ┌5
└6┤
└7
====================================
#4
a-3-1-2-6-4-7-0-5 r-3-5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌0
┌1┤
│ └2
4┤
└6┐
└7
====================================
#5
a-3-1-2-6-4-7-0-5 r-3-5-4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌0
┌1┤
│ └2
6┤
└7
====================================
#6
a-3-1-2-6-4-7-0-5 r-3-5-4-1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌0
┌2┘
6┤
└7
====================================
#7
a-3-1-2-6-4-7-0 r-3-5-4-1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌0
┌2┘
6┤
└7
====================================
#8
a-3-1-2-6-4-7-0-5 r-3-5-4-1-6-7-2-0-0 a-3-2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌2
3┘
====================================
#9
a-3-3-2-2-1-1 r-2-1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
====================================
#10
a-3-3-1-1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌1
3┘
====================================
#11
a-3-1-2-6-4-7-0-5 r-3-4-5-6
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌0
┌1┤
│ └2
7┘
====================================
#12
a-3-12-116-14-7-0-5 r-3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌0
5┤
│ ┌7
└12┤
│ ┌14
└116┘
====================================
#13
a-3-1-2-6-4-7-0-5 r-3-4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌0
┌1┤
│ └2
5┤
└6┐
└7
====================================
#14
a-3-1-2-6-4-7-0-5 r-3-4-5-6-7
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌0
1┤
└2
====================================
#15
a-3-1-2-6-4-7-0-5 r-3-4-5-6-7-1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌0
2┘
====================================
#16
a-3-1-2-6-4-7-0-5 r-3-4-5-6-7-1-2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0
====================================
#17
a-3-1-2-6-4-7-0-5 r-3-4-5-6-7-1-2-0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
====================================
#18
a-3-1-2-6-4-7 r-3 a-3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌1┐
│ └2┐
│ └3
4┤
└6┐
└7
====================================
#19
a-3-1-2-6-4-7 r-3 a-3 r-2 a-2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌1┐
│ │ ┌2
│ └3┘
4┤
└6┐
└7
====================================
#20
a-3-1-2-6-4-7 r-3 a-3 r-2 a-2 r-6
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌1┐
│ │ ┌2
│ └3┘
4┤
└7
====================================

View File

@@ -0,0 +1,20 @@
a-3;3
a-3-1-2-6-4-7-0-5; ┌0~ ┌1┤~ │ └2~3┤~ │ ┌4┐~ │ │ └5~ └6┤~ └7
a-3-1-2-6-4-7-0-5 r-3; ┌0~ ┌1┤~ │ └2~4┤~ │ ┌5~ └6┤~ └7
a-3-1-2-6-4-7-0-5 r-3-5; ┌0~ ┌1┤~ │ └2~4┤~ └6┐~ └7
a-3-1-2-6-4-7-0-5 r-3-5-4; ┌0~ ┌1┤~ │ └2~6┤~ └7
a-3-1-2-6-4-7-0-5 r-3-5-4-1; ┌0~ ┌2┘~6┤~ └7
a-3-1-2-6-4-7-0 r-3-5-4-1; ┌0~ ┌2┘~6┤~ └7
a-3-1-2-6-4-7-0-5 r-3-5-4-1-6-7-2-0-0 a-3-2; ┌2~3┘
a-3-3-2-2-1-1 r-2-1;3
a-3-3-1-1; ┌1~3┘
a-3-1-2-6-4-7-0-5 r-3-4-5-6; ┌0~ ┌1┤~ │ └2~7┘
a-3-12-116-14-7-0-5 r-3; ┌0~5┤~ │ ┌7~ └12┤~ │ ┌14~ └116┘
a-3-1-2-6-4-7-0-5 r-3-4; ┌0~ ┌1┤~ │ └2~5┤~ └6┐~ └7
a-3-1-2-6-4-7-0-5 r-3-4-5-6-7; ┌0~1┤~ └2
a-3-1-2-6-4-7-0-5 r-3-4-5-6-7-1; ┌0~2┘
a-3-1-2-6-4-7-0-5 r-3-4-5-6-7-1-2;0
a-3-1-2-6-4-7-0-5 r-3-4-5-6-7-1-2-0;
a-3-1-2-6-4-7 r-3 a-3; ┌1┐~ │ └2┐~ │ └3~4┤~ └6┐~ └7
a-3-1-2-6-4-7 r-3 a-3 r-2 a-2; ┌1┐~ │ │ ┌2~ │ └3┘~4┤~ └6┐~ └7
a-3-1-2-6-4-7 r-3 a-3 r-2 a-2 r-6; ┌1┐~ │ │ ┌2~ │ └3┘~4┤~ └7
1 a-3 3
2 a-3-1-2-6-4-7-0-5 ┌0~ ┌1┤~ │ └2~3┤~ │ ┌4┐~ │ │ └5~ └6┤~ └7
3 a-3-1-2-6-4-7-0-5 r-3 ┌0~ ┌1┤~ │ └2~4┤~ │ ┌5~ └6┤~ └7
4 a-3-1-2-6-4-7-0-5 r-3-5 ┌0~ ┌1┤~ │ └2~4┤~ └6┐~ └7
5 a-3-1-2-6-4-7-0-5 r-3-5-4 ┌0~ ┌1┤~ │ └2~6┤~ └7
6 a-3-1-2-6-4-7-0-5 r-3-5-4-1 ┌0~ ┌2┘~6┤~ └7
7 a-3-1-2-6-4-7-0 r-3-5-4-1 ┌0~ ┌2┘~6┤~ └7
8 a-3-1-2-6-4-7-0-5 r-3-5-4-1-6-7-2-0-0 a-3-2 ┌2~3┘
9 a-3-3-2-2-1-1 r-2-1 3
10 a-3-3-1-1 ┌1~3┘
11 a-3-1-2-6-4-7-0-5 r-3-4-5-6 ┌0~ ┌1┤~ │ └2~7┘
12 a-3-12-116-14-7-0-5 r-3 ┌0~5┤~ │ ┌7~ └12┤~ │ ┌14~ └116┘
13 a-3-1-2-6-4-7-0-5 r-3-4 ┌0~ ┌1┤~ │ └2~5┤~ └6┐~ └7
14 a-3-1-2-6-4-7-0-5 r-3-4-5-6-7 ┌0~1┤~ └2
15 a-3-1-2-6-4-7-0-5 r-3-4-5-6-7-1 ┌0~2┘
16 a-3-1-2-6-4-7-0-5 r-3-4-5-6-7-1-2 0
17 a-3-1-2-6-4-7-0-5 r-3-4-5-6-7-1-2-0
18 a-3-1-2-6-4-7 r-3 a-3 ┌1┐~ │ └2┐~ │ └3~4┤~ └6┐~ └7
19 a-3-1-2-6-4-7 r-3 a-3 r-2 a-2 ┌1┐~ │ │ ┌2~ │ └3┘~4┤~ └6┐~ └7
20 a-3-1-2-6-4-7 r-3 a-3 r-2 a-2 r-6 ┌1┐~ │ │ ┌2~ │ └3┘~4┤~ └7

View File

@@ -0,0 +1,2 @@
table = \u0441\u0442\u0456\u043b
apple = \u044f\u0431\u043b\u0443\u043a\u043e

Binary file not shown.

View File

@@ -1,4 +1,5 @@
#import "@local/nure:0.0.0": *
// #import "@local/nure:0.0.0": *
#import "lib.typ": *
#show: lab-pz-template.with(
doctype: "ЛБ",

View File

@@ -1,4 +1,5 @@
#import "@local/nure:0.0.0": *
// #import "@local/nure:0.0.0": *
#import "lib.typ": *
#show: lab-pz-template.with(
doctype: "ЛБ",

View File

@@ -0,0 +1,692 @@
// Academic aliases {{{1
/// subject abbreviations to full names
#let subjects = (
"БД": "Бази даних",
"ОПНJ": "Основи програмування на Java",
"ОС": "Операційні системи",
"ПП": "Проектний практикум",
"СПМ": "Скриптові мови програмування",
"Ф": "Філософія",
)
/// education program abbreviations to name & number
#let edu_programs = (
"ПЗПІ": (
name: "Інженерія програмного забезпечення",
number: 121, // TODO: ПЗПІ is "F2" now
),
)
// Template formatting functions {{{1
/// numberless heading
#let nheading(title) = heading(depth: 1, numbering: none, title)
/// fill horizontal space with a box and not an empty space
#let hfill(width) = box(width: width, repeat("")) // NOTE: This is a HAIR SPACE (U+200A), not a regular space
/// make underlined cell with filled value
#let uline(align: center, content) = underline[
#if align != left { hfill(1fr) }
#content
#if align != right { hfill(1fr) }
]
/// bold text
#let bold(content) = text(weight: "bold")[#content]
/// month name from its number
#let month_gen(month) = (
"січня",
"лютого",
"березня",
"квітня",
"травня",
"червня",
"липня",
"серпня",
"вересня",
"жовтня",
"листопада",
"грудня",
).at(month - 1)
// Helper functions {{{1
/// captioned image with label derived from path:
/// - "image.png" = @image
/// - "img/image.png" = @image
/// - "img/foo/image.png" = @foo_image
/// - "img/foo/foo_image.png" = @foo_image
/// the caption will be modified based on a conditional positional value:
/// - `none`: no change
/// - some value: "`caption` (за даними `value`)"
/// - no value: "`caption` (рисунок виконано самостійно)"
/// additional named arguments will be passed to original `image` function
#let img(path, caption, ..sink) = {
let parts = path.split(".").first().split("/")
let label_string = if parts.len() <= 2 or parts.at(-1).starts-with(parts.at(-2)) {
// ("image",), (_, "image") and (.., "img", "img_image")
parts.last()
} else {
// (.., "img", "image") = "img_image"
parts.at(-2) + "_" + parts.at(-1)
}.replace(" ", "_")
let caption = if sink.pos().len() == 0 {
caption + " (рисунок виконано самостійно)"
} else if sink.pos().first() == none {
caption
} else {
[#caption (за даними #sink.pos().first())]
}
[#figure(image(path, ..sink.named()), caption: caption) #label(label_string)]
}
// Styling {{{1
/// NOTE: may be wrong
#let ua_alpha_numbering = "абвгдежиклмнпрстуфхцшщюя".split("") // 0 = "", 1 = "а"
// general outlook {{{2
// spacing between lines
#let spacing = 0.95em
#let style(it) = {
set page(
paper: "a4",
margin: (top: 20mm, right: 10mm, bottom: 20mm, left: 25mm),
number-align: top + right,
numbering: (..numbers) => {
if numbers.pos().at(0) != 1 {
numbering("1", numbers.pos().at(0))
}
},
)
set text(font: ("Times New Roman", "Liberation Serif"), size: 14pt, hyphenate: false, lang: "uk")
set par(justify: true, first-line-indent: (amount: 1.25cm, all: true))
set underline(evade: false)
// set 1.5 line spacing
set block(spacing: spacing)
set par(spacing: spacing)
set par(leading: spacing)
// enums and lists {{{2
set enum(numbering: i => { ua_alpha_numbering.at(i) + ")" }, indent: 1.25cm, body-indent: 0.5cm)
show enum: it => {
set enum(indent: 0em, numbering: "1)")
it
}
set list(indent: 1.35cm, body-indent: 0.5cm, marker: [--])
// figures {{{2
show figure: it => {
v(spacing * 2, weak: true)
it
v(spacing * 2, weak: true)
}
set figure.caption(separator: [ -- ])
show figure.where(kind: table): set figure.caption(position: top)
show figure.caption.where(kind: table): set align(left)
// figure numbering
show heading.where(level: 1): it => {
counter(math.equation).update(0)
counter(figure.where(kind: image)).update(0)
counter(figure.where(kind: table)).update(0)
counter(figure.where(kind: raw)).update(0)
it
}
set math.equation(numbering: (..num) => numbering("(1.1)", counter(heading).get().at(0), num.pos().first()))
set figure(numbering: (..num) => numbering("1.1", counter(heading).get().at(0), num.pos().first()))
// appearance of references to images and tables {{{2
set ref(
supplement: it => {
if it == none or not it.has("kind") {
it
} else if it.kind == image {
"див. рис."
} else if it.kind == table {
"див. таблицю"
} else {
it
}
},
)
show ref: it => {
let el = it.element
if el == none or not el.has("kind") {
return it
}
if el.kind != image and el.kind != table {
return it
}
[(#it)]
}
// headings {{{2
set heading(numbering: "1.1")
show heading.where(level: 1): it => {
set align(center)
set text(size: 14pt, weight: "semibold")
pagebreak(weak: true)
upper(it)
v(spacing * 2, weak: true)
}
show heading.where(level: 2): it => {
set text(size: 14pt, weight: "regular")
v(spacing * 2, weak: true)
block(width: 100%, spacing: 0em)[
#h(1.25cm)
#counter(heading).display(it.numbering)
#it.body
]
v(spacing * 2, weak: true)
}
show heading.where(level: 3): it => {
set text(size: 14pt, weight: "regular")
v(spacing * 2, weak: true)
block(width: 100%, spacing: 0em)[
#h(1.25cm)
#counter(heading).display(it.numbering)
#it.body
]
v(spacing * 2, weak: true)
}
it
}
// Coursework template {{{1
/// DSTU 3008:2015 Template for NURE
/// -> content
/// - doc (content): Content to apply the template to.
/// - title (str): Title of the document.
/// - subject_shorthand (str): Subject short name.
/// - department_gen (str): Department name in genitive form.
/// - authors ((name: str, full_name_gen: str, variant: int, group: str, gender: str),): List of Authors dicts.
/// - mentors ((name: str, gender: str, degree: str),): List of mentors dicts.
/// - edu_program_shorthand (str): Education program shorthand.
/// - task_list (done_date: datetime, initial_date: datetime, source: (content | str), content: (content | str), graphics: (content | str)): Task list object.
/// - calendar_plan ( plan_table: (content | str), approval_date: datetime): Calendar plan object.
/// - abstract (keywords: (str, ), text: (content | str)): Abstract object.
/// - bib_path path: Path to the bibliography yaml file.
/// - appendices (content): Content with appendices.
#let cw-template(
doc,
title: "NONE",
subject_shorthand: "NONE",
department_gen: "Програмної інженерії",
author: (),
mentors: (),
edu_program_shorthand: "ПЗПІ",
task_list: (),
calendar_plan: (),
abstract: (),
bib_path: "bibl.yml",
appendices: (),
) = {
set document(title: title, author: author.name)
show: style
let bib-count = state("citation-counter", ())
show cite: it => {
it
bib-count.update(((..c)) => (..c, it.key))
}
show bibliography: it => {
set text(size: 0pt)
it
}
let head_mentor = mentors.at(0)
let edu_program = edu_programs.at(edu_program_shorthand)
// page 1 {{{2
[
#set align(center)
МІНІСТЕРСТВО ОСВІТИ І НАУКИ УКРАЇНИ
ХАРКІВСЬКИЙ НАЦІОНАЛЬНИЙ УНІВЕРСИТЕТ РАДІОЕЛЕКТРОНІКИ
\
Кафедра Програмної інженерії
\
ПОЯСНЮВАЛЬНА ЗАПИСКА
ДО КУРСОВОЇ РОБОТИ
з дисципліни: "#subjects.at(subject_shorthand, default: "NONE")"
Тема роботи: "#title"
\ \ \
#columns(2, gutter: 4cm)[
#set align(left)
#if author.gender == "m" { [Виконав\ ] } else { [Виконала\ ] } ст. гр. #author.group
\
Керівник:\
#head_mentor.degree
\
Робота захищена на оцінку
\
Комісія:\
#for mentor in mentors {
[#mentor.degree\
]
}
#colbreak()
#set align(left)
\
#author.name
\ \
#head_mentor.name
\
#underline(" " * 35)
\ \
#for mentor in mentors {
[#mentor.name\
]
}
]
#v(1fr)
Харків -- #task_list.done_date.display("[year]")
#pagebreak()
]
// page 2 {{{2
{
uline[Харківський національний університет радіоелектроніки]
linebreak()
linebreak()
grid(
columns: (100pt, 1fr),
bold[
Кафедра
Дисципліна
Спеціальність
],
{
uline(align: left, department_gen)
linebreak()
uline(align: left, subjects.at(subject_shorthand))
linebreak()
uline(align: left, [#edu_program.number #edu_program.name])
},
)
grid(
columns: (1fr, 1fr, 1fr),
gutter: 0.3fr,
[#bold[Курс] #uline(2)], [#bold[Група] #uline(author.group)], [#bold[Семестр] #uline(3)],
)
linebreak()
linebreak()
linebreak()
align(center, bold[ЗАВДАННЯ \ на курсову роботу студента])
linebreak()
uline(align: left)[_#author.full_name_gen _]
linebreak()
linebreak()
bold[\1. Тема роботи:]
uline[#title.]
linebreak()
{
bold[\2. Строк здачі закінченої роботи:]
uline(task_list.done_date.display("[day].[month].[year]"))
hfill(10fr)
}
linebreak()
bold[\3. Вихідні дані для роботи:]
uline(task_list.source)
linebreak()
bold[\4. Зміст розрахунково-пояснювальної записки:]
uline(task_list.content)
linebreak()
bold[\5. Перелік графічного матеріалу:]
uline(task_list.graphics)
linebreak()
{
bold[\6. Дата видачі завдання:]
uline(task_list.initial_date.display("[day].[month].[year]"))
hfill(10fr)
}
pagebreak()
}
// page 3 {{{2
{
align(center, bold[КАЛЕНДАРНИЙ ПЛАН])
set par(first-line-indent: 0pt)
linebreak()
calendar_plan.plan_table
linebreak()
grid(
columns: (5fr, 5fr),
grid(
columns: (1fr, 2fr, 1fr),
gutter: 0.2fr,
[
Студент \
Керівник \
#align(center)["#underline[#calendar_plan.approval_date.day()]"]
],
[
#uline(align: center, []) \
#uline(align: center, []) \
#uline(align: center, month_gen(calendar_plan.approval_date.month()))
],
[
\ \
#underline[#calendar_plan.approval_date.year()] р.
],
),
[
#author.name, \
#head_mentor.degree
#head_mentor.name.
],
)
pagebreak()
}
// page 4 {{{2
[
#align(center, bold[РЕФЕРАТ]) \
#context [
#let pages = counter(page).final().at(0)
#let images = query(figure.where(kind: image)).len()
#let tables = query(figure.where(kind: table)).len()
#let bibs = bib-count.final().dedup().len()
/* TODO: why this stopped working?
#let tables = counter(figure.where(kind: table)).final().at(0)
#let images = counter(figure.where(kind: image)).final().at(0)*/
#let counters = ()
#if pages != 0 { counters.push[#pages с.] }
#if tables != 0 { counters.push[#tables табл.] }
#if images != 0 { counters.push[#images рис.] }
#if bibs != 0 { counters.push[#bibs джерел] }
Пояснювальна записка до курсової роботи: #counters.join(", ").
]
\
#{
let keywords = abstract.keywords.map(upper)
let is_cyrillic = word => word.split("").any(char => ("А" <= char and char <= "я"))
let n = keywords.len()
for i in range(n) {
for j in range(0, n - i - 1) {
if (
(not is_cyrillic(keywords.at(j)) and is_cyrillic(keywords.at(j + 1)))
or (
is_cyrillic(keywords.at(j)) == is_cyrillic(keywords.at(j + 1)) and keywords.at(j) > keywords.at(j + 1)
)
) {
(keywords.at(j), keywords.at(j + 1)) = (keywords.at(j + 1), keywords.at(j))
}
}
}
keywords.join(", ")
}
\
#abstract.text
]
// page 5 {{{2
outline(
title: [
ЗМІСТ
#v(spacing * 2, weak: true)
],
depth: 2,
indent: auto,
)
doc
// bibliography {{{2
{
heading(depth: 1, numbering: none)[Перелік джерел посилання]
bibliography(
bib_path,
style: "ieee",
full: true,
title: none,
)
let bib_data = yaml(bib_path)
let format-entry(citation) = {
if (citation.type == "Web") {
let date_array = citation.url.date.split("-")
let date = datetime(
year: int(date_array.at(0)),
month: int(date_array.at(1)),
day: int(date_array.at(2)),
)
[
#citation.title.
#citation.author.
URL: #citation.url.value (дата звернення: #date.display("[day].[month].[year]")).
]
} else if citation.type == "Book" [
#citation.author
#citation.title.
#citation.publisher,
#citation.date.
#citation.page-total c.
] else [
UNSUPPORTED BIBLIOGRAPHY ENTRY TYPE, PLEASE OPEN AN ISSUE
]
}
show enum.item: it => {
set par(first-line-indent: 0pt)
box(width: 1.25cm)
box(width: 1em + 0.5cm)[#it.number.]
it.body
linebreak()
}
context {
for (i, citation) in query(ref.where(element: none)).map(r => str(r.target)).dedup().enumerate() {
enum.item(
i + 1,
format-entry(bib_data.at(citation)),
)
}
}
}
// appendices {{{2
{
counter(heading).update(0)
set heading(
numbering: (i, ..nums) => {
let char = upper(ua_alpha_numbering.at(i))
if nums.pos().len() == 0 { char } else {
char + "." + nums.pos().map(str).join(".")
}
},
)
show heading.where(level: 1): it => {
set align(center)
set text(size: 14pt, weight: "regular")
pagebreak(weak: true)
bold[ДОДАТОК #counter(heading).display(it.numbering)]
linebreak()
it.body
v(spacing * 2, weak: true)
}
show heading.where(level: 2): it => {
set text(size: 14pt, weight: "regular")
v(spacing * 2, weak: true)
block(width: 100%, spacing: 0em)[
#h(1.25cm)
#counter(heading).display(it.numbering)
#it.body
]
v(spacing * 2, weak: true)
}
appendices
}
}
// Laboratory work template {{{1
/// DSTU 3008:2015 Template for NURE
/// -> content
/// - doc (content): Content to apply the template to.
/// - doctype ("ЛБ" | "ПЗ"): Document type.
/// - title (str): Title of the document.
/// - subject_shorthand (str): Subject short name.
/// - department_gen (str): Department name in genitive form.
/// - worknumber (int): Number of the work, can be omitted.
/// - authors ((name: str, full_name_gen: str, variant: int, group: str, gender: str),): List of Authors dicts.
/// - mentor (name: str, gender: str, degree: str): Mentors objects.
#let lab-pz-template(
doc,
doctype: "NONE",
title: "NONE",
subject_shorthand: "NONE",
department_gen: "Програмної інженерії",
worknumber: 1,
authors: (),
mentor: (),
) = {
set document(title: title, author: authors.at(0).name)
show: style
context counter(heading).update(worknumber - 1)
// page 1 {{{2
align(center)[
МІНІСТЕРСТВО ОСВІТИ І НАУКИ УКРАЇНИ \
ХАРКІВСЬКИЙ НАЦІОНАЛЬНИЙ УНІВЕРСИТЕТ РАДІОЕЛЕКТРОНІКИ
\ \
Кафедра #department_gen
\ \ \
Звіт \
з
#if doctype == "ЛБ" [лабораторної роботи] else [практичної роботи]
#if worknumber != none [ #worknumber]
з дисципліни: "#subjects.at(subject_shorthand, default: "UNLNOWN SUBJECT, PLEASE OPEN AN ISSUE")"
з теми: "#title"
\ \ \ \
#columns(2)[
#set align(left)
#set par(first-line-indent: 0pt)
#if authors.len() == 1 {
let author = authors.at(0)
if author.gender == "m" [Виконав:\ ] else [Виконала:\ ]
[
ст. гр. #author.group\
#author.name\
]
if author.variant != none [Варіант: #author.variant]
} else [
Виконали:\
ст. гр. #authors.at(0).group\
#authors.map(a => [ #a.name\ ])
]
#colbreak()
#set align(right)
#if mentor.gender == "m" { [Перевірив:\ ] } else { [Перевірила:\ ] }
#mentor.degree #if mentor.degree.len() >= 15 [\ ]
#mentor.name\
]
#v(1fr)
Харків -- #datetime.today().display("[year]")
]
pagebreak(weak: true)
heading(title)
doc
}
// vim:sts=2:sw=2:fdl=0:fdm=marker:cms=/*%s*/

View File

@@ -1,4 +1,5 @@
#import "@local/nure:0.0.0": *
// #import "@local/nure:0.0.0": *
#import "lib.typ": *
#show: lab-pz-template.with(
doctype: "ЛБ",

View File

@@ -0,0 +1,8 @@
> [!NOTE]
> Викладач: Мельникова Р. В.
>
> Оцінка: 93 (90 у напарника)
> [!TIP]
> Виконано для Linux в команді.
> Їй не сподобалося друге завдання (LRU для регістрів), не знаю чому, мабуть бо вона сама не знає що це таке 😤

View File

@@ -0,0 +1,21 @@
title: Керування пам'яттю. Частина 2
subject: ОС
doctype: ЛБ
worknumber: 6
mentors:
- name: Мельнікова Р. В.,
gender: f,
degree: доц. каф. ПІ,
edu_program: &EDU ПЗПІ
university: ХНУРЕ
authors:
- name: Ситник Є. С.
course: 2
edu: *EDU
gender: m
group: 23-2
- name: Малишкін. А. С.
course: 2
edu: *EDU
gender: m
group: 23-2

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

Some files were not shown because too many files have changed in this diff Show More