Browse Source

update solution for problem 62 to compile/return correctly.

master
Charles Reid 8 years ago
parent
commit
f65823d02a
  1. 2
      scratch/062/Makefile
  2. 5
      scratch/062/Problem062.java
  3. 14
      scratch/062/problem.txt

2
scratch/062/Makefile

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
default:
javac Problem062.java && java Problem062

5
scratch/062/Problem062.java

@ -13,11 +13,11 @@ public class Problem062 { @@ -13,11 +13,11 @@ public class Problem062 {
/** Set the problem size and solve it. */
public static void solve() {
smallestCubePermutes(5);
System.out.println(smallestCubePermutes(5));
}
/** Find the smallest cube that permutes with nperms other cubes. */
public static void smallestCubePermutes(int nperms) {
public static BigInteger smallestCubePermutes(int nperms) {
/*
* The hash map is central to doing this fast.
* We compute a round of 10^{N-1} to 10^N perfect cubes,
@ -64,6 +64,7 @@ public class Problem062 { @@ -64,6 +64,7 @@ public class Problem062 {
}
}
System.out.println("Search for a cube that permutes "+nperms+" times failed. Search stopped at "+MAX+".");
return null;
}

14
scratch/062/problem.txt

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
The cube, 41063625 (345^3), can be permuted to produce two other cubes:
56623104 (384^3) and 66430125 (405^3).
In fact, 41063625 is the smallest cube which has exactly
three permutations of its digits which are also cube.
Find the smallest cube for which exactly five permutations of its digits are cube.
Classic interview problem.
Loading…
Cancel
Save