Created
March 25, 2020 09:18
-
-
Save joriki/50650dfd9ace9a5afa8bce32547b63ed to your computer and use it in GitHub Desktop.
Solve a digit subtraction problem; see https://math.stackexchange.com/questions/3594010.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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