Skip to content

Commit 7647a4c

Browse files
committed
update day 16
1 parent b840670 commit 7647a4c

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

src/day16/Main.java

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package day16;
22

33
import java.util.ArrayList;
4+
import java.util.Arrays;
45

56
import org.apache.commons.lang3.ArrayUtils;
67

@@ -27,12 +28,20 @@ public static void main(String[] args) {
2728

2829
moves.add(new Move(move, arg1, arg2));
2930
}
30-
31+
char[] orig = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p' };
3132
char[] ps = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p' };
3233

34+
ArrayList<char[]> pasts = new ArrayList<>();
35+
3336
char c3, c4;
3437
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));
3645
for (Move move : moves) {
3746
switch (move.move) {
3847
case "s":
@@ -44,7 +53,7 @@ public static void main(String[] args) {
4453
case "p":
4554
c3 = move.arg1;
4655
c4 = move.arg2;
47-
56+
4857
pos1 = ArrayUtils.indexOf(ps, c3);
4958
pos2 = ArrayUtils.indexOf(ps, c4);
5059

@@ -54,16 +63,40 @@ public static void main(String[] args) {
5463
}
5564

5665
}
57-
66+
67+
5868
if (j % 1000000 == 0)
5969
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+
// }
6084
}
6185

6286
System.out.println(new String(ps));
6387

6488
}
6589
}
6690

91+
class Program {
92+
int position;
93+
char name;
94+
95+
public Program(char name, int pos) {
96+
97+
}
98+
}
99+
67100
class Move {
68101
public String move;
69102
public int pos1, pos2;

0 commit comments

Comments
 (0)