Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit 0d64e17

Browse files
committed
Лабораторная №32 fixes
1 parent a4af6c9 commit 0d64e17

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

students/23K0120/23K0120-p32/src/main/java/ru/mirea/practice/s23k0120/task1/Combinatorics.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ private int maxMobileInd(List<DirectedInteger> directedIntegers) {
4747
}
4848
}
4949
} else if (i == size - 1 && dirInt.getDirection() == Direction.LEFT && directedIntegers.get(i - 1).getValue() < dirInt.getValue()) {
50-
maxInd = i;
50+
if (maxInd == -1 || directedIntegers.get(maxInd).getValue() < dirInt.getValue()) {
51+
maxInd = i;
52+
}
5153
} else if (i == 0 && dirInt.getDirection() == Direction.RIGHT && directedIntegers.get(1).getValue() < dirInt.getValue()) {
5254
maxInd = i;
5355
}
@@ -112,7 +114,7 @@ public void switchDirection() {
112114

113115
@Override
114116
public String toString() {
115-
return direction + " " + value;
117+
return direction == Direction.LEFT ? "<" + value : value + ">";
116118
}
117119
}
118120
}

students/23K0120/23K0120-p32/src/main/java/ru/mirea/practice/s23k0120/task1/Main.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ru.mirea.practice.s23k0120.task1;
22

33
import java.util.List;
4+
import java.util.stream.Collectors;
45

56
public abstract class Main {
67
public static String combine(List<Integer> list) {
@@ -13,8 +14,8 @@ public static String combine(List<Integer> list) {
1314

1415
public static void main(String[] args) {
1516
Combinatorics comb = new Combinatorics();
16-
List<List<Integer>> perms = comb.permutations(4);
17-
System.out.println(perms);
17+
List<List<Integer>> perms = comb.permutations(5);
18+
System.out.println(perms.stream().map(Main::combine).collect(Collectors.toList()));
1819
System.out.println(perms.size());
1920
}
2021
}

0 commit comments

Comments
 (0)