-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVampStrArray.java
More file actions
33 lines (29 loc) · 1002 Bytes
/
VampStrArray.java
File metadata and controls
33 lines (29 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.*;
public class VampStrArray {
private static final int start = 11;
private static final int end = 99;
int a, b, product;
String[] resultLeft, resultRight;
public void count() {
int bottom = (start - 1) * (end + 1) - 1;
for (a = start; a <= end; ++a) {
for (b = end; b >= a; --b) {
product = a * b;
if (product <= bottom) {
break;
}
resultLeft = (String.valueOf(a) + String.valueOf(b)).split("");
resultRight = String.valueOf(product).split("");
Arrays.sort(resultLeft);
Arrays.sort(resultRight);
if (Arrays.equals(resultLeft, resultRight)) {
System.out.println(a + " * " + b + " = " + product);
}
}
}
}
public static void main(String[] args) {
VampStrArray run = new VampStrArray();
run.count();
}
}