Skip to content

Instantly share code, notes, and snippets.

@joriki
Created March 25, 2020 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joriki/50650dfd9ace9a5afa8bce32547b63ed to your computer and use it in GitHub Desktop.
Save joriki/50650dfd9ace9a5afa8bce32547b63ed to your computer and use it in GitHub Desktop.
Solve a digit subtraction problem; see https://math.stackexchange.com/questions/3594010.
public class Question3594010 {
public static void main(String [] args) {
for (int [] p : Permutations.getPermutations (9)) {
int n1 = getNumber(p,0);
int n2 = getNumber(p,1);
if (n1 - n2 == 33333)
System.out.println(n1 + " - " + n2 + " = 33333");
}
}
private static int getNumber(int [] p,int i) {
int number = 0;
while (i < p.length) {
number *= 10;
number += p [i] + 1;
i += 2;
}
return number;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment