This repository was archived by the owner on Dec 28, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
students/23K0120/23K0120-p32/src/main/java/ru/mirea/practice/s23k0120/task1 Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,9 @@ private int maxMobileInd(List<DirectedInteger> directedIntegers) {
47
47
}
48
48
}
49
49
} 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
+ }
51
53
} else if (i == 0 && dirInt .getDirection () == Direction .RIGHT && directedIntegers .get (1 ).getValue () < dirInt .getValue ()) {
52
54
maxInd = i ;
53
55
}
@@ -112,7 +114,7 @@ public void switchDirection() {
112
114
113
115
@ Override
114
116
public String toString () {
115
- return direction + " " + value ;
117
+ return direction == Direction . LEFT ? "<" + value : value + ">" ;
116
118
}
117
119
}
118
120
}
Original file line number Diff line number Diff line change 1
1
package ru .mirea .practice .s23k0120 .task1 ;
2
2
3
3
import java .util .List ;
4
+ import java .util .stream .Collectors ;
4
5
5
6
public abstract class Main {
6
7
public static String combine (List <Integer > list ) {
@@ -13,8 +14,8 @@ public static String combine(List<Integer> list) {
13
14
14
15
public static void main (String [] args ) {
15
16
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 ()) );
18
19
System .out .println (perms .size ());
19
20
}
20
21
}
You can’t perform that action at this time.
0 commit comments