diff --git a/semester-4/ОПJа/lb-1/task1/.gitignore b/semester-4/ОПJа/lb-1/task1/.gitignore new file mode 100644 index 0000000..13fbea8 --- /dev/null +++ b/semester-4/ОПJа/lb-1/task1/.gitignore @@ -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 + diff --git a/semester-4/ОПJа/lb-2/task2/.gitignore b/semester-4/ОПJа/lb-2/task2/.gitignore new file mode 100644 index 0000000..13fbea8 --- /dev/null +++ b/semester-4/ОПJа/lb-2/task2/.gitignore @@ -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 + diff --git a/semester-4/ОПJа/lb-2/task2/src/main/java/ua/nure/jfn/task2/ArrayImpl.java b/semester-4/ОПJа/lb-2/task2/src/main/java/ua/nure/jfn/task2/ArrayImpl.java index dbdc55d..a3dfa48 100644 --- a/semester-4/ОПJа/lb-2/task2/src/main/java/ua/nure/jfn/task2/ArrayImpl.java +++ b/semester-4/ОПJа/lb-2/task2/src/main/java/ua/nure/jfn/task2/ArrayImpl.java @@ -1,6 +1,7 @@ package ua.nure.jfn.task2; import java.util.Iterator; +import java.util.NoSuchElementException; public class ArrayImpl implements Array { @@ -11,10 +12,10 @@ public class ArrayImpl implements Array { } public ArrayImpl(Container 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 implements Array { @Override public int size() { - return this.size; + return size; } @SuppressWarnings("unchecked") @@ -127,7 +128,7 @@ public class ArrayImpl implements Array { @Override public T next() { if (!hasNext()) - throw new java.util.NoSuchElementException(); + throw new NoSuchElementException(); lastReturnedIndex = currentIndex; return (T) elements[currentIndex++]; diff --git a/semester-4/ОПJа/lb-2/task2/src/main/java/ua/nure/jfn/task2/ListImpl.java b/semester-4/ОПJа/lb-2/task2/src/main/java/ua/nure/jfn/task2/ListImpl.java index fdfd6b0..b8f1bb2 100644 --- a/semester-4/ОПJа/lb-2/task2/src/main/java/ua/nure/jfn/task2/ListImpl.java +++ b/semester-4/ОПJа/lb-2/task2/src/main/java/ua/nure/jfn/task2/ListImpl.java @@ -1,6 +1,7 @@ package ua.nure.jfn.task2; import java.util.Iterator; +import java.util.NoSuchElementException; public class ListImpl implements List { @@ -114,7 +115,7 @@ public class ListImpl implements List { @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 implements List { @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 implements List { @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 implements List { @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 implements List { 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 implements List { return true; } - if (head.next != null) { + if (head.next != null) return head.remove(element); - } return false; } @@ -224,7 +225,7 @@ public class ListImpl implements List { @Override public T next() { if (!hasNext()) - throw new java.util.NoSuchElementException(); + throw new NoSuchElementException(); prev = curr; curr = curr.next; diff --git a/semester-4/ОПJа/lb-2/task2/src/main/java/ua/nure/jfn/task2/StreamImpl.java b/semester-4/ОПJа/lb-2/task2/src/main/java/ua/nure/jfn/task2/StreamImpl.java index a347225..bf61176 100644 --- a/semester-4/ОПJа/lb-2/task2/src/main/java/ua/nure/jfn/task2/StreamImpl.java +++ b/semester-4/ОПJа/lb-2/task2/src/main/java/ua/nure/jfn/task2/StreamImpl.java @@ -20,10 +20,9 @@ public class StreamImpl implements Stream { public Container apply(Container input) { Array newContainer = new ArrayImpl(); - 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 implements Stream { public Container apply(Container input) { Array newContainer = new ArrayImpl(); - for (Object element : input) { + for (Object element : input) newContainer.add(function.apply((T) element)); - } return newContainer; } @@ -61,14 +59,14 @@ public class StreamImpl implements Stream { @Override public Stream filter(Function predicate) { - Array newOperations = new ArrayImpl<>(this.operations); + Array newOperations = new ArrayImpl<>(operations); newOperations.add(new FilterOperation<>(predicate)); return new StreamImpl(source, newOperations); } @Override public Stream map(Function function) { - Array newOperations = new ArrayImpl<>(this.operations); + Array newOperations = new ArrayImpl<>(operations); newOperations.add(new MapOperation<>(function)); return new StreamImpl(source, newOperations); } @@ -88,13 +86,10 @@ public class StreamImpl implements Stream { @SuppressWarnings("unchecked") @Override public void forEach(Action 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); - } } - } diff --git a/semester-4/ОПJа/lb-3/README.md b/semester-4/ОПJа/lb-3/README.md new file mode 100644 index 0000000..3fdfbd7 --- /dev/null +++ b/semester-4/ОПJа/lb-3/README.md @@ -0,0 +1,4 @@ +> [!NOTE] +> Викладач: Колесников Д. О. +> +> Оцінка: In Progress diff --git a/semester-4/ОПJа/lb-3/images/converters_output.png b/semester-4/ОПJа/lb-3/images/converters_output.png new file mode 100644 index 0000000..d556416 Binary files /dev/null and b/semester-4/ОПJа/lb-3/images/converters_output.png differ diff --git a/semester-4/ОПJа/lb-3/images/part1_convert3_output.png b/semester-4/ОПJа/lb-3/images/part1_convert3_output.png new file mode 100644 index 0000000..b30e14b Binary files /dev/null and b/semester-4/ОПJа/lb-3/images/part1_convert3_output.png differ diff --git a/semester-4/ОПJа/lb-3/task3.zip b/semester-4/ОПJа/lb-3/task3.zip new file mode 100644 index 0000000..75e15ed Binary files /dev/null and b/semester-4/ОПJа/lb-3/task3.zip differ diff --git a/semester-4/ОПJа/lb-3/task3/.gitignore b/semester-4/ОПJа/lb-3/task3/.gitignore new file mode 100644 index 0000000..13fbea8 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/.gitignore @@ -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 + diff --git a/semester-4/ОПJа/lb-3/task3/part1.txt b/semester-4/ОПJа/lb-3/task3/part1.txt new file mode 100644 index 0000000..b0b74c1 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/part1.txt @@ -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 diff --git a/semester-4/ОПJа/lb-3/task3/part2.txt b/semester-4/ОПJа/lb-3/task3/part2.txt new file mode 100644 index 0000000..2439290 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/part2.txt @@ -0,0 +1,2 @@ +When I was younger, so much younger than today +I never needed anybody's help in any way diff --git a/semester-4/ОПJа/lb-3/task3/part3.txt b/semester-4/ОПJа/lb-3/task3/part3.txt new file mode 100644 index 0000000..3306ae0 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/part3.txt @@ -0,0 +1,2 @@ +when I was younger younger than today was +I never needed needed never never was I was diff --git a/semester-4/ОПJа/lb-3/task3/pom.xml b/semester-4/ОПJа/lb-3/task3/pom.xml new file mode 100644 index 0000000..9bfa9f4 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/pom.xml @@ -0,0 +1,58 @@ + + + + 4.0.0 + + ua.nure.jfn + task3 + 0.0.1-SNAPSHOT + + + UTF-8 + 17 + 5.12.0 + 3.5.2 + 11.2.0 + + + + + org.junit.jupiter + junit-jupiter-engine + ${junit5.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit5.version} + test + + + fr.inria.gforge.spoon + spoon-core + ${spoon.version} + test + + + org.slf4j + slf4j-simple + 2.0.17 + test + + + + + task3 + + + + maven-surefire-plugin + ${surefire.version} + + + + + diff --git a/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Demo.java b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Demo.java new file mode 100644 index 0000000..49766fc --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Demo.java @@ -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); + } + +} diff --git a/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Part1.java b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Part1.java new file mode 100644 index 0000000..96fc1c9 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Part1.java @@ -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(); + } + +} diff --git a/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Part2.java b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Part2.java new file mode 100644 index 0000000..1b42692 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Part2.java @@ -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; + } + +} diff --git a/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Part3.java b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Part3.java new file mode 100644 index 0000000..79a4a1b --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Part3.java @@ -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(); + } +} diff --git a/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Utils.java b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Utils.java new file mode 100644 index 0000000..5fceee6 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/Utils.java @@ -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")); + } +} diff --git a/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/converter/CyrillicConverter.java b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/converter/CyrillicConverter.java new file mode 100644 index 0000000..8324f61 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/converter/CyrillicConverter.java @@ -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)); + } + +} diff --git a/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/converter/MayaConverter.java b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/converter/MayaConverter.java new file mode 100644 index 0000000..a99f145 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/converter/MayaConverter.java @@ -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"))); + } + +} diff --git a/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/converter/PositionalConverter.java b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/converter/PositionalConverter.java new file mode 100644 index 0000000..07b9a6b --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/converter/PositionalConverter.java @@ -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)); + } + +} diff --git a/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/converter/RomanConverter.java b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/converter/RomanConverter.java new file mode 100644 index 0000000..6be2917 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/main/java/ua/nure/jfn/task3/converter/RomanConverter.java @@ -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)); + } + +} diff --git a/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/Base.java b/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/Base.java new file mode 100644 index 0000000..217ec64 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/Base.java @@ -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); + } + } + +} diff --git a/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/ComplianceTest.java b/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/ComplianceTest.java new file mode 100644 index 0000000..5052098 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/ComplianceTest.java @@ -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 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()); + } + +} diff --git a/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/Part1Test.java b/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/Part1Test.java new file mode 100644 index 0000000..03e2b72 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/Part1Test.java @@ -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); + } + +} diff --git a/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/Part2Test.java b/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/Part2Test.java new file mode 100644 index 0000000..606e1f7 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/Part2Test.java @@ -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); + } + +} diff --git a/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/Part3Test.java b/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/Part3Test.java new file mode 100644 index 0000000..e89519f --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/Part3Test.java @@ -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); + } + +} diff --git a/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/converter/ConverterTest.java b/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/converter/ConverterTest.java new file mode 100644 index 0000000..0f265ab --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/java/ua/nure/jfn/task3/converter/ConverterTest.java @@ -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); + } + +} diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/converter/cyrillic.csv b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/converter/cyrillic.csv new file mode 100644 index 0000000..d1c4b57 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/converter/cyrillic.csv @@ -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 | ҂рсч diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/converter/maya.csv b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/converter/maya.csv new file mode 100644 index 0000000..3fe91fb --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/converter/maya.csv @@ -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 | 𝋡𝋠𝋠 diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/converter/positional.csv b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/converter/positional.csv new file mode 100644 index 0000000..5f91619 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/converter/positional.csv @@ -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 diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/converter/roman.csv b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/converter/roman.csv new file mode 100644 index 0000000..dfe9005 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/converter/roman.csv @@ -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 | ⅠⅩ diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/forbidden-api-regex.txt b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/forbidden-api-regex.txt new file mode 100644 index 0000000..16730ec --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/forbidden-api-regex.txt @@ -0,0 +1,8 @@ +(?x) +^ +(?:java\.util\.[^.]+) +| +(?:java\.util\.stream\.[^.]+) +| +(?:java\.lang\.(?:Byte|Short|Integer|Long|Float|Double|Character)) +$ diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/list-of-types.txt b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/list-of-types.txt new file mode 100644 index 0000000..7b77e6c --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/list-of-types.txt @@ -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 diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert1-data.txt b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert1-data.txt new file mode 100644 index 0000000..5b05d5c --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert1-data.txt @@ -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 + +==================================== diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert1.csv b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert1.csv new file mode 100644 index 0000000..273c696 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert1.csv @@ -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 diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert2-data.txt b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert2-data.txt new file mode 100644 index 0000000..21d0651 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert2-data.txt @@ -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 + +==================================== diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert2.csv b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert2.csv new file mode 100644 index 0000000..ea5d3de --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert2.csv @@ -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 diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert3-data.txt b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert3-data.txt new file mode 100644 index 0000000..323be37 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert3-data.txt @@ -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 + +==================================== diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert3.csv b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert3.csv new file mode 100644 index 0000000..1f9f41f --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part1-convert3.csv @@ -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 diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part2-data.txt b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part2-data.txt new file mode 100644 index 0000000..231575c --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part2-data.txt @@ -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, + +==================================== diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part2.csv b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part2.csv new file mode 100644 index 0000000..a7da31b --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part2.csv @@ -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, diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part3-data.txt b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part3-data.txt new file mode 100644 index 0000000..291c126 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part3-data.txt @@ -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 + +==================================== + + + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + +==================================== diff --git a/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part3.csv b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part3.csv new file mode 100644 index 0000000..079a9a9 --- /dev/null +++ b/semester-4/ОПJа/lb-3/task3/src/test/resources/ua/nure/jfn/task3/part3.csv @@ -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 + ~ | ~ diff --git a/semester-4/ОПJа/lb-3/tasks.pdf b/semester-4/ОПJа/lb-3/tasks.pdf new file mode 100644 index 0000000..256410c Binary files /dev/null and b/semester-4/ОПJа/lb-3/tasks.pdf differ diff --git a/semester-4/ОПJа/lb-4/part5-gifs/part5-demo-1.gif b/semester-4/ОПJа/lb-4/part5-gifs/part5-demo-1.gif new file mode 100644 index 0000000..ca29dca Binary files /dev/null and b/semester-4/ОПJа/lb-4/part5-gifs/part5-demo-1.gif differ diff --git a/semester-4/ОПJа/lb-4/part5-gifs/part5-demo-2.gif b/semester-4/ОПJа/lb-4/part5-gifs/part5-demo-2.gif new file mode 100644 index 0000000..9465d61 Binary files /dev/null and b/semester-4/ОПJа/lb-4/part5-gifs/part5-demo-2.gif differ diff --git a/semester-4/ОПJа/lb-4/part5-gifs/part5-demo-3.gif b/semester-4/ОПJа/lb-4/part5-gifs/part5-demo-3.gif new file mode 100644 index 0000000..53d45e8 Binary files /dev/null and b/semester-4/ОПJа/lb-4/part5-gifs/part5-demo-3.gif differ diff --git a/semester-4/ОПJа/lb-4/part5-gifs/part5-demo-4.gif b/semester-4/ОПJа/lb-4/part5-gifs/part5-demo-4.gif new file mode 100644 index 0000000..2c3602e Binary files /dev/null and b/semester-4/ОПJа/lb-4/part5-gifs/part5-demo-4.gif differ diff --git a/semester-4/ОПJа/lb-4/task4/.gitignore b/semester-4/ОПJа/lb-4/task4/.gitignore new file mode 100644 index 0000000..13fbea8 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/.gitignore @@ -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 + diff --git a/semester-4/ОПJа/lb-4/task4/mvn-clean-test.bat b/semester-4/ОПJа/lb-4/task4/mvn-clean-test.bat new file mode 100644 index 0000000..7213658 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/mvn-clean-test.bat @@ -0,0 +1,2 @@ +set JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 +mvn clean test diff --git a/semester-4/ОПJа/lb-4/task4/mvn-clean-test.sh b/semester-4/ОПJа/lb-4/task4/mvn-clean-test.sh new file mode 100644 index 0000000..183764c --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/mvn-clean-test.sh @@ -0,0 +1,2 @@ +JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 +mvn clean test diff --git a/semester-4/ОПJа/lb-4/task4/part1.txt b/semester-4/ОПJа/lb-4/task4/part1.txt new file mode 100644 index 0000000..ea69d9b --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/part1.txt @@ -0,0 +1,5 @@ +Сонце гріє лице, + Радує це! +Ooh + What more +can I say \ No newline at end of file diff --git a/semester-4/ОПJа/lb-4/task4/part2.txt b/semester-4/ОПJа/lb-4/task4/part2.txt new file mode 100644 index 0000000..1e2500b --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/part2.txt @@ -0,0 +1,3 @@ +asd asdf asd asdf +asdf 43 asdsf 43 43 434 +stop diff --git a/semester-4/ОПJа/lb-4/task4/part4_sorted.txt b/semester-4/ОПJа/lb-4/task4/part4_sorted.txt new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/part4_sorted.txt @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/semester-4/ОПJа/lb-4/task4/pom.xml b/semester-4/ОПJа/lb-4/task4/pom.xml new file mode 100644 index 0000000..aa290ef --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + ua.nure.jfn + task4 + 0.0.1-SNAPSHOT + + + UTF-8 + 17 + 5.12.0 + 3.5.3 + + + + + org.junit.jupiter + junit-jupiter-engine + ${junit5.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit5.version} + test + + + + + task4 + + + + maven-surefire-plugin + ${surefire.version} + + + + + diff --git a/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Demo.java b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Demo.java new file mode 100644 index 0000000..2f7aad1 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Demo.java @@ -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); + } +} diff --git a/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part1.java b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part1.java new file mode 100644 index 0000000..0e9b087 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part1.java @@ -0,0 +1,59 @@ +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; + } else 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(); + } +} diff --git a/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part2.java b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part2.java new file mode 100644 index 0000000..8dc9817 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part2.java @@ -0,0 +1,24 @@ +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; + + System.setIn(new ByteArrayInputStream(symin.getBytes(StandardCharsets.UTF_8))); + + WordContainer.main(args); + + System.setIn(stdin); + } + +} diff --git a/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part3.java b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part3.java new file mode 100644 index 0000000..5005f23 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part3.java @@ -0,0 +1,30 @@ +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])); + } + scanner.close(); + } +} diff --git a/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part4.java b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part4.java new file mode 100644 index 0000000..dfc7241 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part4.java @@ -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 nums; + + if (!Files.exists(INPUT_FILE)) { + Random random = new Random(); + + nums = new ArrayList(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 sortDedup(List 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 dedup = new ArrayList(); + for (int num : nums) { + if (dedup.indexOf(num) == -1) + dedup.add(num); + } + + return dedup; + } + + private static boolean tryWriteNums(Path path, List 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 tryReadNums(Path path) { + List nums = new ArrayList(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 numbers) { + String result = ""; + for (int num : numbers) { + result += " " + num; + } + + return result.trim(); + } +} diff --git a/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part5.java b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part5.java new file mode 100644 index 0000000..412ffe6 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Part5.java @@ -0,0 +1,25 @@ +package ua.nure.jfn.task4; + +public class Part5 { + + private static final String SEPARATOR = "~~~~~~~"; + + public static void main(String[] args) { + Tree 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(); + } + +} \ No newline at end of file diff --git a/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Tree.java b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Tree.java new file mode 100644 index 0000000..d8ef864 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Tree.java @@ -0,0 +1,194 @@ +package ua.nure.jfn.task4; + +public class Tree> { + private Node 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 addRecursive(Node 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 removeRecursive(Node 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 successor = findMin(node.right); + node.data = successor.data; + node.right = removeRecursive(node.right, successor.data); + size++; + } + + return node; + } + + private Node findMin(Node 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 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 data; + Node left; + Node 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); + } + } + } +} diff --git a/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Word.java b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Word.java new file mode 100644 index 0000000..f29f82a --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/Word.java @@ -0,0 +1,61 @@ +package ua.nure.jfn.task4; + +import java.util.Objects; + +public class Word implements Comparable { + 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); + } +} diff --git a/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/WordContainer.java b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/WordContainer.java new file mode 100644 index 0000000..21b014b --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/main/java/ua/nure/jfn/task4/WordContainer.java @@ -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 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); + } +} diff --git a/semester-4/ОПJа/lb-4/task4/src/main/resources/resources_en.properties b/semester-4/ОПJа/lb-4/task4/src/main/resources/resources_en.properties new file mode 100644 index 0000000..df962a9 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/main/resources/resources_en.properties @@ -0,0 +1,2 @@ +table = table +apple = apple \ No newline at end of file diff --git a/semester-4/ОПJа/lb-4/task4/src/main/resources/resources_uk.properties b/semester-4/ОПJа/lb-4/task4/src/main/resources/resources_uk.properties new file mode 100644 index 0000000..f14ead4 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/main/resources/resources_uk.properties @@ -0,0 +1,2 @@ +table = \u0441\u0442\u0456\u043b +apple = \u044f\u0431\u043b\u0443\u043a\u043e diff --git a/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part1Test.java b/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part1Test.java new file mode 100644 index 0000000..13c066f --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part1Test.java @@ -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()); + } + +} diff --git a/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part2Test.java b/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part2Test.java new file mode 100644 index 0000000..da397c8 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part2Test.java @@ -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); + } + } + +} diff --git a/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part3Test.java b/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part3Test.java new file mode 100644 index 0000000..e23737e --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part3Test.java @@ -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 stream = Files.newDirectoryStream(Path.of(classPathURI))) { + for (Path p : stream) { + if (p.toString().endsWith(".properties")) { + Files.delete(p); + } + } + } + + Path classPath = Paths.get(classPathURI); + List 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()); + } + +} diff --git a/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part4Test.java b/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part4Test.java new file mode 100644 index 0000000..de79a24 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part4Test.java @@ -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()); + } + +} diff --git a/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part5Test.java b/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part5Test.java new file mode 100644 index 0000000..ddeaef4 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Part5Test.java @@ -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 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; + } + +} diff --git a/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Utils.java b/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Utils.java new file mode 100644 index 0000000..df182b8 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/java/ua/nure/jfn/task4/Utils.java @@ -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); + } + } + +} diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/en.props b/semester-4/ОПJа/lb-4/task4/src/test/resources/en.props new file mode 100644 index 0000000..df962a9 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/en.props @@ -0,0 +1,2 @@ +table = table +apple = apple \ No newline at end of file diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/ka.props b/semester-4/ОПJа/lb-4/task4/src/test/resources/ka.props new file mode 100644 index 0000000..72cd6b3 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/ka.props @@ -0,0 +1,2 @@ +table = \u10db\u10d0\u10d2\u10d8\u10d3\u10d0 +apple = \u10d5\u10d0\u10e8\u10da\u10d8 diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/convert.sh b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/convert.sh new file mode 100644 index 0000000..4bdfa05 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/convert.sh @@ -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 \ No newline at end of file diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part1-data.txt b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part1-data.txt new file mode 100644 index 0000000..ede668d --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part1-data.txt @@ -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: Сонце гріє лице Радує це +==================================== diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part1.csv b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part1.csv new file mode 100644 index 0000000..2c85fbd --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part1.csv @@ -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: Сонце гріє лице Радує це diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part2-data.txt b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part2-data.txt new file mode 100644 index 0000000..29efacd --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part2-data.txt @@ -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 + +==================================== diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part2.csv b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part2.csv new file mode 100644 index 0000000..547377b --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part2.csv @@ -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 diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part3-data.txt b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part3-data.txt new file mode 100644 index 0000000..df909f4 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part3-data.txt @@ -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 +яблуко +яблуко + +==================================== diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part3.csv b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part3.csv new file mode 100644 index 0000000..718fa75 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part3.csv @@ -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~яблуко~яблуко diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part4-data.txt b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part4-data.txt new file mode 100644 index 0000000..3c35aaf --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part4-data.txt @@ -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 + +==================================== diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part4.csv b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part4.csv new file mode 100644 index 0000000..aafd456 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part4.csv @@ -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 diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part5-data.txt b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part5-data.txt new file mode 100644 index 0000000..c3a862d --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part5-data.txt @@ -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 + +==================================== + diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part5.csv b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part5.csv new file mode 100644 index 0000000..ffd2998 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/ua/nure/jfn/task4/part5.csv @@ -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 diff --git a/semester-4/ОПJа/lb-4/task4/src/test/resources/uk.props b/semester-4/ОПJа/lb-4/task4/src/test/resources/uk.props new file mode 100644 index 0000000..f14ead4 --- /dev/null +++ b/semester-4/ОПJа/lb-4/task4/src/test/resources/uk.props @@ -0,0 +1,2 @@ +table = \u0441\u0442\u0456\u043b +apple = \u044f\u0431\u043b\u0443\u043a\u043e diff --git a/semester-4/ОПJа/lb-4/tasks.pdf b/semester-4/ОПJа/lb-4/tasks.pdf new file mode 100644 index 0000000..918ec0d Binary files /dev/null and b/semester-4/ОПJа/lb-4/tasks.pdf differ