1
1
package day16 ;
2
2
3
3
import java .util .ArrayList ;
4
+ import java .util .Arrays ;
4
5
5
6
import org .apache .commons .lang3 .ArrayUtils ;
6
7
@@ -27,12 +28,20 @@ public static void main(String[] args) {
27
28
28
29
moves .add (new Move (move , arg1 , arg2 ));
29
30
}
30
-
31
+ char [] orig = { 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , 'p' };
31
32
char [] ps = { 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , 'p' };
32
33
34
+ ArrayList <char []> pasts = new ArrayList <>();
35
+
33
36
char c3 , c4 ;
34
37
int pos1 , pos2 ;
35
- for (int j = 0 ; j < 1000000000 ; j ++) {
38
+ boolean found = false ;
39
+
40
+ for (int j = 0 ; j < 200 ; j ++) {
41
+ char [] temp = new char [ps .length ];
42
+ System .arraycopy (ps , 0 , temp , 0 , ps .length );
43
+ pasts .add (temp );
44
+ System .out .println (j + ": " +new String (ps ));
36
45
for (Move move : moves ) {
37
46
switch (move .move ) {
38
47
case "s" :
@@ -44,7 +53,7 @@ public static void main(String[] args) {
44
53
case "p" :
45
54
c3 = move .arg1 ;
46
55
c4 = move .arg2 ;
47
-
56
+
48
57
pos1 = ArrayUtils .indexOf (ps , c3 );
49
58
pos2 = ArrayUtils .indexOf (ps , c4 );
50
59
@@ -54,16 +63,40 @@ public static void main(String[] args) {
54
63
}
55
64
56
65
}
57
-
66
+
67
+
58
68
if (j % 1000000 == 0 )
59
69
System .out .println (j );
70
+
71
+ if (!found ) {
72
+ for (char [] cs : pasts ) {
73
+ if (Arrays .equals (orig , ps )) {
74
+ System .out .println (j );
75
+ found = true ;
76
+ System .out .println (1000000000 % j );
77
+ break ;
78
+ }
79
+ }
80
+ }
81
+ // if(found){
82
+ // break;
83
+ // }
60
84
}
61
85
62
86
System .out .println (new String (ps ));
63
87
64
88
}
65
89
}
66
90
91
+ class Program {
92
+ int position ;
93
+ char name ;
94
+
95
+ public Program (char name , int pos ) {
96
+
97
+ }
98
+ }
99
+
67
100
class Move {
68
101
public String move ;
69
102
public int pos1 , pos2 ;
0 commit comments